Skip to content

Commit 02484bc

Browse files
committed
chore: add mypy to the build
1 parent 1c0c453 commit 02484bc

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+166
-3
lines changed

.github/workflows/testing.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ jobs:
4141
- name: Code check
4242
run: tox -e ${TOX_VENV}
4343
env:
44-
TOX_VENV: black,pep8
44+
TOX_VENV: black,pep8,mypy
4545

4646
test:
4747
needs: [validate]

kazoo/client.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# mypy: ignore-errors
2+
13
"""Kazoo Zookeeper Client"""
24
from collections import defaultdict, deque
35
from functools import partial

kazoo/exceptions.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# mypy: ignore-errors
2+
13
"""Kazoo Exceptions"""
24
from collections import defaultdict
35

kazoo/handlers/eventlet.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# mypy: ignore-errors
2+
13
"""A eventlet based handler."""
24
from __future__ import absolute_import
35

kazoo/handlers/gevent.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# mypy: ignore-errors
2+
13
"""A gevent based handler."""
24
from __future__ import absolute_import
35

kazoo/handlers/threading.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# mypy: ignore-errors
2+
13
"""A threading based handler.
24
35
The :class:`SequentialThreadingHandler` is intended for regular Python

kazoo/handlers/utils.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# mypy: ignore-errors
2+
13
"""Kazoo handler helpers"""
24

35
from collections import defaultdict

kazoo/hosts.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# mypy: ignore-errors
2+
13
import urllib.parse
24

35

kazoo/interfaces.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# mypy: ignore-errors
2+
13
"""Kazoo Interfaces
24
35
.. versionchanged:: 1.4

kazoo/protocol/connection.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# mypy: ignore-errors
2+
13
"""Zookeeper Protocol Connection Handler"""
24
from binascii import hexlify
35
from contextlib import contextmanager

kazoo/protocol/paths.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# mypy: ignore-errors
2+
13
def normpath(path, trailing=False):
24
"""Normalize path, eliminating double slashes, etc."""
35
comps = path.split("/")

kazoo/protocol/serialization.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# mypy: ignore-errors
2+
13
"""Zookeeper Serializers, Deserializers, and NamedTuple objects"""
24
from collections import namedtuple
35
import struct

kazoo/protocol/states.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# mypy: ignore-errors
2+
13
"""Kazoo State and Event objects"""
24
from collections import namedtuple
35

kazoo/recipe/barrier.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# mypy: ignore-errors
2+
13
"""Zookeeper Barriers
24
35
:Maintainer: None

kazoo/recipe/cache.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# mypy: ignore-errors
2+
13
"""TreeCache
24
35
:Maintainer: Jiangge Zhang <[email protected]>

kazoo/recipe/counter.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# mypy: ignore-errors
2+
13
"""Zookeeper Counter
24
35
:Maintainer: None

kazoo/recipe/election.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# mypy: ignore-errors
2+
13
"""ZooKeeper Leader Elections
24
35
:Maintainer: None

kazoo/recipe/lease.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# mypy: ignore-errors
2+
13
"""Zookeeper lease implementations
24
35
:Maintainer: Lars Albertsson <[email protected]>

kazoo/recipe/lock.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# mypy: ignore-errors
2+
13
"""Zookeeper Locking Implementations
24
35
:Maintainer: Ben Bangert <[email protected]>

kazoo/recipe/partitioner.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# mypy: ignore-errors
2+
13
"""Zookeeper Partitioner Implementation
24
35
:Maintainer: None

kazoo/recipe/party.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# mypy: ignore-errors
2+
13
"""Party
24
35
:Maintainer: Ben Bangert <[email protected]>

kazoo/recipe/queue.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# mypy: ignore-errors
2+
13
"""Zookeeper based queue implementations.
24
35
:Maintainer: None

kazoo/recipe/watchers.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# mypy: ignore-errors
2+
13
"""Higher level child and data watching API's.
24
35
:Maintainer: Ben Bangert <[email protected]>

kazoo/retry.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# mypy: ignore-errors
2+
13
import logging
24
import random
35
import time

kazoo/security.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# mypy: ignore-errors
2+
13
"""Kazoo Security"""
24
from base64 import b64encode
35
from collections import namedtuple

kazoo/testing/common.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# mypy: ignore-errors
2+
13
#
24
# Copyright (C) 2010-2011, 2011 Canonical Ltd. All Rights Reserved
35
#

kazoo/testing/harness.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# mypy: ignore-errors
2+
13
"""Kazoo testing harnesses"""
24
import atexit
35
import logging

kazoo/tests/conftest.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# mypy: ignore-errors
2+
13
import logging
24

35
log = logging.getLogger(__name__)

kazoo/tests/test__connection.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# mypy: ignore-errors
2+
13
from collections import namedtuple, deque
24
import os
35
import threading

kazoo/tests/test_barrier.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# mypy: ignore-errors
2+
13
import threading
24

