Skip to content

Commit

Permalink
Drop Python 3.7 support (#272)
Browse files Browse the repository at this point in the history
  • Loading branch information
adamchainz authored Jul 10, 2023
1 parent c0fc159 commit a0da9d2
Show file tree
Hide file tree
Showing 11 changed files with 16 additions and 271 deletions.
1 change: 0 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ jobs:
strategy:
matrix:
python-version:
- 3.7
- 3.8
- 3.9
- '3.10'
Expand Down
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ repos:
rev: v3.7.0
hooks:
- id: pyupgrade
args: [--py37-plus]
args: [--py38-plus]
- repo: https://github.com/adamchainz/django-upgrade
rev: 1.14.0
hooks:
Expand All @@ -60,7 +60,7 @@ repos:
hooks:
- id: reorder-python-imports
args:
- --py37-plus
- --py38-plus
- --application-directories
- .:example:src
- --add-import
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
Changelog
=========

* Drop Python 3.7 support.

2.10.0 (2023-07-03)
-------------------

Expand Down
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ For a bit of background, see the `introductory blog post <https://adamj.eu/tech/
Requirements
============

Python 3.7 to 3.12 supported.
Python 3.8 to 3.12 supported.

Django 3.2 to 4.2 supported.

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ requires = [
]

[tool.black]
target-version = ['py37']
target-version = ['py38']

[tool.pytest.ini_options]
addopts = """\
Expand Down
12 changes: 0 additions & 12 deletions requirements/compile.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,6 @@
"--generate-hashes",
"--allow-unsafe",
] + sys.argv[1:]
subprocess.run(
[
"python3.7",
*common_args,
"-P",
"Django>=3.2a1,<3.3",
"-o",
"py37-django32.txt",
],
check=True,
capture_output=True,
)
subprocess.run(
[
"python3.8",
Expand Down
212 changes: 0 additions & 212 deletions requirements/py37-django32.txt

This file was deleted.

3 changes: 1 addition & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ classifiers =
Operating System :: OS Independent
Programming Language :: Python :: 3
Programming Language :: Python :: 3 :: Only
Programming Language :: Python :: 3.7
Programming Language :: Python :: 3.8
Programming Language :: Python :: 3.9
Programming Language :: Python :: 3.10
Expand All @@ -39,7 +38,7 @@ project_urls =
packages = find:
install_requires =
Django>=3.2
python_requires = >=3.7
python_requires = >=3.8
include_package_data = True
package_dir =
=src
Expand Down
30 changes: 0 additions & 30 deletions src/django_linear_migrations/compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,34 +5,6 @@
import sys
from typing import no_type_check

if sys.version_info >= (3, 8):
# Bridge the change from ast.Str to ast.Constant

ast_constant_type = ast.Constant

def is_ast_constant_str(node: ast.AST) -> bool:
return isinstance(node, ast.Constant) and isinstance(node.value, str)

def get_ast_constant_str_value(node: ast.Constant) -> str:
value = node.value
assert isinstance(value, str)
return value

def make_ast_constant_str(value: str) -> ast.Constant:
return ast.Constant(value=value, kind=None)

else:
ast_constant_type = ast.Str

def is_ast_constant_str(node: ast.AST) -> bool:
return isinstance(node, ast.Str)

def get_ast_constant_str_value(node: ast.Str) -> str:
return node.s

def make_ast_constant_str(value: str) -> ast.Str:
return ast.Str(s=value)


if sys.version_info >= (3, 9):
ast_unparse = ast.unparse
Expand Down Expand Up @@ -496,8 +468,6 @@ def _Constant(self, t):
elif value is ...:
self.write("...")
else:
if t.kind == "u":
self.write("u")
self._write_constant(t.value)

@no_type_check
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,7 @@

from django_linear_migrations.apps import is_first_party_app_config
from django_linear_migrations.apps import MigrationDetails
from django_linear_migrations.compat import ast_constant_type
from django_linear_migrations.compat import ast_unparse
from django_linear_migrations.compat import get_ast_constant_str_value
from django_linear_migrations.compat import is_ast_constant_str
from django_linear_migrations.compat import make_ast_constant_str


class Command(BaseCommand):
Expand Down Expand Up @@ -121,22 +117,26 @@ def handle(self, *args: Any, app_label: str, **options: Any) -> None:
if (
not isinstance(dependency, (ast.Tuple, ast.List))
or len(dependency.elts) != 2
or not all(is_ast_constant_str(el) for el in dependency.elts)
or not all(
isinstance(el, ast.Constant) and isinstance(el.value, str)
for el in dependency.elts
)
):
new_dependencies.elts.append(dependency)
continue

dependency_app_label_node = dependency.elts[0]
assert isinstance(dependency_app_label_node, ast_constant_type)
dependency_app_label = get_ast_constant_str_value(dependency_app_label_node)
assert isinstance(dependency_app_label_node, ast.Constant)
dependency_app_label = dependency_app_label_node.value
assert isinstance(dependency_app_label, str)

if dependency_app_label == app_label:
num_this_app_dependencies += 1
new_dependencies.elts.append(
ast.Tuple(
elts=[
make_ast_constant_str(app_label),
make_ast_constant_str(merged_migration_name),
ast.Constant(app_label),
ast.Constant(merged_migration_name),
]
)
)
Expand Down
1 change: 0 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ env_list =
py310-django{42, 41, 40, 32}
py39-django{42, 41, 40, 32}
py38-django{42, 41, 40, 32}
py37-django{32}

[testenv]
package = wheel
Expand Down

0 comments on commit a0da9d2

Please sign in to comment.