Skip to content

Refresh of partial type produces the wrong type in fine-grained incremental mode #4464

Closed
@JukkaL

Description

@JukkaL

This test case fails in fine-grained incremental mode, though the code is okay in batch mode:

[case testRefreshPartialSpanningScopes]
import a
a.x

class A:
    x = None

    def f(self) -> None:
        a.x
        self.x = ''  # Incompatible types in assignment (expression has type "str", 
                     # variable has type "None")
[file a.py]
x = 0
[file a.py.2]
x = ''

The type of attribute A.x is derived from information in two scopes (class body and method f), and this logic fails in fine-grained incremental mode.

The best fix might be to require an annotation for x in class body.

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions