Skip to content

Always patch indirect dependencies #5132

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
Jun 1, 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
6 changes: 3 additions & 3 deletions mypy/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -2057,9 +2057,9 @@ def finish_passes(self) -> None:
manager.options.dump_deps):
manager.all_types.update(self.type_map())

if self.options.incremental:
self._patch_indirect_dependencies(self.type_checker().module_refs,
self.type_map())
# We should always patch indirect dependencies, even in full (non-incremental) builds,
# because the cache still may be written, and it must be correct.
self._patch_indirect_dependencies(self.type_checker().module_refs, self.type_map())

if self.options.dump_inference_stats:
dump_type_stats(self.tree, self.xpath, inferred=True,
Expand Down
3 changes: 2 additions & 1 deletion mypy/test/testcheck.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,8 @@ def run_case_once(self, testcase: DataDrivenTestCase,
options.show_traceback = True
if 'optional' in testcase.file:
options.strict_optional = True
if incremental_step:
if incremental_step and options.incremental:
# Don't overwrite # flags: --no-incremental in incremental test cases
options.incremental = True
else:
options.incremental = False
Expand Down
18 changes: 18 additions & 0 deletions test-data/unit/check-incremental.test
Original file line number Diff line number Diff line change
Expand Up @@ -4410,3 +4410,21 @@ tmp/b.py:4: note: Expected:
tmp/b.py:4: note: def __iter__(self) -> Iterator[int]
tmp/b.py:4: note: Got:
tmp/b.py:4: note: def __iter__(self) -> Iterator[str]

[case testIndirectDepsAlwaysPatched-writescache]
# flags: --no-incremental
# flags2: --incremental
from b import C
def f() -> None:
x: int = C().x
[file b.py]
from c import C
[file c.pyi]
class C:
x: int
[file c.pyi.2]
class C:
x: str
[out]
[out2]
main:5: error: Incompatible types in assignment (expression has type "str", variable has type "int")