Skip to content

cache bug switching to disallow_incomplete_defs = true #5413

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

Closed
asottile opened this issue Aug 1, 2018 · 1 comment
Closed

cache bug switching to disallow_incomplete_defs = true #5413

asottile opened this issue Aug 1, 2018 · 1 comment
Labels
bug mypy got something wrong

Comments

@asottile
Copy link
Contributor

asottile commented Aug 1, 2018

version info

$ mypy --version
mypy 0.620

reproduction script

#!/usr/bin/env bash
set -euxo pipefail

mypy --version
rm -rf .mypy_cache

: should pass, no special setting
echo -e 'def f(x) -> str:\n    return ""\n' > t.py
echo -e '[mypy]\n' > mypy.ini
mypy t.py

: should fail, does not
echo -e '[mypy]\ndisallow_incomplete_defs = true' > mypy.ini
mypy t.py

: now it properly fails
rm -rf .mypy_cache
mypy t.py

reproduction output

+ mypy --version
mypy 0.620
+ rm -rf .mypy_cache
+ : should pass, no special setting
+ echo -e 'def f(x) -> str:\n    return ""\n'
+ echo -e '[mypy]\n'
+ mypy t.py
+ : should fail, does not
+ echo -e '[mypy]\ndisallow_incomplete_defs = true'
+ mypy t.py
+ : now it properly fails
+ rm -rf .mypy_cache
+ mypy t.py
t.py:1: error: Function is missing a type annotation for one or more arguments

more obvious file contents

before

[mypy]
def f(x) -> str:
    return ""

after

[mypy]
disallow_incomplete_defs = true
def f(x) -> str:
    return ""
@gvanrossum
Copy link
Member

Confirmed. Manual repro instructions: with the t.py file above, and starting with an empty .mypy_cache:

  • run mypy t.py --disallow-untyped-defs (gives an error)
  • run mypy t.py (no error)
  • run mypy t.py --disallow-untyped-defs (no error!)

It seems that when the flag value changes the cache is not ignored. A possible fix would be to add "disallow_incomplete_defs" to the list of per-module options (PER_MODULE_OPTIONS) in mypy/options.py (thus also causing it to be added to OPTIONS_AFFECTING_CACHE), though I'm not sure why this option is currently not per-module.

@gvanrossum gvanrossum added the bug mypy got something wrong label Aug 1, 2018
gvanrossum pushed a commit that referenced this issue Aug 3, 2018
This invalidates the cache if disallow_incomplete_defs changes, fixing #5413.
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

2 participants