Remove support for Python < 3.6 and Django < 2.2.

This commit is contained in:
Emil Stenström 2021-02-12 21:10:33 +01:00
parent ab7e97658f
commit 2c95b0930f
6 changed files with 22 additions and 67 deletions

View file

@ -106,14 +106,14 @@ TEMPLATES = [
# Compatiblity
| Python version | Django version |
|----------------|-------------------------------|
| 2.7 | 1.11 |
| 3.5 | 1.11, 2.0, 2.1, 2.2 |
| 3.6 | 1.11, 2.0, 2.1, 2.2, 3.0, 3.1 |
| 3.7 | 1.11, 2.0, 2.1, 2.2, 3.0, 3.1 |
| 3.8 | 2.1, 2.2, 3.0, 3.1 |
| 3.9 | 2.1, 2.2, 3.0, 3.1 |
Django-components supports all officially supported versions of Django and Python.
| Python version | Django version |
|----------------|--------------------------|
| 3.6 | 2.2, 3.0, 3.1 |
| 3.7 | 2.2, 3.0, 3.1 |
| 3.8 | 2.2, 3.0, 3.1 |
| 3.9 | 2.2, 3.0, 3.1 |
# Create your first component

View file

@ -3,7 +3,6 @@ from time import perf_counter
from django.template import Context, Template
from django_components import component
from tests.django_test_setup import * # NOQA
from tests.testutils import Django111CompatibleSimpleTestCase as SimpleTestCase

View file

@ -4,7 +4,7 @@ from itertools import chain
from django.conf import settings
from django.forms.widgets import MediaDefiningClass
from django.template.base import NodeList
from django.template.base import NodeList, TokenType
from django.template.loader import get_template
from django.utils.safestring import mark_safe
from six import with_metaclass
@ -12,17 +12,6 @@ from six import with_metaclass
# Allow "component.AlreadyRegistered" instead of having to import these everywhere
from django_components.component_registry import AlreadyRegistered, ComponentRegistry, NotRegistered # noqa
# Django < 2.1 compatibility
try:
from django.template.base import TokenType
except ImportError:
from django.template.base import TOKEN_BLOCK, TOKEN_TEXT, TOKEN_VAR
class TokenType:
TEXT = TOKEN_TEXT
VAR = TOKEN_VAR
BLOCK = TOKEN_BLOCK
class Component(with_metaclass(MediaDefiningClass)):

View file

@ -1,39 +1,12 @@
from collections import defaultdict
import django
from django import template
from django.template.base import Node, NodeList, TemplateSyntaxError
from django.template.base import Node, NodeList, TemplateSyntaxError, TokenType
from django.template.library import parse_bits
from django.utils.safestring import mark_safe
from django_components.component import registry
# Django < 2.1 compatibility
try:
from django.template.base import TokenType
except ImportError:
from django.template.base import TOKEN_BLOCK, TOKEN_TEXT, TOKEN_VAR
class TokenType:
TEXT = TOKEN_TEXT
VAR = TOKEN_VAR
BLOCK = TOKEN_BLOCK
# Django < 2.0 compatibility
if django.VERSION > (2, 0):
PARSE_BITS_DEFAULTS = {
"varkw": [],
"defaults": None,
"kwonly": [],
"kwonly_defaults": None,
}
else:
PARSE_BITS_DEFAULTS = {
"varkw": [],
"defaults": None,
}
register = template.Library()
COMPONENT_CONTEXT_KEY = "component_context"
@ -212,7 +185,10 @@ def parse_component_with_args(parser, bits, tag_name):
takes_context=False,
name=tag_name,
varargs=True,
**PARSE_BITS_DEFAULTS
varkw=[],
defaults=None,
kwonly=[],
kwonly_defaults=None,
)
assert tag_name == tag_args[0].token, "Internal error: Expected tag_name to be {}, but it was {}".format(

View file

@ -20,9 +20,7 @@ setup(
keywords=["django", "components", "css", "js", "html"],
classifiers=[
"Programming Language :: Python",
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.5",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",

23
tox.ini
View file

@ -1,29 +1,22 @@
[tox]
envlist =
py27-django111
py35-django{111,20,21,22}
py36-django{111,20,21,22,30,31}
py37-django{111,20,21,22,30,31}
py38-django{21,22,30,31}
py39-django{21,22,30,31}
py36-django{22,30,31}
py37-django{22,30,31}
py38-django{22,30,31}
py39-django{22,30,31}
flake8
isort
[gh-actions]
2.7 = py27-django111
3.5 = py35-django{111,20,21,22}
3.6 = py36-django{111,20,21,22,30,31}
3.7 = py37-django{111,20,21,22,30,31}
3.8 = py38-django{21,22,30,31}
3.9 = py39-django{21,22,30,31}, flake8, isort
3.6 = py36-django{22,30,31}
3.7 = py37-django{22,30,31}
3.8 = py38-django{22,30,31}
3.9 = py39-django{22,30,31}, flake8, isort
[testenv]
deps =
pytest
pytest-xdist
django111: Django>=1.11,<2.0
django20: Django>=2.0,<2.1
django21: Django>=2.1,<2.2
django22: Django>=2.2,<2.3
django30: Django>=3.0,<3.1
django31: Django>=3.1,<3.2