Skip to content

feat: support constant folding in ExpressionChecker.visit_typeddict_index_expr [1/1]#19976

Open
BobTheBuidler wants to merge 7 commits into
python:masterfrom
BobTheBuidler:constant-fold-typeddict-index
Open

feat: support constant folding in ExpressionChecker.visit_typeddict_index_expr [1/1]#19976
BobTheBuidler wants to merge 7 commits into
python:masterfrom
BobTheBuidler:constant-fold-typeddict-index

Conversation

@BobTheBuidler

Copy link
Copy Markdown
Contributor

This PR implements constant folding in ExpressionChecker.visit_typeddict_index_expr

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

Copy link
Copy Markdown
Contributor

According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅

Comment thread mypy/checkexpr.py
) -> tuple[Type, set[str]]:
if isinstance(index, StrExpr):
key_names = [index.value]
if isinstance(folded_index := constant_fold_expr(index, "unused"), str):

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Should we make cur_mod_id an invalid identifier?

Suggested change
if isinstance(folded_index := constant_fold_expr(index, "unused"), str):
if isinstance(folded_index := constant_fold_expr(index, "--dummy.name--"), str):

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.

3 participants