Skip to content

Commit 3022eec

Browse files
committed
Add some more mypy checks
1 parent 07cd83f commit 3022eec

File tree

6 files changed

+17
-7
lines changed

6 files changed

+17
-7
lines changed

.prospector.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,15 @@ mypy:
1414
options:
1515
ignore-missing-imports: true
1616
follow-imports: skip
17+
check-untyped-defs: true
18+
disallow-any-generics: true
1719
disallow-untyped-defs: true
18-
#strict: true
20+
disallow-incomplete-defs: true
21+
disallow-untyped-decorators: true
22+
warn-unused-configs: true
23+
warn-unused-ignores: true
24+
warn-redundant-casts: true
25+
extra-checks: true
1926

2027
pylint:
2128
options:

prospector/config/__init__.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,11 @@ def replace_deprecated_tool_names(self) -> list[str]:
9898

9999
def get_output_report(self) -> list[tuple[str, list[str]]]:
100100
# Get the output formatter
101+
output_report: list[tuple[str, list[str]]]
101102
if self.config.output_format is not None:
102103
output_report = self.config.output_format
103104
else:
104-
output_report = [(self.profile.output_format, self.profile.output_target)]
105+
output_report = [(self.profile.output_format, self.profile.output_target)] # type: ignore[list-item]
105106

106107
for index, report in enumerate(output_report):
107108
if not all(report):
@@ -262,7 +263,7 @@ def _determine_tool_runners(self, config: setoptconf.config.Configuration, profi
262263

263264
def _determine_ignores(
264265
self, config: setoptconf.config.Configuration, profile: ProspectorProfile, libraries: list[str]
265-
) -> list[re.Pattern]:
266+
) -> list[re.Pattern[str]]:
266267
# Grab ignore patterns from the options
267268
ignores = []
268269
for pattern in config.ignore_patterns + profile.ignore_patterns:

prospector/finder.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class FileFinder:
1818
is basically to know which files to pass to which tools to be inspected.
1919
"""
2020

21-
def __init__(self, *provided_paths: Path, exclusion_filters: Optional[Iterable[Callable]] = None):
21+
def __init__(self, *provided_paths: Path, exclusion_filters: Optional[Iterable[Callable[[Path], bool]]] = None):
2222
"""
2323
:param provided_paths:
2424
A list of Path objects to search for files and modules - can be either directories or files

prospector/profiles/profile.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ def get_disabled_messages(self, tool_name: str) -> list[str]:
5858
return list(set(disable) - set(enable))
5959

6060
def is_tool_enabled(self, name: str) -> bool:
61-
enabled = getattr(self, name).get("run")
61+
enabled: Optional[bool] = getattr(self, name).get("run")
6262
if enabled is not None:
6363
return enabled
6464
# this is not explicitly enabled or disabled, so use the default

prospector/tools/mypy/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,9 @@ def format_message(message: str) -> Message:
4545
)
4646

4747

48-
def _run_in_subprocess(q: Queue, cmd: Callable[[list[str]], tuple[str, str]], paths: list[str]) -> None:
48+
def _run_in_subprocess(
49+
q: "Queue[tuple[str, str]]", cmd: Callable[[list[str]], tuple[str, str]], paths: list[str]
50+
) -> None:
4951
"""
5052
This function exists only to be called by multiprocessing.Process as using
5153
lambda is forbidden

prospector/tools/profile_validator/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def __init__(self) -> None:
6262
self.ignore_codes: list[str] = []
6363

6464
def configure(self, prospector_config: "ProspectorConfig", found_files: FileFinder) -> None:
65-
for profile in prospector_config.config.profiles: # type: ignore[attr-defined]
65+
for profile in prospector_config.config.profiles:
6666
self.to_check.add(profile)
6767

6868
self.ignore_codes = prospector_config.get_disabled_messages("profile-validator")

0 commit comments

Comments
 (0)