-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Remove/improve some more casts to Any
#14828
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
Conversation
This comment has been minimized.
This comment has been minimized.
mypyc/codegen/literals.py
Outdated
@@ -55,13 +55,13 @@ def record_literal(self, value: LiteralValue) -> None: | |||
tuple_literals = self.tuple_literals | |||
if value not in tuple_literals: | |||
for item in value: | |||
self.record_literal(cast(Any, item)) | |||
self.record_literal(cast(LiteralValue, item)) |
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.
Not familiar with this code, but I wonder whether this can be an assert
instead.
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.
Hmm, I'll try it.
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.
LiteralValue
is a union, so I had to use a TypeGuard
in order to convert this code to using assert
:
mypy/mypyc/codegen/literals.py
Lines 6 to 10 in 0f467c6
# Supported Python literal types. All tuple / frozenset items must have supported | |
# literal types as well, but we can't represent the type precisely. | |
LiteralValue = Union[ | |
str, bytes, int, bool, float, complex, Tuple[object, ...], FrozenSet[object], None | |
] |
According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉 |
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.
mypyc literals.py changes look good 👍
No description provided.