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

dmypy and mypy behave differently with same settings #8046

Closed
kurtgn opened this issue Dec 1, 2019 · 5 comments · Fixed by #8201
Closed

dmypy and mypy behave differently with same settings #8046

kurtgn opened this issue Dec 1, 2019 · 5 comments · Fixed by #8201

Comments

@kurtgn
Copy link

kurtgn commented Dec 1, 2019

Consider this example:

class Config:
    url = None

    def __init__(self) -> None:
        self.url = 'xxx'

mypy says there are no errors, but dmypy with the same settings finds one:

$ mypy example.py
Success: no issues found in 1 source file

$ dmypy run -- --follow-imports=skip example.py
Daemon started
example.py:3: error: Need type annotation for 'url'
Found 1 error in 1 file (checked 1 source file)

my package versions:


$ python --version
Python 3.6.5 :: Anaconda, Inc.
$ mypy --version
mypy 0.750
@JukkaL
Copy link
Collaborator

JukkaL commented Dec 2, 2019

Yeah, this is a known issue (but it might be undocumented). You can use --local-partial-types to get the dmypy semantics when using mypy.

At some point we'll likely make --local-partial-types enabled by default.

@kurtgn
Copy link
Author

kurtgn commented Dec 2, 2019

Thanks! Can you provide any link to docs regarding local-partial-types at least for regular mypy? I can't seem to find one on the docs webpage.

@JukkaL
Copy link
Collaborator

JukkaL commented Dec 2, 2019

It looks like we've forgotten to document it.

@jnoortheen
Copy link

is there any config variable to set --local-partial-types in setup.cfg or similar ?

@bobwhitelock
Copy link
Contributor

bobwhitelock commented Aug 24, 2021

@jnoortheen It can be set with the local_partial_types option

Edit: Although it looks like setting this to True means it will be treated as True when running mypy as well as dmypy, as expected, but setting it to False will not override the implicit --local-partial-types when running dmypy, which seems a little surprising

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

Successfully merging a pull request may close this issue.

4 participants