-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Fix crash caused by invalid format strings in .format
context
#10300
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
Codecov ReportAll modified and coverable lines are covered by tests β
Additional details and impacted files@@ Coverage Diff @@
## main #10300 +/- ##
=======================================
Coverage 95.86% 95.86%
=======================================
Files 175 175
Lines 19074 19074
=======================================
Hits 18286 18286
Misses 788 788
π New features to boost your workflow:
|
This comment has been minimized.
This comment has been minimized.
π€ According to the primer, this change has no effect on the checked open source code. π€π This comment was generated for commit 2b16fcf |
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.
Great !
if isinstance(keyword, nodes.Dict): | ||
if len(keyword.items) > 1 and len(keyword_args) > 1: | ||
return | ||
if ( | ||
isinstance(keyword, nodes.Dict) | ||
and len(keyword.items) > 1 | ||
and len(keyword_args) > 1 | ||
): | ||
return |
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.
Nice !
I don't know what's wrong with the failing job, seems like a cache issue where pylint 4.0.0dev0 doesn't refer to the same commit ? |
.format
context.format
context
β¦) (#10302) (cherry picked from commit e6cbd41) Co-authored-by: Zen Lee <[email protected]>
Type of Changes
Description
This PR addresses a crash in the
consider-using-f-string
check that occurs when.format
is used with keyword arguments and the format string is malformed. Theutils.parse_format_method_string
raises an uncaughtIncompleteFormatString
exception, leading to the unexpected crash.Another observation is
consider-using-f-string
is raised when.format
is used with positional arguments:In such cases, it seems more appropriate to suppress
consider-using-f-string
, since thebad-format-string
message already covers the issue.Closes #10282