Skip to content

Add plugin API to specify fine grained dependencies #5153

@ilevkivskyi

Description

@ilevkivskyi

Currently plugins can add type information that requires reprocessing if another node is updated. This requires additional fine grained dependencies to be correct. For example:

# file a.py
@dataclass
class A:
    x: int

# file b.py
from a import A
@dataclass
class B(A):
    y: int

B(1, 2)

Updating type of a.A.x requires re-checking (more precisely re-semantically analyzing) the B definition, and the B call later in b.py.

The idea is to give a possibility for plugins to add dependencies. It looks like the simplest way is to add an add_dependencies method to semantic analyzer interface with a signature like def (trigger_fullname: str, node_to_recheck: Node) -> None. Then hooks for class decorators, base classes, and metaclasses can use it when modifying a TypeInfo.

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions