Skip to content

Commit 7c56ee3

Browse files
authored
Update mypy (and other linters) (#91)
1 parent ffa1a83 commit 7c56ee3

File tree

6 files changed

+23
-8
lines changed

6 files changed

+23
-8
lines changed

.github/workflows/tests.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ jobs:
5252
- name: Test
5353
if: steps.release.outputs.version == 0
5454
run: |
55-
pip install --verbose -e .[test]
55+
python -m pip install -U pip setuptools
56+
python -m pip install --verbose -e .[test]
5657
flake8 immutables/ tests/
5758
mypy immutables/
5859
python -m pytest -v

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ testpaths = "tests"
99
filterwarnings = "default"
1010

1111
[tool.mypy]
12+
files = "immutables"
1213
incremental = true
1314
strict = true
1415

setup.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
# pycodestyle is a dependency of flake8, but it must be frozen because
99
# their combination breaks too often
1010
# (example breakage: https://gitlab.com/pycqa/flake8/issues/427)
11-
'flake8~=3.8.4',
12-
'pycodestyle~=2.6.0',
13-
'mypy==0.942',
11+
'flake8~=5.0.4',
12+
'pycodestyle~=2.9.1',
13+
'mypy==0.971',
1414
'pytest~=6.2.4',
1515
]
1616

tests/test-data/check-immu.test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,4 +70,4 @@ def mutate() -> None:
7070
mm.set('3', '4')
7171
m2 = mm.finish()
7272

73-
reveal_type(m2) # N: Revealed type is "immutables._map.Map[builtins.str*, builtins.str*]"
73+
reveal_type(m2) # N: Revealed type is "immutables._map.Map[builtins.str, builtins.str]"

tests/test_mypy.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import os
2+
import sys
23

34
try:
45
import mypy.test.testcmdline
@@ -20,7 +21,19 @@ def renormalize_error_messages(messages):
2021

2122
this_file_dir = os.path.dirname(os.path.realpath(__file__))
2223
test_data_prefix = os.path.join(this_file_dir, 'test-data')
24+
parent_dir = os.path.dirname(this_file_dir)
25+
26+
mypy_path = os.environ.get("MYPYPATH")
27+
if mypy_path:
28+
mypy_path = parent_dir + os.pathsep + mypy_path
29+
else:
30+
mypy_path = parent_dir
2331

2432
class ImmuMypyTest(mypy.test.testcmdline.PythonCmdlineSuite):
2533
data_prefix = test_data_prefix
2634
files = ['check-immu.test']
35+
36+
def run_case(self, testcase):
37+
if sys.version_info >= (3, 7):
38+
os.environ["MYPYPATH"] = mypy_path
39+
super().run_case(testcase)

tests/test_none_keys.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,16 @@
66

77

88
none_hash = map_hash(None)
9-
assert(none_hash != 1)
10-
assert(none_hash.bit_length() <= 32)
9+
assert none_hash != 1
10+
assert none_hash.bit_length() <= 32
1111

1212
none_hash_u = ctypes.c_size_t(none_hash).value
1313
not_collision = 0xffffffff & (~none_hash_u)
1414

1515
mask = 0x7ffffffff
1616
none_collisions = [none_hash_u & (mask >> shift)
1717
for shift in reversed(range(0, 32, 5))]
18-
assert(len(none_collisions) == 7)
18+
assert len(none_collisions) == 7
1919
none_collisions = [
2020
ctypes.c_ssize_t(h | (not_collision & (mask << shift))).value
2121
for shift, h in zip(range(5, 37, 5), none_collisions)

0 commit comments

Comments
 (0)