Skip to content

Commit

Permalink
add make mypy to Makefile
Browse files Browse the repository at this point in the history
  • Loading branch information
ilanschnell committed Jun 12, 2021
1 parent 8b34c83 commit 8474158
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 13 deletions.
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ doc: bitarray/_bitarray.so
twine check dist/*


mypy:
mypy examples/*.py examples/huffman/*.py


clean:
rm -rf build dist
rm -f bitarray/*.o bitarray/*.so
Expand Down
6 changes: 3 additions & 3 deletions bitarray/__init__.pyi
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
"""
This stub, as well as util.pyi, have been tested with
Python 3.9 and mypy 0.901
Python 3.9 and mypy 0.902
"""
from collections.abc import Iterable, Iterator
from unittest.runner import TextTestResult

from typing import BinaryIO, Hashable, Union, overload
from typing import Any, BinaryIO, Union, overload


Codedict = dict[Hashable, bitarray]
Codedict = dict[Any, bitarray]


class decodetree:
Expand Down
6 changes: 3 additions & 3 deletions bitarray/test_bitarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
if is_py3k:
from io import BytesIO
else:
from cStringIO import StringIO as BytesIO
range = xrange
from cStringIO import StringIO as BytesIO # type: ignore
range = xrange # type: ignore


from bitarray import (bitarray, frozenbitarray, bits2bytes, decodetree,
Expand All @@ -40,7 +40,7 @@ def zeros(n, endian=None):
a.setall(0)
return a

tests = []
tests = [] # type: list

class Util(object):

Expand Down
2 changes: 1 addition & 1 deletion bitarray/test_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
else:
from io import BytesIO as StringIO

tests = []
tests = [] # type: list

# ---------------------------------------------------------------------------

Expand Down
6 changes: 3 additions & 3 deletions bitarray/util.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Any, AnyStr, BinaryIO, Hashable, Optional, Union
from typing import Any, AnyStr, BinaryIO, Optional, Union

from bitarray import bitarray

Expand Down Expand Up @@ -38,6 +38,6 @@ def int2ba(i: int, /,

def serialize(a: bitarray, /) -> bytes: ...
def deserialize(b: bytes, /) -> bitarray: ...
def huffman_code(freq_map: dict[Hashable, Union[int, float]],
def huffman_code(freq_map: dict[Any, Union[int, float]],
endian: Optional[str] = ...
) -> dict[Hashable, bitarray]: ...
) -> dict[Any, bitarray]: ...
4 changes: 2 additions & 2 deletions examples/hexadecimal.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
'c': bitarray('1100'), 'd': bitarray('1101'),
'e': bitarray('1110'), 'f': bitarray('1111'),
}}
for k, v in CODEDICT['big'].items():
CODEDICT['little'][k] = v[::-1]
for k, v in CODEDICT['big'].items(): # type: ignore
CODEDICT['little'][k] = v[::-1] # type: ignore

def prefix_ba2hex(a):
return ''.join(a.iterdecode(CODEDICT[a.endian()]))
Expand Down
2 changes: 1 addition & 1 deletion examples/mandel.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import sys
from bitarray import bitarray
from numba import jit
from numba import jit # type: ignore

width, height = 4000, 3000
maxdepth = 500
Expand Down

0 comments on commit 8474158

Please sign in to comment.