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

Fix string formatting for string enums #16555

Merged
merged 1 commit into from
Apr 8, 2024

Conversation

roberfi
Copy link
Contributor

@roberfi roberfi commented Nov 24, 2023

Fixes #7563

Inside check_str_format_call method, it checks if expression of format method call is an Enum member and it takes Literal value of that Enum member to check the format call arguments, if so.

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): typechecking got 1.09x faster (194.1s -> 178.0s)
(Performance measurements are based on a single noisy sample)

Copy link
Collaborator

@hauntsaninja hauntsaninja left a comment

Choose a reason for hiding this comment

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

Thanks for the fix!

@hauntsaninja hauntsaninja merged commit 732d98e into python:master Apr 8, 2024
18 checks passed
@roberfi roberfi deleted the fix-string-enums-formatting branch April 10, 2024 12:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Using string enums with string formatting may cause false positives
2 participants