-
-
Notifications
You must be signed in to change notification settings - Fork 3k
feat: support constant folding in StringFormatterChecker.checkers_for_c_type
[1/1]
#19978
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
base: master
Are you sure you want to change the base?
feat: support constant folding in StringFormatterChecker.checkers_for_c_type
[1/1]
#19978
Conversation
StringFormatterChecker.checkers_for_c_type
StringFormatterChecker.checkers_for_c_type
[1/1]
This comment has been minimized.
This comment has been minimized.
self.msg.requires_int_or_single_byte(context) | ||
elif isinstance(expr, (StrExpr, BytesExpr)) and len(expr.value) != 1: | ||
self.msg.requires_int_or_char(context) | ||
elif isinstance(folded := constant_fold_expr(expr, "<unused>"), str): |
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.
note to self: can I get cur_mod_id from context?
This comment has been minimized.
This comment has been minimized.
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.
Please add a mypy checker test case.
I forgot I can't use Final for my test here since we don't pass But once we merge #19982 I can do a simple |
According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅ |
This PR implements constant folding in
StringFormatterChecker.checkers_for_c_type