Skip to content

Commit

Permalink
Upgraded and tested latest supported deps.
Browse files Browse the repository at this point in the history
  • Loading branch information
charettes committed Jan 23, 2023
1 parent 9cac985 commit c5185f6
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 59 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ jobs:
fail-fast: false
max-parallel: 5
matrix:
python-version: ['3.6', '3.7', '3.8', '3.9']
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11']

services:
postgres:
image: postgres:10
image: postgres:12
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
Expand Down
10 changes: 5 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,25 +13,25 @@
url="https://github.com/charettes/django-syzygy",
author="Simon Charette",
author_email="charette.s@gmail.com",
install_requires=["Django>=2.2"],
install_requires=["Django>=3.2"],
packages=find_packages(exclude=["tests", "tests.*"]),
license="MIT License",
classifiers=[
"Environment :: Web Environment",
"Framework :: Django",
"Framework :: Django :: 2.2",
"Framework :: Django :: 3.0",
"Framework :: Django :: 3.1",
"Framework :: Django :: 3.2",
"Framework :: Django :: 4.0",
"Framework :: Django :: 4.1",
"Framework :: Django :: 4.2",
"Intended Audience :: Developers",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Topic :: Software Development :: Libraries :: Python Modules",
],
)
14 changes: 5 additions & 9 deletions syzygy/autodetector.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
from django.db.models.fields import NOT_PROVIDED
from django.utils.functional import cached_property

from .compat import get_model_state_field
from .constants import Stage
from .exceptions import AmbiguousStage
from .operations import (
Expand Down Expand Up @@ -156,11 +155,10 @@ def add_operation(self, app_label, operation, dependencies=None, beginning=False
operation = RenameModel.for_stage(operation, stage)
elif isinstance(operation, operations.AlterField) and not operation.field.null:
# Addition of not-NULL constraints must be performed post-deployment.
from_null = get_model_state_field(
self.from_state.models[app_label, operation.model_name_lower],
operation.name,
).null
if from_null:
from_field = self.from_state.models[
app_label, operation.model_name_lower
].fields[operation.name]
if from_field.null:
operation = AlterField.for_stage(operation, Stage.POST_DEPLOY)
super().add_operation(app_label, operation, dependencies, beginning)

Expand All @@ -186,9 +184,7 @@ def _generate_added_field(self, app_label, model_name, field_name):
)

def _generate_removed_field(self, app_label, model_name, field_name):
field = get_model_state_field(
self.from_state.models[app_label, model_name], field_name
)
field = self.from_state.models[app_label, model_name].fields[field_name]
remove_default = field.default
if remove_default is NOT_PROVIDED and field.null:
return super()._generate_removed_field(app_label, model_name, field_name)
Expand Down
16 changes: 0 additions & 16 deletions syzygy/compat.py

This file was deleted.

4 changes: 2 additions & 2 deletions tests/test_autodetector.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,8 +328,8 @@ def test_field_rename(self):
],
),
]
questioner = InteractiveMigrationQuestioner()
with captured_stdin() as stdin, captured_stdout() as stdout, captured_stderr() as stderr:
questioner = InteractiveMigrationQuestioner()
stdin.write("y\n2\n")
stdin.seek(0)
self.get_changes(from_models, to_models, questioner)
Expand Down Expand Up @@ -369,8 +369,8 @@ def test_model_rename(self):
],
),
]
questioner = InteractiveMigrationQuestioner()
with captured_stdin() as stdin, captured_stdout() as stdout, captured_stderr() as stderr:
questioner = InteractiveMigrationQuestioner()
stdin.write("y\n2\n")
stdin.seek(0)
self.get_changes(from_models, to_models, questioner)
Expand Down
7 changes: 5 additions & 2 deletions tests/test_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,11 @@


class BaseMigrateTests(TransactionTestCase):
def tearDown(self):
MigrationRecorder(connection).flush()
def setUp(self) -> None:
super().setUp()
recorder = MigrationRecorder(connection)
recorder.ensure_schema()
self.addCleanup(recorder.flush)

def call_command(self, *args, **options):
stdout = StringIO()
Expand Down
11 changes: 4 additions & 7 deletions tests/test_operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
from django.test import TestCase

from syzygy.autodetector import MigrationAutodetector
from syzygy.compat import get_model_state_field
from syzygy.constants import Stage
from syzygy.operations import AddField, PostAddField, PreRemoveField
from syzygy.plan import get_operation_stage
Expand Down Expand Up @@ -118,9 +117,7 @@ def test_database_forwards(
if not preserve_default:
self.assertIs(
NOT_PROVIDED,
get_model_state_field(
to_state.models["tests", model_name.lower()], field_name
).default,
to_state.models["tests", model_name.lower()].fields[field_name].default,
)
with connection.cursor() as cursor:
fields = connection.introspection.get_table_description(
Expand All @@ -144,9 +141,9 @@ def test_database_backwards(self, preserve_default=True):
if not preserve_default:
self.assertIs(
NOT_PROVIDED,
get_model_state_field(
from_state.models["tests", model_name.lower()], field_name
).default,
from_state.models["tests", model_name.lower()]
.fields[field_name]
.default,
)
with connection.cursor() as cursor:
fields = connection.introspection.get_table_description(
Expand Down
32 changes: 16 additions & 16 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,25 @@ envlist =
isort,
mypy,
pypi,
py{36,37,38,39}-{2.2,3.0,3.1,3.2},
py{38,39}-{4.0,main},
py{36,37,38,39}-{2.2,3.0,3.1,3.2}-postgresql,
py{38,39}-{4.0,main}-postgresql,
py37-{3.2}-{sqlite,postgresql},
py{38,39,310}-{3.2,4.0,4.1,4.2,main}-{sqlite,postgresql},
py311-{4.1,4.2,main}-{sqlite,postgresql},

[gh-actions]
python =
3.6: py36, black, flake8, isort, mypy
3.7: py37
3.7: py37, black, flake8, isort, mypy
3.8: py38
3.9: py39
3.10: py310
3.11: py311

[testenv]
basepython =
py36: python3.6
py37: python3.7
py38: python3.8
py39: python3.9
py310: python3.10
py311: python3.11
usedevelop = true
setenv =
DJANGO_SETTINGS_MODULE=tests.settings
Expand All @@ -37,11 +38,10 @@ commands =
coverage report
deps =
coverage
2.2: Django>=2.2,<3
3.0: Django>=3.0,<3.1
3.1: Django>=3.1,<3.2
3.2: Django>=3.2,<4
4.0: Django>=4.0a1,<4.1
4.0: Django>=4.0,<4.1
4.1: Django>=4.1,<4.2
4.2: Django>=4.2a1,<5
main: https://github.com/django/django/archive/main.tar.gz
postgresql: psycopg2-binary
ignore_outcome =
Expand All @@ -55,26 +55,26 @@ deps = black

[testenv:flake8]
usedevelop = false
basepython = python3.6
basepython = python3.7
commands = flake8
deps = flake8

[testenv:isort]
usedevelop = false
basepython = python3.6
basepython = python3.7
commands = isort --check-only --diff syzygy tests
deps =
isort
Django>=2.2,<3.1
Django>=3.2,<4

[testenv:mypy]
usedevelop = false
basepython = python3.6
basepython = python3.8
commands = mypy -p syzygy --warn-redundant-casts
deps =
mypy
django-stubs
Django>=2.2,<3.1
Django>=3.2,<4

[testenv:pypi]
usedevelop = false
Expand Down

0 comments on commit c5185f6

Please sign in to comment.