35
from kazoo.testing import KazooTestCase

kazoo/tests/test_build.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# mypy: ignore-errors
2+
13
import os
24

35
import pytest

kazoo/tests/test_cache.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# mypy: ignore-errors
2+
13
import gc
24
import importlib
35
import uuid

kazoo/tests/test_client.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# mypy: ignore-errors
2+
13
import socket
24
import sys
35
import threading

kazoo/tests/test_counter.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# mypy: ignore-errors
2+
13
import uuid
24

35
import pytest

kazoo/tests/test_election.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# mypy: ignore-errors
2+
13
import uuid
24
import sys
35
import threading

kazoo/tests/test_eventlet_handler.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# mypy: ignore-errors
2+
13
import contextlib
24
import unittest
35

kazoo/tests/test_exceptions.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# mypy: ignore-errors
2+
13
from unittest import TestCase
24

35
import pytest

kazoo/tests/test_gevent_handler.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# mypy: ignore-errors
2+
13
import unittest
24

35
import pytest

kazoo/tests/test_hosts.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# mypy: ignore-errors
2+
13
from unittest import TestCase
24

35
from kazoo.hosts import collect_hosts

kazoo/tests/test_interrupt.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# mypy: ignore-errors
2+
13
import os
24
from sys import platform
35

kazoo/tests/test_lease.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# mypy: ignore-errors
2+
13
import datetime
24
import uuid
35

kazoo/tests/test_lock.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# mypy: ignore-errors
2+
13
import collections
24
import mock
35
import threading

kazoo/tests/test_partitioner.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# mypy: ignore-errors
2+
13
import uuid
24
import threading
35
import time

kazoo/tests/test_party.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# mypy: ignore-errors
2+
13
import uuid
24

35
from kazoo.testing import KazooTestCase

kazoo/tests/test_paths.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# mypy: ignore-errors
2+
13
import sys
24
from unittest import TestCase
35

kazoo/tests/test_queue.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# mypy: ignore-errors
2+
13
import uuid
24

35
import pytest

kazoo/tests/test_retry.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# mypy: ignore-errors
2+
13
import unittest
24

35
import pytest

kazoo/tests/test_sasl.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# mypy: ignore-errors
2+
13
import os
24
import subprocess
35
import time

kazoo/tests/test_security.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# mypy: ignore-errors
2+
13
import unittest
24

35
from kazoo.security import Permissions

kazoo/tests/test_selectors_select.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# mypy: ignore-errors
2+
13
"""
24
The official python select function test case copied from python source
35
to test the selector_select function.

kazoo/tests/test_threading_handler.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# mypy: ignore-errors
2+
13
import threading
24
import unittest
35

kazoo/tests/test_utils.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# mypy: ignore-errors
2+
13
import unittest
24

35
from mock import patch

kazoo/tests/test_watchers.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# mypy: ignore-errors
2+
13
import time
24
import threading
35
import uuid

kazoo/tests/util.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# mypy: ignore-errors
2+
13
##############################################################################
24
#
35
# Copyright Zope Foundation and Contributors.

mypy.ini

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
[mypy]
2+
3+
# TODO: For details on each flag, please see the mypy documentation at:
4+
# https://mypy.readthedocs.io/en/stable/config_file.html#config-file
5+
6+
# Import Discovery
7+
ignore_missing_imports = false
8+
9+
# Disallow dynamic typing
10+
disallow_any_generics = true
11+
disallow_subclassing_any = true
12+
13+
# Untyped definitions and calls
14+
disallow_untyped_calls = true
15+
disallow_untyped_defs = true
16+
disallow_incomplete_defs = true
17+
check_untyped_defs = true
18+
disallow_untyped_decorators = true
19+
20+
# None and Optional handling
21+
implicit_optional = false
22+
strict_optional = true
23+
24+
# Configuring warnings
25+
warn_redundant_casts = true
26+
warn_unused_ignores = true
27+
warn_no_return = true
28+
warn_return_any = true
29+
warn_unreachable = true
30+
31+
# Miscellaneous strictness flags
32+
implicit_reexport = false
33+
strict_equality = true
34+
35+
# Configuring error messages
36+
show_error_context = true
37+
show_column_numbers = true
38+
show_error_codes = true
39+
pretty = true
40+
color_output = true
41+
show_absolute_path = true
42+
43+
# Miscellaneous
44+
allow_untyped_globals = false
45+
warn_unused_configs = true
46+
verbosity = 0

setup.cfg

+4-1
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,14 @@ sasl =
7373
docs =
7474
Sphinx>=1.2.2
7575

76+
typing =
77+
mypy>=0.991
78+
7679
alldeps =
7780
%(dev)s
7881
%(eventlet)s
7982
%(gevent)s
8083
%(sasl)s
8184
%(docs)s
82-
85+
%(typing)s
8386

0 commit comments

Comments
 (0)