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 get_member_expr_fullname returning strings with embedded "None" #17848

Conversation

brianschubert
Copy link
Contributor

Fixes #17847

Before

from mypy.nodes import CallExpr, MemberExpr, NameExpr, get_member_expr_fullname
m3 = MemberExpr(MemberExpr(CallExpr(NameExpr("a"), [], [], []), "b"), "c")  # a().b.c

>>> get_member_expr_fullname(m3)
'None.c'

After

from mypy.nodes import CallExpr, MemberExpr, NameExpr, get_member_expr_fullname
m3 = MemberExpr(MemberExpr(CallExpr(NameExpr("a"), [], [], []), "b"), "c")  # a().b.c

>>> get_member_expr_fullname(m3) is None
True

This comment has been minimized.

@brianschubert
Copy link
Contributor Author

@hauntsaninja py313-dev-ubuntu test failure:

https://github.com/python/mypy/actions/runs/11085498771/job/30801981409?pr=17848#step:9:224

Looks like a sporadic error where clearing an OrderedDict during iteration can sometimes raise with a message of OrderedDict mutated during iteration instead of the expected message of OrderedDict changed size during iteration.

Copy link
Contributor

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

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.

Interesting that you got two failures in a row, I wonder if latest 3.13 branch changed something. (Test is easy to fix on our side, but could be worth checking whether CPython's behaviour is expected or not)

Thanks for spotting the issue and this fix, though!

@brianschubert
Copy link
Contributor Author

brianschubert commented Sep 28, 2024

Looks like this changed in python/cpython@c6c3d97 (python/cpython#121329). After that commit, the error message switches to OrderedDict mutated during iteration.

@hauntsaninja hauntsaninja merged commit ca28425 into python:master Sep 28, 2024
18 of 19 checks passed
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.

mypy.nodes.get_member_expr_fullname can return strings with embeded "None"
2 participants