Skip to content

Invalidate cache when a plugin is added/removed #5892

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

Merged
merged 1 commit into from
Nov 14, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion mypy/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class BuildType:
} # type: Final

OPTIONS_AFFECTING_CACHE = ((PER_MODULE_OPTIONS |
{"quick_and_dirty", "platform", "bazel"})
{"quick_and_dirty", "platform", "bazel", "plugins"})
- {"debug_cache"}) # type: Final


Expand Down
86 changes: 86 additions & 0 deletions test-data/unit/check-incremental.test
Original file line number Diff line number Diff line change
Expand Up @@ -5500,3 +5500,89 @@ plugins=basic_plugin.py
[out]
[out2]
tmp/a.py:2: error: Incompatible types in assignment (expression has type "str", variable has type "int")

[case testAddedPluginsInvalidateCache]
# flags: --config-file tmp/mypy.ini
import a
[file a.py]
from b import x
y: int = x

[file a.py.2]
from b import x
y: int = x
touch = 1

[file b.py]
def f() -> int: ...
x = f()

[file basic_plugin.py]
from mypy.plugin import Plugin

class MyPlugin(Plugin):
def get_function_hook(self, fullname):
if fullname.endswith('.f'):
return my_hook
assert fullname is not None
return None

def my_hook(ctx):
return ctx.api.named_generic_type('builtins.str', [])

def plugin(version):
return MyPlugin

[file mypy.ini]
[[mypy]
python_version=3.6
[file mypy.ini.2]
[[mypy]
python_version=3.6
plugins=basic_plugin.py
[out]
[out2]
tmp/a.py:2: error: Incompatible types in assignment (expression has type "str", variable has type "int")

[case testRemovedPluginsInvalidateCache]
# flags: --config-file tmp/mypy.ini
import a
[file a.py]
from b import x
y: str = x

[file a.py.2]
from b import x
y: str = x
touch = 1

[file b.py]
def f() -> int: ...
x = f()

[file basic_plugin.py]
from mypy.plugin import Plugin

class MyPlugin(Plugin):
def get_function_hook(self, fullname):
if fullname.endswith('.f'):
return my_hook
assert fullname is not None
return None

def my_hook(ctx):
return ctx.api.named_generic_type('builtins.str', [])

def plugin(version):
return MyPlugin

[file mypy.ini]
[[mypy]
python_version=3.6
plugins=basic_plugin.py
[file mypy.ini.2]
[[mypy]
python_version=3.6
[out]
[out2]
tmp/a.py:2: error: Incompatible types in assignment (expression has type "int", variable has type "str")