Skip to content
This repository has been archived by the owner on Feb 21, 2023. It is now read-only.

Enable mypy in CI #1101

Merged
merged 19 commits into from Oct 31, 2021
Merged
4 changes: 4 additions & 0 deletions .github/workflows/ci.yml
Expand Up @@ -39,6 +39,10 @@ jobs:
uses: py-actions/py-dependency-install@v2.1.0
with:
path: tests/requirements.txt
- name: Run mypy
run: |
pip install -r tests/requirements-mypy.txt
mypy
- name: Run linter
run: |
make lint
Expand Down
30 changes: 30 additions & 0 deletions .mypy.ini
@@ -0,0 +1,30 @@
[mypy]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Commented out things are to be enabled in future PRs.

#, docs/examples, tests
files = aioredis
check_untyped_defs = True
follow_imports_for_stubs = True
#disallow_any_decorated = True
#disallow_any_generics = True
#disallow_incomplete_defs = True
disallow_subclassing_any = True
#disallow_untyped_calls = True
disallow_untyped_decorators = True
#disallow_untyped_defs = True
implicit_reexport = False
no_implicit_optional = True
show_error_codes = True
strict_equality = True
warn_incomplete_stub = True
warn_redundant_casts = True
warn_unreachable = True
warn_unused_ignores = True
disallow_any_unimported = True
#warn_return_any = True

[mypy-aioredis.client]
# TODO: Fix
ignore_errors = True

[mypy-aioredis.lock]
# TODO: Remove once locks has been rewritten
ignore_errors = True
1 change: 1 addition & 0 deletions CHANGES/1101.misc
@@ -0,0 +1 @@
Enable Mypy in CI.
4 changes: 2 additions & 2 deletions Makefile
Expand Up @@ -17,7 +17,7 @@ spelling:
$(MAKE) -C docs spelling

mypy:
$(MYPY) aioredis --ignore-missing-imports
$(MYPY)

test:
$(PYTEST)
Expand All @@ -38,7 +38,7 @@ init-hooks:
pre-commit install-hooks

lint: init-hooks
pre-commit run --all-files
pre-commit run --all-files --show-diff-on-failure

devel: aioredis.egg-info init-hooks
pip install -U pip
Expand Down
13 changes: 8 additions & 5 deletions aioredis/compat.py
@@ -1,5 +1,8 @@
# flake8: noqa
try:
from typing import Protocol, TypedDict # lgtm [py/unused-import]
except ImportError:
from typing_extensions import Protocol, TypedDict # lgtm [py/unused-import]
import sys

if sys.version_info >= (3, 8):
from typing import Protocol, TypedDict
else:
from typing_extensions import Protocol, TypedDict

__all__ = ("Protocol", "TypedDict")