-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Split import-untyped into import-untyped and import-untyped-stubs-available #19101
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 10 commits
1fc7d81
c5ce82c
cd279e9
9d6282a
d26ac50
562198b
f98aa58
bb65ad8
65a3254
c2c5a06
009e391
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -34,6 +34,9 @@ def __init__( | |
| sub_code_map[sub_code_of.code].add(code) | ||
| error_codes[code] = self | ||
|
|
||
| def is_import_related_code(self) -> bool: | ||
| return IMPORT in (self.code, self.sub_code_of) | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (Informtional:) This could easily be generalized to |
||
|
|
||
| def __str__(self) -> str: | ||
| return f"<ErrorCode {self.code}>" | ||
|
|
||
|
|
@@ -113,6 +116,12 @@ def __hash__(self) -> int: | |
| IMPORT_UNTYPED: Final = ErrorCode( | ||
| "import-untyped", "Require that imported module has stubs", "General", sub_code_of=IMPORT | ||
| ) | ||
| IMPORT_UNTYPED_STUBS_AVAILABLE: Final = ErrorCode( | ||
| "import-untyped-stubs-available", | ||
| "Require that imported module (with known stubs) has stubs", | ||
| "General", | ||
| sub_code_of=IMPORT, | ||
| ) | ||
| NO_REDEF: Final = ErrorCode("no-redef", "Check that each name is defined once", "General") | ||
| FUNC_RETURNS_VALUE: Final = ErrorCode( | ||
| "func-returns-value", "Check that called function returns a value in value context", "General" | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,7 +11,7 @@ | |
|
|
||
| from mypy import errorcodes as codes | ||
| from mypy.error_formatter import ErrorFormatter | ||
| from mypy.errorcodes import IMPORT, IMPORT_NOT_FOUND, IMPORT_UNTYPED, ErrorCode, mypy_error_codes | ||
| from mypy.errorcodes import ErrorCode, mypy_error_codes | ||
| from mypy.nodes import Context | ||
| from mypy.options import Options | ||
| from mypy.scope import Scope | ||
|
|
@@ -583,7 +583,7 @@ def _add_error_info(self, file: str, info: ErrorInfo) -> None: | |
| self.error_info_map[file].append(info) | ||
| if info.blocker: | ||
| self.has_blockers.add(file) | ||
| if info.code in (IMPORT, IMPORT_UNTYPED, IMPORT_NOT_FOUND): | ||
| if info.code is not None and info.code.is_import_related_code(): | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (Informational:) this code pattern also suggests refactoring into a static function (so it can just handle None as well instead of needing this check), but I didn't because YAGNI; this was fine. |
||
| self.seen_import_error = True | ||
|
|
||
| def get_watchers(self) -> Iterator[ErrorWatcher]: | ||
|
|
@@ -630,7 +630,7 @@ def add_error_info(self, info: ErrorInfo) -> None: | |
| self.only_once_messages.add(info.message) | ||
| if ( | ||
| self.seen_import_error | ||
| and info.code not in (IMPORT, IMPORT_UNTYPED, IMPORT_NOT_FOUND) | ||
| and (info.code is None or (not info.code.is_import_related_code())) | ||
| and self.has_many_errors() | ||
| ): | ||
| # Missing stubs can easily cause thousands of errors about | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.