Skip to content

chore: add mypy to the build #689

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
- name: Code check
run: tox -e ${TOX_VENV}
env:
TOX_VENV: black,pep8
TOX_VENV: black,pep8,mypy

test:
needs: [validate]
Expand Down
122 changes: 122 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,125 @@ extend-exclude = '''

[tool.pytest.ini_options]
addopts = "-ra -v"

[tool.mypy]

# For details on each flag, please see the mypy documentation at:
# https://mypy.readthedocs.io/en/stable/config_file.html#config-file

# Note: The order of flags listed here should match the order used in mypy's
# documentation to make it easier to find the documentation for each flag.

# Import Discovery
ignore_missing_imports = false

# Disallow dynamic typing
disallow_any_unimported = true
disallow_any_expr = false
disallow_any_decorated = true
disallow_any_explicit = true
disallow_any_generics = true
disallow_subclassing_any = true

# Untyped definitions and calls
disallow_untyped_calls = true
disallow_untyped_defs = true
disallow_incomplete_defs = true
check_untyped_defs = true
disallow_untyped_decorators = true

# None and Optional handling
implicit_optional = false
strict_optional = true

# Configuring warnings
warn_redundant_casts = true
warn_unused_ignores = true
warn_no_return = true
warn_return_any = true
warn_unreachable = true

# Miscellaneous strictness flags
allow_untyped_globals = false
allow_redefinition = false
local_partial_types = true
implicit_reexport = false
strict_concatenate = true
strict_equality = true
strict = true

# Configuring error messages
show_error_context = true
show_column_numbers = true
hide_error_codes = false
pretty = true
color_output = true
error_summary = true
show_absolute_path = true

# Miscellaneous
warn_unused_configs = true
verbosity = 0

# FIXME: As type annotations are introduced, please remove the appropriate
# ignore_errors flag below. New modules should NOT be added here!

[[tool.mypy.overrides]]
module = [
'kazoo.client',
'kazoo.exceptions',
'kazoo.handlers.eventlet',
'kazoo.handlers.gevent',
'kazoo.handlers.threading',
'kazoo.handlers.utils',
'kazoo.hosts',
'kazoo.interfaces',
'kazoo.loggingsupport',
'kazoo.protocol.connection',
'kazoo.protocol.paths',
'kazoo.protocol.serialization',
'kazoo.protocol.states',
'kazoo.recipe.barrier',
'kazoo.recipe.cache',
'kazoo.recipe.counter',
'kazoo.recipe.election',
'kazoo.recipe.lease',
'kazoo.recipe.lock',
'kazoo.recipe.partitioner',
'kazoo.recipe.party',
'kazoo.recipe.queue',
'kazoo.recipe.watchers',
'kazoo.retry',
'kazoo.security',
'kazoo.testing.common',
'kazoo.testing.harness',
'kazoo.tests.conftest',
'kazoo.tests.test__connection',
'kazoo.tests.test_barrier',
'kazoo.tests.test_build',
'kazoo.tests.test_cache',
'kazoo.tests.test_client',
'kazoo.tests.test_counter',
'kazoo.tests.test_election',
'kazoo.tests.test_eventlet_handler',
'kazoo.tests.test_exceptions',
'kazoo.tests.test_gevent_handler',
'kazoo.tests.test_hosts',
'kazoo.tests.test_interrupt',
'kazoo.tests.test_lease',
'kazoo.tests.test_lock',
'kazoo.tests.test_partitioner',
'kazoo.tests.test_party',
'kazoo.tests.test_paths',
'kazoo.tests.test_queue',
'kazoo.tests.test_retry',
'kazoo.tests.test_sasl',
'kazoo.tests.test_security',
'kazoo.tests.test_selectors_select',
'kazoo.tests.test_threading_handler',
'kazoo.tests.test_utils',
'kazoo.tests.test_watchers',
'kazoo.tests.util',
'kazoo.version'
]
ignore_errors = true
5 changes: 4 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,14 @@ sasl =
docs =
Sphinx>=1.2.2

typing =
mypy>=0.991

alldeps =
%(dev)s
%(eventlet)s
%(gevent)s
%(sasl)s
%(docs)s

%(typing)s

10 changes: 9 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ requires=
virtualenv>=20.7.2
skip_missing_interpreters=True
envlist =
pep8,black,
pep8,black,mypy,
gevent,eventlet,sasl,
docs,
pypy3
Expand Down Expand Up @@ -59,3 +59,11 @@ deps =
usedevelop = True
commands = black --check {posargs: {toxinidir}/kazoo {toxinidir}/kazoo}

[testenv:mypy]
basepython = python3
extras = alldeps
deps =
mypy
mypy: types-mock
usedevelop = True
commands = mypy --config-file {toxinidir}/pyproject.toml {toxinidir}/kazoo