Skip to content
Snippets Groups Projects
Commit 66a2948b authored by Todd Dembrey's avatar Todd Dembrey
Browse files

Tidy up the typing settings

parent 7ee56a40
No related branches found
No related tags found
No related merge requests found
......@@ -43,8 +43,8 @@ script:
# Type check the project
- mypy .
# Type check the apply module
- mypy opentech/apply --check-untyped-defs --ignore-missing-imports
# Type check the project
- mypy .
# Run system checks
- python manage.py check
......
mypy.ini 0 → 100644
[mypy]
show_column_numbers = True
ignore_missing_imports = True
[mypy-opentech.*]
ignore_errors = True
[mypy-opentech.apply.*]
check_untyped_defs = True
ignore_errors = False
[mypy-opentech.apply.tests.*]
# ignore_errors = True
\ No newline at end of file
......@@ -44,7 +44,7 @@ class TestStageCreation(SimpleTestCase):
def test_can_iterate_through_phases(self):
stage = StageFactory()
for phase, check in zip(stage, stage.phases):
for phase, check in zip(stage, stage.phases): # type: ignore # spurious error
self.assertEqual(phase, check)
......
from typing import Iterator, Iterable, Sequence, Union
from typing import Dict, Iterator, Iterable, Sequence, Tuple, Union
from django.forms import Form
......@@ -9,8 +9,8 @@ class Workflow:
self.stages = stages
self.mapping = self.build_mapping(stages)
def build_mapping(self, stages):
mapping = {}
def build_mapping(self, stages: Sequence['Stage']) -> Dict[str, Tuple[int, int]]:
mapping: Dict[str, Tuple[int, int]] = {}
for i, stage in enumerate(stages):
for j, phase in enumerate(stage):
while str(phase) in mapping:
......@@ -26,7 +26,7 @@ class Workflow:
except KeyError:
return 0, -1
def next(self, current_phase: Union['Phase', str, None]=None) -> Union['Phase', None]:
def next(self, current_phase: Union['Phase', str]=None) -> Union['Phase', None]:
stage_idx, phase_idx = self.current_index(current_phase)
try:
return self.stages[stage_idx].phases[phase_idx + 1]
......@@ -57,6 +57,7 @@ class Stage(Iterable['Phase']):
class Phase:
def __init__(self, name: str) -> None:
self.name = name
self.stage: Union['Stage', None] = None
self.occurance = 0
def __str__(self):
......
......@@ -51,6 +51,6 @@ source $VIRTUALENV_DIR/bin/activate
export PS1="[$PROJECT_NAME \W]\\$ "
cd $PROJECT_DIR
alias djtestapply="dj test opentech.apply --keepdb; mypy opentech/apply --check-untyped-defs --ignore-missing-imports"
alias djtestapply="dj test opentech.apply --keepdb; mypy ."
EOF
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment