-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Stubtest: check _value_ for ellipsis-valued stub enum members
#19760
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
Changes from 1 commit
3471156
ce659ac
d30f5f6
0e58ca1
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 |
|---|---|---|
|
|
@@ -1255,6 +1255,7 @@ def verify_var( | |
| yield Error(object_path, "is read-only at runtime but not in the stub", stub, runtime) | ||
|
|
||
| runtime_type = get_mypy_type_of_runtime_value(runtime, type_context=stub.type) | ||
| note = "" | ||
| if ( | ||
| runtime_type is not None | ||
| and stub.type is not None | ||
|
|
@@ -1273,11 +1274,20 @@ def verify_var( | |
| isinstance(proper_type, mypy.types.Instance) | ||
| and proper_type.type.fullname in mypy.types.ELLIPSIS_TYPE_NAMES | ||
| ): | ||
| should_error = False | ||
| value_t = stub.info.get("_value_") | ||
| if value_t is None or value_t.type is None: | ||
| should_error = False | ||
| elif runtime_type is not None and is_subtype_helper(runtime_type, value_t.type): | ||
| should_error = False | ||
| elif runtime_type is not None: | ||
| note = " (incompatible '_value_')" | ||
|
Collaborator
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. Is this intentionally making the
Collaborator
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. I also tried thinking about that, couldn't invent a case where we have found an attribute but failed to interpret its
Collaborator
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. Okay, almost all other checks do not reject "wtf" values as incompatible, updated for consistency. |
||
|
|
||
| if should_error: | ||
| yield Error( | ||
| object_path, f"variable differs from runtime type {runtime_type}", stub, runtime | ||
| object_path, | ||
| f"variable differs from runtime type {runtime_type}{note}", | ||
| stub, | ||
| runtime, | ||
| ) | ||
|
|
||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.