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 mypy 1.14.1 error #13148

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Conversation

notatallshaw
Copy link
Member

No description provided.

@notatallshaw
Copy link
Member Author

FYI, this is exactly the literal in typeshed and there is no importable version: https://github.com/python/typeshed/blob/f26ad2059ef33e7aa55a15bf861f594e441de03b/stdlib/tarfile.pyi#L109C11-L109C61

Also pyright is intelligent enough to know that mode isn't an arbitary str but seems mypy isn't 🙁

@sbidoul
Copy link
Member

sbidoul commented Jan 10, 2025

That's quite ugly, if you ask me.

Shall we skip the mypy upgrade until that is solved?

@notatallshaw
Copy link
Member Author

Shall we skip the mypy upgrade until that is solved?

I'll make an MRE, report it to mypy, and see what they say.

@pfmoore
Copy link
Member

pfmoore commented Jan 10, 2025

+1 on getting this fixed in mypy rather than adding that hack - and if we can't get a fix in mypy, I'd prefer using #type: ignore if we want to force things to work.

With luck, it'll just get fixed in mypy, though.

@notatallshaw
Copy link
Member Author

A little digging, this was actually caused by a typeshed change to the signature of tar.open: python/typeshed#12181

mypy consistently upcasts Literal to str when there are multiple different Literal strings in branch statements, I have made a request for them to fix this but it may be that it's working as designed or a long known difficult problem: python/mypy#18442

I'm suspecting it will be easier to go with #type: ignore for now, but I will leave it a day to see if there is any input from mypy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants