Skip to content

Commit

Permalink
Merge 4b069ac into ff0668f
Browse files Browse the repository at this point in the history
  • Loading branch information
charettes committed Apr 14, 2020
2 parents ff0668f + 4b069ac commit cc82d24
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 5 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ dist/
*.egg-info/*
.coverage
.tox
.mypy_cache/
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ jobs:
include:
- { stage: lint, env: TOXENV=flake8, python: 3.6 }
- { stage: lint, env: TOXENV=isort, python: 3.6 }
- { stage: lint, env: TOXENV=mypy, python: 3.6 }
- stage: deploy
if: tag IS present
python: 3.6
Expand Down
8 changes: 7 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,11 @@ branch = 1
[flake8]
max-line-length = 119

[mypy]
plugins = mypy_django_plugin.main

[mypy.plugins.django-stubs]
django_settings_module = "tests.settings"

[wheel]
universal = 1
universal = 1
4 changes: 3 additions & 1 deletion syzygy/management/commands/migrate.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from django.core.management import CommandError
from django.core.management.commands.migrate import Command as MigrateCommand
from django.core.management.commands.migrate import ( # type: ignore
Command as MigrateCommand,
)
from django.db.models.signals import pre_migrate

from syzygy.plan import get_prerequisite_plan
Expand Down
6 changes: 3 additions & 3 deletions syzygy/plan.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from typing import List, NewType, Optional, Tuple
from typing import List, Optional, Tuple

from django.conf import settings
from django.db.migrations import DeleteModel, Migration, RemoveField
from django.db.migrations.operations.base import Operation

Plan = NewType("Plan", List[Tuple[Migration, bool]])
Plan = List[Tuple[Migration, bool]]


def must_postpone_operation(
Expand Down Expand Up @@ -63,7 +63,7 @@ def get_prerequisite_plan(plan: Plan) -> Plan:
If the plan contains non-contiguous sequence of prerequisite migrations
or migrations with ambiguous prerequisite nature a `ValueError` is raised.
"""
prerequisite_plan = []
prerequisite_plan: Plan = []
postpone = False
for migration, backward in plan:
if must_postpone_migration(migration, backward):
Expand Down
4 changes: 4 additions & 0 deletions tests/settings.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
from typing import Dict, Tuple

SECRET_KEY = "not-secret-anymore"

TIME_ZONE = "America/Montreal"

DATABASES = {"default": {"ENGINE": "django.db.backends.sqlite3"}}

INSTALLED_APPS = ["syzygy", "tests"]

SYZYGY_POSTPONE: Dict[Tuple[str, str], bool] = {}
9 changes: 9 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,12 @@ commands = isort --recursive --check-only --diff syzygy tests
deps =
isort
Django>=2.2,<3

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

0 comments on commit cc82d24

Please sign in to comment.