Skip to content

Conversation

@dcbaker
Copy link
Member

@dcbaker dcbaker commented Dec 5, 2025

Mypy is wrong because typeshed is wrong.

@dcbaker dcbaker added this to the 1.11 milestone Dec 5, 2025
@dcbaker dcbaker requested a review from jpakkane as a code owner December 5, 2025 18:33
@dcbaker dcbaker added the typing label Dec 5, 2025
@dcbaker dcbaker mentioned this pull request Dec 5, 2025
40 tasks
@dcbaker
Copy link
Member Author

dcbaker commented Dec 5, 2025

I think this is a typeshed issue

python/typeshed#15108

@dcbaker dcbaker force-pushed the submit/typesafe-datafile branch from c4d7ade to 95a9311 Compare December 8, 2025 18:22
@dcbaker
Copy link
Member Author

dcbaker commented Dec 8, 2025

@eli-schwartz: updated with an ignore because this is a bad warning from a bug in typeshed.

@eli-schwartz
Copy link
Member

Nice.

@jpakkane
Copy link
Member

jpakkane commented Dec 9, 2025

Seems to need tweaking.

mesonbuild/mesondata.py:30: error: Unused "type: ignore" comment  [unused-ignore]
mesonbuild/mesondata.py:30:24: error: Module has no attribute "files"  [attr-defined]
mesonbuild/mesondata.py:30:24: note: Error code "attr-defined" not covered by "type: ignore" comment

@dcbaker
Copy link
Member Author

dcbaker commented Dec 9, 2025

Yeah, I think we need to have a version check instead of a try/except

@eli-schwartz
Copy link
Member

eli-schwartz commented Dec 9, 2025

IIRC I wrote this and did it this way because a simple version check was wrong -- older versions of python didn't support the good path, and newer versions of python support the good path only when not running from a zipapp install. Trying to remember the details of what the thought process was...

Mypy is wrong, because typeshed is wrong, this is just fine.

We do need to add a version check, because mypy doesn't understand that
the code inside the try can fail, and that's fine. The try/except
remains, as it is needed for the zipapp case.
@dcbaker dcbaker force-pushed the submit/typesafe-datafile branch from 95a9311 to 566d844 Compare December 9, 2025 19:49
@dcbaker dcbaker requested a review from eli-schwartz December 9, 2025 21:41
except AttributeError:
# fall through to python 3.7 compatible code
pass
if sys.version_info >= (3, 10):
Copy link
Member

Choose a reason for hiding this comment

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

It should be fine with 3.9 too?

Copy link
Member

Choose a reason for hiding this comment

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

The error in the previous lint run was occurring for 3.7 and 3.8 only -- and it said "files() doesn't exist".

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.

3 participants