Skip to content

Commit a77a151

Browse files
committed
mypy: Fix all no-untyped-call
1 parent b2d1c85 commit a77a151

File tree

8 files changed

+63
-45
lines changed

8 files changed

+63
-45
lines changed

pyproject.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,6 @@ disallow_incomplete_defs = false
118118
disallow_untyped_defs = false
119119
# Allow dynamic typing in our own code
120120
warn_return_any = false # TODO
121-
disallow_untyped_calls = false # TODO
122121
check_untyped_defs = true
123122
# Suppressing errors
124123
disable_error_code = [

stubs/matplotlib/colors.pyi

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -128,24 +128,42 @@ class CenteredNorm(Normalize):
128128
def __call__(self, value, clip: bool = ...): ...
129129

130130
def make_norm_from_scale(scale_cls, base_norm_cls=..., *, init=...): ...
131-
@make_norm_from_scale(FuncScale, init=lambda functions, vmin=None, vmax=None, clip=False: None)
132-
class FuncNorm(Normalize): ...
133131

134-
@make_norm_from_scale(functools.partial(LogScale, nonpositive="mask"))
132+
class FuncNorm(Normalize):
133+
def __init__(
134+
self,
135+
functions: tuple[Callable, Callable],
136+
vmin: float | None = ...,
137+
vmax: float | None = ...,
138+
clip: bool = ...,
139+
) -> None: ...
140+
135141
class LogNorm(Normalize): ...
136142

137-
@make_norm_from_scale(
138-
SymmetricalLogScale,
139-
init=lambda linthresh, linscale=1, vmin=None, vmax=None, clip=False, *, base=10: None,
140-
)
141143
class SymLogNorm(Normalize):
144+
def __init__(
145+
self,
146+
linthresh: float,
147+
linscale: float = ...,
148+
vmin: float | None = ...,
149+
vmax: float | None = ...,
150+
clip: bool = ...,
151+
*,
152+
base: float = ...,
153+
) -> None: ...
142154
@property
143155
def linthresh(self): ...
144156
@linthresh.setter
145157
def linthresh(self, value): ...
146158

147-
@make_norm_from_scale(AsinhScale, init=lambda linear_width=1, vmin=None, vmax=None, clip=False: None)
148159
class AsinhNorm(Normalize):
160+
def __init__(
161+
self,
162+
linear_width: float = ...,
163+
vmin: float | None = ...,
164+
vmax: float | None = ...,
165+
clip: bool = ...,
166+
) -> None: ...
149167
@property
150168
def linear_width(self): ...
151169
@linear_width.setter

stubs/matplotlib/transforms.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ class Transform(TransformNode):
199199
output_dims = ...
200200
is_separable = ...
201201
has_inverse = ...
202-
def __init_subclass__(cls): ...
202+
def __init_subclass__(cls) -> None: ...
203203
def __add__(self, other: Transform) -> Transform: ...
204204
@property
205205
def depth(self) -> int: ...

stubs/sympy-stubs/assumptions/assume.pyi

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from collections.abc import Generator
22
from contextlib import contextmanager
33
from typing import Any, Callable
4-
from typing_extensions import Self
4+
from typing_extensions import Never, Self
55

66
from sympy.core.basic import Basic
77
from sympy.logic.boolalg import Boolean
@@ -35,9 +35,9 @@ class Predicate(Boolean, metaclass=PredicateMeta):
3535
@property
3636
def name(self) -> str: ...
3737
@classmethod
38-
def register(cls, *types, **kwargs): ...
38+
def register(cls, *types: type, **kwargs: object) -> Callable[..., None]: ...
3939
@classmethod
40-
def register_many(cls, *types, **kwargs) -> Callable[..., None]: ...
40+
def register_many(cls, *types: type, **kwargs: object) -> Callable[..., None]: ...
4141
def __call__(self, *args) -> AppliedPredicate: ...
4242
def eval(self, args, assumptions=...) -> None: ...
4343

tests/run_hygiene.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,22 @@
44
from pathlib import Path
55

66

7-
def install_requirements():
7+
def install_requirements() -> subprocess.CompletedProcess[bytes]:
88
print("\nInstalling requirements...")
99
return subprocess.run((sys.executable, "-m", "pip", "install", "--upgrade", "ruff"))
1010

1111

12-
def run_ruff_fix():
12+
def run_ruff_fix() -> subprocess.CompletedProcess[bytes]:
1313
print("\nRunning Ruff check --fix...")
1414
return subprocess.run((sys.executable, "-m", "ruff", "check", "--fix"))
1515

1616

17-
def run_ruff_format():
17+
def run_ruff_format() -> subprocess.CompletedProcess[bytes]:
1818
print("\nRunning Ruff format...")
1919
return subprocess.run((sys.executable, "-m", "ruff", "format"))
2020

2121

22-
def main():
22+
def main() -> None:
2323
test_folder = Path(__file__).parent
2424
root = test_folder.parent
2525
os.chdir(root)

tests/run_tests.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,27 @@
44
from pathlib import Path
55

66

7-
def install_requirements(test_folder: Path):
7+
def install_requirements(test_folder: Path) -> subprocess.CompletedProcess[bytes]:
88
print("\nInstalling requirements...")
99
return subprocess.run(
1010
(sys.executable, "-m", "pip", "install", "--upgrade", "-r", os.path.join(test_folder, "requirements.txt"))
1111
)
1212

1313

14-
def run_pyright():
14+
def run_pyright() -> subprocess.CompletedProcess[bytes]:
1515
print("\nRunning Pyright...")
1616
# https://github.com/RobertCraigie/pyright-python#keeping-pyright-and-pylance-in-sync
1717
os.environ.pop("PYRIGHT_PYTHON_FORCE_VERSION", None)
1818
os.environ["PYRIGHT_PYTHON_PYLANCE_VERSION"] = "latest-prerelease"
1919
return subprocess.run((sys.executable, "-m", "pyright"))
2020

2121

22-
def run_mypy():
22+
def run_mypy() -> subprocess.CompletedProcess[bytes]:
2323
print("\nRunning mypy...")
2424
return subprocess.run((sys.executable, "-m", "mypy", "."))
2525

2626

27-
def main():
27+
def main() -> None:
2828
test_folder = Path(__file__).parent
2929
root = test_folder.parent
3030
os.chdir(root)

utils/count_ids.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#!/bin/python
2+
from __future__ import annotations
23

34
__doc__ = """Count IDs.
45
@@ -23,7 +24,7 @@
2324
import docopt
2425

2526

26-
def count(root, suffix, regex, uniq):
27+
def count(root: str | None, suffix: str | None, regex: str | re.Pattern[str] | None, uniq: bool) -> None:
2728
if root is None:
2829
root = "."
2930
filepat = "*" if suffix is None else "*." + suffix[suffix.find(".") + 1 :]

utils/validate_stubs.py

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,6 @@
22
# ruff: noqa: F841 # TODO: plenty of unused variables. Validate what was the intent.
33
from __future__ import annotations
44

5-
__doc__ = """Validate Stubs.
6-
7-
Usage:
8-
validate_stubs <package> [--path=<stubpath>] [--class=<c>] [--function=<f>]
9-
validate_stubs -h | --help
10-
validate_stubs --version
11-
12-
Options:
13-
-h --help Show this screen.
14-
--version Show version.
15-
--path=<stubpath> Where to find stubs (default to parent directory)
16-
--function=<f> Restrict to the named function (or method if used with --class).
17-
--class=<c> Restrict to the named class.
18-
"""
19-
205
import importlib
216
import importlib.machinery
227
import inspect
@@ -32,6 +17,21 @@
3217

3318
import docopt
3419

20+
__doc__ = """Validate Stubs.
21+
22+
Usage:
23+
validate_stubs <package> [--path=<stubpath>] [--class=<c>] [--function=<f>]
24+
validate_stubs -h | --help
25+
validate_stubs --version
26+
27+
Options:
28+
-h --help Show this screen.
29+
--version Show version.
30+
--path=<stubpath> Where to find stubs (default to parent directory)
31+
--function=<f> Restrict to the named function (or method if used with --class).
32+
--class=<c> Restrict to the named class.
33+
"""
34+
3535
overloads: dict[str, Callable] = {}
3636

3737

@@ -66,7 +66,7 @@ def import_dual(m: str, stub_path: str) -> tuple:
6666
6767
"""
6868

69-
def _clean(m):
69+
def _clean(m: str) -> None:
7070
to_del = [k for k in sys.modules.keys() if k == m or k.startswith(m + ".")]
7171
for k in to_del:
7272
del sys.modules[k]
@@ -99,7 +99,7 @@ class ItemType(Enum):
9999

100100
def __init__(
101101
self, file: str, module: str, name: str, object_: object, type_: ItemType, children: dict[str, Item] | None = None
102-
):
102+
) -> None:
103103
self.file = file
104104
self.module = module
105105
self.name = name
@@ -109,25 +109,25 @@ def __init__(
109109
self.done = False
110110
self.analog: Item | None = None
111111

112-
def ismodule(self):
112+
def ismodule(self) -> bool:
113113
return self.type_ == Item.ItemType.MODULE
114114

115-
def isclass(self):
115+
def isclass(self) -> bool:
116116
return self.type_ == Item.ItemType.CLASS
117117

118-
def isfunction(self):
118+
def isfunction(self) -> bool:
119119
return self.type_ == Item.ItemType.FUNCTION
120120

121121
@staticmethod
122-
def make_function(file: str, module: str, name: str, object_: object):
122+
def make_function(file: str, module: str, name: str, object_: object) -> Item:
123123
return Item(file, module, name, object_, Item.ItemType.FUNCTION)
124124

125125
@staticmethod
126-
def make_class(file: str, module: str, name: str, object_: object, children: dict[str, Item]):
126+
def make_class(file: str, module: str, name: str, object_: object, children: dict[str, Item]) -> Item:
127127
return Item(file, module, name, object_, Item.ItemType.CLASS, children)
128128

129129
@staticmethod
130-
def make_module(file: str, module: str, name: str, object_: object, children: dict[str, Item]):
130+
def make_module(file: str, module: str, name: str, object_: object, children: dict[str, Item]) -> Item:
131131
return Item(file, module, name, object_, Item.ItemType.MODULE, children)
132132

133133

0 commit comments

Comments
 (0)