-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
[PEP 695] Add more error checks and tests for error conditions #17339
Conversation
At least two are required, according do PEP 695. Work on #15238.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
@@ -330,3 +330,6 @@ def with_additional_msg(self, info: str) -> ErrorMessage: | |||
NARROWED_TYPE_NOT_SUBTYPE: Final = ErrorMessage( | |||
"Narrowed type {} is not a subtype of input type {}", codes.NARROWED_TYPE_NOT_SUBTYPE | |||
) | |||
TYPE_VAR_TOO_FEW_CONSTRAINED_TYPES: Final = ErrorMessage( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this message be reused in semanal.py
where a TypeVar cannot have only a single constraint
message is used inline? This should help with discoverability of two TypeVar
syntax variants constraints, because they share some common argument validation logic.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, if there are not too many tests to update, we should reuse the same message for both old and new style variables.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I made the error messages consistent.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LG, only minor things.
@@ -271,7 +271,7 @@ def __hash__(self) -> int: | |||
del error_codes[FILE.code] | |||
|
|||
# This is a catch-all for remaining uncategorized errors. | |||
MISC: Final = ErrorCode("misc", "Miscellaneous other checks", "General") | |||
MISC: Final[ErrorCode] = ErrorCode("misc", "Miscellaneous other checks", "General") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this because we are not deferring top-levels, LOL?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Possibly, though I didn't look into this in any detail. This is not the first instance of this issue in this module.
@@ -330,3 +330,6 @@ def with_additional_msg(self, info: str) -> ErrorMessage: | |||
NARROWED_TYPE_NOT_SUBTYPE: Final = ErrorMessage( | |||
"Narrowed type {} is not a subtype of input type {}", codes.NARROWED_TYPE_NOT_SUBTYPE | |||
) | |||
TYPE_VAR_TOO_FEW_CONSTRAINED_TYPES: Final = ErrorMessage( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, if there are not too many tests to update, we should reuse the same message for both old and new style variables.
According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅ |
Detect invalid number of constrained types. At least two are required, according do PEP 695.
Add tests for other simple errors.
Work on #15238.