Skip to content
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

Add error code to missed invalid Literal case #13763

Merged
merged 2 commits into from
Sep 29, 2022

Conversation

hauntsaninja
Copy link
Collaborator

No description provided.

@github-actions

This comment has been minimized.

@@ -1284,7 +1284,7 @@ def analyze_literal_param(self, idx: int, arg: Type, ctx: Context) -> list[Type]
out.extend(union_result)
return out
else:
self.fail(f"Parameter {idx} of Literal[...] is invalid", ctx)
self.fail(f"Parameter {idx} of Literal[...] is invalid", ctx, code=codes.VALID_TYPE)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't comment there, but should the error on line 1253 above also have this code?

@github-actions
Copy link
Contributor

Diff from mypy_primer, showing the effect of this PR on open source code:

discord.py (https://github.com/Rapptz/discord.py)
- discord/ext/commands/parameters.py:63: error: Parameter 1 of Literal[...] is invalid  [misc]
+ discord/ext/commands/parameters.py:63: error: Parameter 1 of Literal[...] is invalid  [valid-type]
- discord/ext/commands/parameters.py:64: error: Parameter 1 of Literal[...] is invalid  [misc]
+ discord/ext/commands/parameters.py:64: error: Parameter 1 of Literal[...] is invalid  [valid-type]
- discord/ext/commands/parameters.py:65: error: Parameter 1 of Literal[...] is invalid  [misc]
+ discord/ext/commands/parameters.py:65: error: Parameter 1 of Literal[...] is invalid  [valid-type]
- discord/ext/commands/parameters.py:66: error: Parameter 1 of Literal[...] is invalid  [misc]
+ discord/ext/commands/parameters.py:66: error: Parameter 1 of Literal[...] is invalid  [valid-type]
- discord/ext/commands/parameters.py:67: error: Parameter 1 of Literal[...] is invalid  [misc]
+ discord/ext/commands/parameters.py:67: error: Parameter 1 of Literal[...] is invalid  [valid-type]

steam.py (https://github.com/Gobot1234/steam.py)
- steam/id.py:128: error: Parameter 1 of Literal[...] is invalid  [misc]
+ steam/id.py:128: error: Parameter 1 of Literal[...] is invalid  [valid-type]
- steam/id.py:227: error: Parameter 1 of Literal[...] is invalid  [misc]
+ steam/id.py:227: error: Parameter 1 of Literal[...] is invalid  [valid-type]
- steam/event.py:183: error: Parameter 1 of Literal[...] is invalid  [misc]
+ steam/event.py:183: error: Parameter 1 of Literal[...] is invalid  [valid-type]
- steam/event.py:200: error: Parameter 1 of Literal[...] is invalid  [misc]
+ steam/event.py:200: error: Parameter 1 of Literal[...] is invalid  [valid-type]
- steam/event.py:221: error: Parameter 1 of Literal[...] is invalid  [misc]
+ steam/event.py:221: error: Parameter 1 of Literal[...] is invalid  [valid-type]
- steam/event.py:234: error: Parameter 1 of Literal[...] is invalid  [misc]
+ steam/event.py:234: error: Parameter 1 of Literal[...] is invalid  [valid-type]
- steam/clan.py:39: error: Parameter 1 of Literal[...] is invalid  [misc]
+ steam/clan.py:39: error: Parameter 1 of Literal[...] is invalid  [valid-type]
- steam/clan.py:40: error: Parameter 1 of Literal[...] is invalid  [misc]
+ steam/clan.py:40: error: Parameter 1 of Literal[...] is invalid  [valid-type]
- steam/clan.py:41: error: Parameter 1 of Literal[...] is invalid  [misc]
+ steam/clan.py:41: error: Parameter 1 of Literal[...] is invalid  [valid-type]
- steam/clan.py:42: error: Parameter 1 of Literal[...] is invalid  [misc]
+ steam/clan.py:42: error: Parameter 1 of Literal[...] is invalid  [valid-type]
- steam/clan.py:43: error: Parameter 1 of Literal[...] is invalid  [misc]
+ steam/clan.py:43: error: Parameter 1 of Literal[...] is invalid  [valid-type]
- steam/clan.py:44: error: Parameter 1 of Literal[...] is invalid  [misc]
+ steam/clan.py:44: error: Parameter 1 of Literal[...] is invalid  [valid-type]
- steam/clan.py:45: error: Parameter 1 of Literal[...] is invalid  [misc]
+ steam/clan.py:45: error: Parameter 1 of Literal[...] is invalid  [valid-type]
- steam/clan.py:46: error: Parameter 1 of Literal[...] is invalid  [misc]
+ steam/clan.py:46: error: Parameter 1 of Literal[...] is invalid  [valid-type]
- steam/clan.py:560: error: Parameter 1 of Literal[...] is invalid  [misc]
+ steam/clan.py:560: error: Parameter 1 of Literal[...] is invalid  [valid-type]
- steam/clan.py:565: error: Parameter 1 of Literal[...] is invalid  [misc]
+ steam/clan.py:565: error: Parameter 1 of Literal[...] is invalid  [valid-type]
- steam/clan.py:584: error: Parameter 1 of Literal[...] is invalid  [misc]
+ steam/clan.py:584: error: Parameter 1 of Literal[...] is invalid  [valid-type]

core (https://github.com/home-assistant/core)
- homeassistant/components/zwave_js/api.py:120: error: Parameter 1 of Literal[...] cannot be of type "Any"  [misc]
+ homeassistant/components/zwave_js/api.py:120: error: Parameter 1 of Literal[...] cannot be of type "Any"  [valid-type]

@hauntsaninja hauntsaninja merged commit d560570 into python:master Sep 29, 2022
@hauntsaninja hauntsaninja deleted the literal-error-code branch September 29, 2022 04:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants