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

Version 1.5.0 breaks argpare.parse_args(namespace) #15847

Closed
kovidgoyal opened this issue Aug 11, 2023 · 3 comments
Closed

Version 1.5.0 breaks argpare.parse_args(namespace) #15847

kovidgoyal opened this issue Aug 11, 2023 · 3 comments
Labels
bug mypy got something wrong

Comments

@kovidgoyal
Copy link

Here is a test case:

import argparse

class Options(argparse.Namespace):
    something: bool = True

p = argparse.ArgumentParser()
a: Options = p.parse_args(namespace=Options())

Running mypy version 1.5.0 on it gives the spurious error

10: error: Incompatible types in assignment (expression has type "Namespace", variable has type "Options")  [assignment]
    a: Options = p.parse_args(namespace=Options())
                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Found 1 error in 1 file (checked 1 source file)

Running mypy version 1.3.0 on it passes.

@kovidgoyal kovidgoyal added the bug mypy got something wrong label Aug 11, 2023
@cdce8p
Copy link
Collaborator

cdce8p commented Aug 11, 2023

I bisected the issue to 59a6c5e. Seems like an issue with the argparse typing stubs.
Looks like it's already fixed in typeshed, however the sync didn't make it in time for this release. Probably in 1.6.0 then.

CC @AlexWaygood

@AlexWaygood
Copy link
Member

Yeah, the issue was cause by python/typeshed#10307, which made it into mypy v1.5. It's already been fixed on typeshed's main branch by python/typeshed#10387, but the fix unfortunately didn't make it into mypy v1.5.

Since python/typeshed#10387 was a fairly small PR, it could possibly be cherry-picked into the next mypy patch release. However, I know @svalentin has already created the mypy 1.5.1 tag, so I'm not sure if it's possible to get a fix into mypy 1.5.1 :/

(We also can't create any new mypy releases at all until pypi/support#3094 is resolved)

@alicederyn
Copy link

This appears to be fixed in mypy 1.6.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug mypy got something wrong
Projects
None yet
Development

No branches or pull requests

4 participants