Skip to content

Commit 937bd47

Browse files
authored
added django 3.1 support (#55)
* added django 3.1 support * Add additional fixes * fix linting
1 parent 67c8c5d commit 937bd47

21 files changed

+66
-101
lines changed

.travis.yml

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,31 @@
11
language: python
22

33
dist: xenial
4-
sudo: false
54

65
matrix:
76
include:
87
- python: 3.5
98
env: TOX_ENV='flake8'
109
- python: 3.5
1110
env: TOX_ENV='isort'
12-
# Django 1.11
13-
- python: 2.7
14-
env: DJANGO='dj111'
15-
- python: 3.4
16-
env: DJANGO='dj111'
11+
# Django 2.2, run all supported versions for LTS releases
1712
- python: 3.5
18-
env: DJANGO='dj111'
19-
- python: 3.6
20-
env: DJANGO='dj111'
21-
# Django 2.1
22-
- python: 3.6
23-
env: DJANGO='dj21'
24-
# Django 2.2
13+
env: DJANGO='dj22'
2514
- python: 3.6
2615
env: DJANGO='dj22'
2716
- python: 3.7
2817
env: DJANGO='dj22'
2918
- python: 3.8
3019
env: DJANGO='dj22'
31-
# Django 3.0
20+
# Django 3.0, always run the lowest supported version
3221
- python: 3.6
3322
env: DJANGO='dj30'
34-
- python: 3.7
35-
env: DJANGO='dj30'
36-
- python: 3.8
37-
env: DJANGO='dj30'
23+
# Django 3.1, always run the lowest supported version
24+
- python: 3.6
25+
env: DJANGO='dj31'
3826

3927
install:
40-
- pip install coverage isort tox pep8
41-
- "if [[ $TRAVIS_PYTHON_VERSION == '2.7' ]]; then export PY_VER=py27; fi"
42-
- "if [[ $TRAVIS_PYTHON_VERSION == '3.4' ]]; then export PY_VER=py34; fi"
28+
- pip install coverage isort tox
4329
- "if [[ $TRAVIS_PYTHON_VERSION == '3.5' ]]; then export PY_VER=py35; fi"
4430
- "if [[ $TRAVIS_PYTHON_VERSION == '3.6' ]]; then export PY_VER=py36; fi"
4531
- "if [[ $TRAVIS_PYTHON_VERSION == '3.7' ]]; then export PY_VER=py37; fi"

CHANGELOG.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,15 @@ Changelog
33
=========
44

55

6+
2.0.0 (unreleased)
7+
==================
8+
9+
* Added support for Django 3.1
10+
* Dropped support for Python 2.7 and Python 3.4
11+
* Dropped support for Django < 2.2
12+
* Replaced pep8 with flake8
13+
14+
615
1.0.0 (2020-01-22)
716
==================
817

README.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ You can run tests by executing::
9696
.. |coverage| image:: https://codecov.io/gh/divio/django-classy-tags/branch/master/graph/badge.svg
9797
:target: https://codecov.io/gh/divio/django-classy-tags
9898

99-
.. |python| image:: https://img.shields.io/badge/python-2.7%20%7C%203.4+-blue.svg
99+
.. |python| image:: https://img.shields.io/badge/python-3.5+-blue.svg
100100
:target: https://pypi.org/project/django-classy-tags/
101-
.. |django| image:: https://img.shields.io/badge/django-1.11%20%7C%202.2%20%7C%203.0-blue.svg
101+
.. |django| image:: https://img.shields.io/badge/django-2.2,%203.0,%203.1-blue.svg
102102
:target: https://www.djangoproject.com/

classytags/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
# -*- coding: utf-8 -*-
21
__version__ = '1.0.0'

classytags/arguments.py

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21
from django import template
32
from django.core.exceptions import ImproperlyConfigured
43

@@ -10,7 +9,7 @@
109
)
1110

1211

13-
class Argument(object):
12+
class Argument:
1413
"""
1514
A basic single value argument.
1615
"""
@@ -61,7 +60,7 @@ class KeywordArgument(Argument):
6160

6261
def __init__(self, name, default=None, required=True, resolve=True,
6362
defaultkey=None, splitter='='):
64-
super(KeywordArgument, self).__init__(name, default, required, resolve)
63+
super().__init__(name, default, required, resolve)
6564
self.defaultkey = defaultkey
6665
self.splitter = splitter
6766

@@ -76,10 +75,10 @@ def get_default(self):
7675
def parse_token(self, parser, token):
7776
if self.splitter in token:
7877
key, raw_value = token.split(self.splitter, 1)
79-
value = super(KeywordArgument, self).parse_token(parser, raw_value)
78+
value = super().parse_token(parser, raw_value)
8079
else:
8180
key = self.defaultkey
82-
value = super(KeywordArgument, self).parse_token(parser, token)
81+
value = super().parse_token(parser, token)
8382
return key, self.value_class(value)
8483

8584
def parse(self, parser, token, tagname, kwargs):
@@ -107,7 +106,7 @@ class ChoiceArgument(Argument):
107106

