Skip to content

Commit 52d9587

Browse files
final typing/mypy fixes
1 parent 725692e commit 52d9587

File tree

4 files changed

+21
-19
lines changed

4 files changed

+21
-19
lines changed

.pre-commit-config.yaml

+6-4
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,10 @@ repos:
1313
args: [--remove]
1414
- id: check-yaml
1515
- id: debug-statements
16-
language_version: python3
17-
- repo: https://gitlab.com/pycqa/flake8
18-
rev: 3.9.2
16+
- repo: https://github.com/pycqa/flake8
17+
rev: 4.0.1
1918
hooks:
2019
- id: flake8
21-
language_version: python3
2220
additional_dependencies:
2321
- flake8-typing-imports==1.9.0
2422
- repo: https://github.com/asottile/reorder_python_imports
@@ -36,3 +34,7 @@ repos:
3634
rev: "0.3.3"
3735
hooks:
3836
- id: pyproject-fmt
37+
- repo: https://github.com/pre-commit/mirrors-mypy
38+
rev: 'v0.960'
39+
hooks:
40+
- id: mypy

conftest.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import py
1+
import pathlib
22

33
import apipkg
44

5-
LOCAL_APIPKG = py.path.local(__file__).dirpath().join("src/apipkg/__init__.py")
5+
LOCAL_APIPKG = pathlib.Path(__file__).parent.joinpath("src/apipkg/__init__.py")
66
INSTALL_TYPE = "editable" if apipkg.__file__ == LOCAL_APIPKG else "full"
77

88

src/apipkg/__init__.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@
77
"""
88
from __future__ import annotations
99

10-
__all__ = ["initpkg", "ApiModule", "AliasModule"]
10+
__all__ = ["initpkg", "ApiModule", "AliasModule", "__version__", "distribution_version"]
1111
import sys
1212
from typing import Any
1313

1414
from ._alias_module import AliasModule
15-
from ._importing import distribution_version as distribution_version # NOQA:F401
15+
from ._importing import distribution_version as distribution_version
1616
from ._module import _initpkg
1717
from ._module import ApiModule
18-
from ._version import version as __version__ # NOQA:F401
18+
from ._version import version as __version__
1919

2020

2121
def initpkg(

test_apipkg.py

+10-10
Original file line numberDiff line numberDiff line change
@@ -70,23 +70,23 @@ def setup_method(self, *args):
7070
sys.modules.pop(modname, None)
7171

7272
def test_realmodule(self):
73-
import realtest.x
73+
import realtest.x # type: ignore
7474

7575
assert "realtest.x.module" in sys.modules
7676
assert getattr(realtest.x.module, "mytest0")
7777

7878
def test_realmodule_repr(self):
79-
import realtest.x
79+
import realtest.x # type: ignore
8080

8181
assert "<ApiModule 'realtest.x'>" == repr(realtest.x)
8282

8383
def test_realmodule_from(self):
84-
from realtest.x import module
84+
from realtest.x import module # type: ignore
8585

8686
assert getattr(module, "mytest1")
8787

8888
def test_realmodule__all__(self):
89-
import realtest.x.module
89+
import realtest.x.module # type: ignore
9090

9191
assert realtest.x.__all__ == ["module"]
9292
assert len(realtest.x.module.__all__) == 4
@@ -770,8 +770,8 @@ def doit():
770770
)
771771

772772
monkeypatch.syspath_prepend(tmpdir)
773-
import aliasmodule_proxy as orig
774-
from my_aliasmodule_proxy import proxy
773+
import aliasmodule_proxy as orig # type: ignore
774+
from my_aliasmodule_proxy import proxy # type: ignore
775775

776776
doit = proxy.doit
777777
assert doit is orig.doit
@@ -811,20 +811,20 @@ def test_aliasmodule_nested_import_with_from(tmpdir, monkeypatch):
811811
)
812812
)
813813
monkeypatch.syspath_prepend(tmpdir)
814-
from api1 import os2
815-
from api1.os2.path import abspath
814+
from api1 import os2 # type: ignore
815+
from api1.os2.path import abspath # type: ignore
816816

817817
assert abspath == os.path.abspath
818818
# check that api1.os2 mirrors os.*
819819
assert os2.x == 3
820-
import api1
820+
import api1 # type: ignore
821821

822822
assert "os2.path" not in api1.__dict__
823823

824824

825825
def test_initpkg_without_old_module():
826826
apipkg.initpkg("initpkg_without_old_module", dict(modules="sys:modules"))
827-
from initpkg_without_old_module import modules
827+
from initpkg_without_old_module import modules # type: ignore
828828

829829
assert modules is sys.modules
830830

0 commit comments

Comments
 (0)