Skip to content

Commit 83c0a5a

Browse files
committed
Add mypy linting
1 parent 15705cd commit 83c0a5a

File tree

6 files changed

+28
-9
lines changed

6 files changed

+28
-9
lines changed

pytest_django/asserts.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
"""
22
Dynamically load all Django assertion cases and expose them for importing.
33
"""
4+
from typing import Set
45
from functools import wraps
6+
57
from django.test import (
68
TestCase, SimpleTestCase,
79
LiveServerTestCase, TransactionTestCase
@@ -21,7 +23,7 @@ def assertion_func(*args, **kwargs):
2123

2224

2325
__all__ = []
24-
assertions_names = set()
26+
assertions_names = set() # type: Set[str]
2527
assertions_names.update(
2628
{attr for attr in vars(TestCase) if attr.startswith('assert')},
2729
{attr for attr in vars(SimpleTestCase) if attr.startswith('assert')},

pytest_django/fixtures.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
"""All pytest-django fixtures"""
2-
3-
2+
from typing import List, Any
43
import os
54
from contextlib import contextmanager
65
from functools import partial
@@ -356,7 +355,7 @@ def async_rf():
356355

357356

358357
class SettingsWrapper:
359-
_to_restore = []
358+
_to_restore = [] # type: List[Any]
360359

361360
def __delattr__(self, attr):
362361
from django.test import override_settings

pytest_django_test/app/migrations/0001_initial.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Generated by Django 1.9a1 on 2016-06-22 04:33
1+
from typing import List, Tuple
22

33
from django.db import migrations, models
44

@@ -7,7 +7,7 @@ class Migration(migrations.Migration):
77

88
initial = True
99

10-
dependencies = []
10+
dependencies = [] # type: List[Tuple[str, str]]
1111

1212
operations = [
1313
migrations.CreateModel(

setup.cfg

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,3 +69,20 @@ exclude = lib/,src/,docs/,bin/
6969

7070
[isort]
7171
forced_separate = tests,pytest_django,pytest_django_test
72+
73+
[mypy]
74+
disallow_any_generics = True
75+
no_implicit_optional = True
76+
show_error_codes = True
77+
strict_equality = True
78+
warn_redundant_casts = True
79+
warn_unreachable = True
80+
warn_unused_configs = True
81+
no_implicit_reexport = True
82+
83+
[mypy-django.*]
84+
ignore_missing_imports = True
85+
[mypy-configurations.*]
86+
ignore_missing_imports = True
87+
[mypy-psycopg2cffi.*]
88+
ignore_missing_imports = True

tests/test_fixtures.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,10 @@
33
Not quite all fixtures are tested here, the db and transactional_db
44
fixtures are tested in test_database.
55
"""
6-
7-
86
import socket
97
from contextlib import contextmanager
10-
from urllib.request import urlopen, HTTPError
8+
from urllib.error import HTTPError
9+
from urllib.request import urlopen
1110

1211
import pytest
1312
from django.conf import settings as real_settings

tox.ini

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,11 @@ commands =
5353
extras =
5454
deps =
5555
flake8
56+
mypy==0.812
5657
commands =
5758
flake8 --version
5859
flake8 --statistics {posargs:pytest_django pytest_django_test tests}
60+
mypy {posargs:pytest_django pytest_django_test tests}
5961

6062
[testenv:doc8]
6163
extras =

0 commit comments

Comments
 (0)