108107
def __init__(self, name, choices, default=None, required=True,
109108
resolve=True):
110-
super(ChoiceArgument, self).__init__(name, default, required, resolve)
109+
super().__init__(name, default, required, resolve)
111110
if default or not required:
112111
value_on_error = default
113112
else:
@@ -136,8 +135,7 @@ def __init__(self, name, default=NULL, required=True, max_values=None,
136135
default = []
137136
else:
138137
required = False
139-
super(MultiValueArgument, self).__init__(name, default, required,
140-
resolve)
138+
super().__init__(name, default, required, resolve)
141139

142140
def parse(self, parser, token, tagname, kwargs):
143141
"""
@@ -160,8 +158,7 @@ def __init__(self, name, default=None, required=True, resolve=True,
160158
default = {}
161159
else:
162160
default = dict(default)
163-
super(MultiKeywordArgument, self).__init__(name, default, required,
164-
resolve, NULL, splitter)
161+
super().__init__(name, default, required, resolve, NULL, splitter)
165162
self.max_values = max_values
166163

167164
def get_default(self):
@@ -197,7 +194,7 @@ def __init__(self, name, default=NULL, true_values=None, false_values=None,
197194
required = False
198195
else:
199196
required = True
200-
super(Flag, self).__init__(name, default, required)
197+
super().__init__(name, default, required)
201198
if true_values is None:
202199
true_values = []
203200
if false_values is None:

classytags/blocks.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21
from django.core.exceptions import ImproperlyConfigured
32

43

@@ -9,7 +8,7 @@ def _collect(name, parser):
98
return name
109

1110

12-
class BlockDefinition(object):
11+
class BlockDefinition:
1312
"""
1413
Definition of 'parse-until-blocks' used by the parser.
1514
"""
@@ -27,7 +26,7 @@ def collect(self, parser):
2726
return [_collect(name, parser) for name in self.names]
2827

2928

30-
class VariableBlockName(object):
29+
class VariableBlockName:
3130
def __init__(self, template, argname):
3231
self.template = template
3332
self.argname = argname

classytags/core.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,13 @@
1-
# -*- coding: utf-8 -*-
21
from operator import attrgetter
32

43
from django.template import Node
54

6-
import six
7-
85
from classytags.blocks import BlockDefinition
96
from classytags.parser import Parser
107
from classytags.utils import StructuredOptions, get_default_name
118

129

13-
class Options(object):
10+
class Options:
1411
"""
1512
Option class holding the arguments of a tag.
1613
"""
@@ -26,8 +23,8 @@ def __init__(self, *options, **kwargs):
2623
self.options[current_breakpoint] = []
2724
self.all_argument_names = []
2825
for value in options:
29-
if isinstance(value, six.string_types):
30-
if isinstance(last, six.string_types):
26+
if isinstance(value, str):
27+
if isinstance(last, str):
3128
self.combined_breakpoints[last] = value
3229
self.breakpoints.append(value)
3330
current_breakpoint = value
@@ -40,7 +37,7 @@ def __init__(self, *options, **kwargs):
4037
for block in kwargs.get('blocks', []):
4138
if isinstance(block, BlockDefinition):
4239
block_definition = block
43-
elif isinstance(block, six.string_types):
40+
elif isinstance(block, str):
4441
block_definition = BlockDefinition(block, block)
4542
else:
4643
block_definition = BlockDefinition(block[1], block[0])
@@ -117,7 +114,7 @@ class TagMeta(type):
117114
def __new__(cls, name, bases, attrs):
118115
parents = [base for base in bases if isinstance(base, TagMeta)]
119116
if not parents:
120-
return super(TagMeta, cls).__new__(cls, name, bases, attrs)
117+
return super().__new__(cls, name, bases, attrs)
121118
tag_name = str(attrs.get('name', get_default_name(name)))
122119

123120
def fake_func():
@@ -126,7 +123,7 @@ def fake_func():
126123
fake_func.__name__ = tag_name
127124
attrs['_decorated_function'] = fake_func
128125
attrs['name'] = str(tag_name)
129-
return super(TagMeta, cls).__new__(cls, name, bases, attrs)
126+
return super().__new__(cls, name, bases, attrs)
130127

131128

132129
class Tag(TagMeta('TagMeta', (Node,), {})):

classytags/exceptions.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21
from django.template import TemplateSyntaxError
32

43

classytags/helpers.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21
from django.core.exceptions import ImproperlyConfigured
32
from django.template.loader import render_to_string
43

@@ -12,7 +11,7 @@ class AsTag(Tag):
1211
options must be added 'manually' to the options class.
1312
"""
1413
def __init__(self, parser, tokens):
15-
super(AsTag, self).__init__(parser, tokens)
14+
super().__init__(parser, tokens)
1615
if len(self.options.breakpoints) < 1:
1716
raise ImproperlyConfigured(
1817
"AsTag subclasses require at least one breakpoint."

classytags/parser.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21
from copy import deepcopy
32

43
from django import template
@@ -9,7 +8,7 @@
98
)
109

1110

12-
class Parser(object):
11+
class Parser:
1312
"""
1413
Argument parsing class. A new instance of this gets created each time a tag
1514
get's parsed.

0 commit comments

Comments
 (0)