Generate fine-grained dependencies for AST nodes, for use in the daemon mode.
Dependencies are stored in a map from triggers to sets of affected locations.
A trigger is a string that represents a program property that has changed, such as the signature of a specific function. Triggers are written as '<...>' (angle brackets). When a program property changes, we determine the relevant trigger(s) and all affected locations. The latter are stale and will have to be reprocessed.
An affected location is a string than can refer to a target (a non-nested function or method, or a module top level), a class, or a trigger (for recursively triggering other triggers).
Here's an example representation of a simple dependency map (in format "<trigger> -> locations"):
<m.A.g> -> m.f <m.A> -> <m.f>, m.A, m.f
Assuming 'A' is a class, this means that
The triggers to fire are determined using mypy.server.astdiff.
Examples of triggers:
Examples of locations:
Triggers can be triggered by program changes such as these:
Changes in the body of a function that aren't reflected in the signature don't cause the function to be triggered. More generally, we trigger only on changes that may affect type checking results outside the module that contains the change.
We don't generate dependencies from builtins and certain other stdlib modules, since these change very rarely, and they would just increase the size of the dependency map significantly without significant benefit.
Test cases for this module live in 'test-data/unit/deps*.test'.
Class | DependencyVisitor |
No class docstring; 0/8 instance variable, 8/50 methods documented |
Class | TypeTriggersVisitor |
Undocumented |
Function | dump_all_dependencies |
Generate dependencies for all interesting modules and print them to stdout. |
Function | get_dependencies |
Get all dependencies of a node, recursively. |
Function | get_dependencies_of_target |
Get dependencies of a target -- don't recursive into nested targets. |
Function | get_type_triggers |
Return all triggers that correspond to a type becoming stale. |
Function | has_user_bases |
Undocumented |
Function | merge_dependencies |
Undocumented |
Function | non_trivial_bases |
Undocumented |
Parameters | |
modules:Dict[ | Undocumented |
type_map:Dict[ | Undocumented |
python_version:Tuple[ | Undocumented |
options:Options | Undocumented |
Parameters | |
target:MypyFile | Undocumented |
type_map:Dict[ | Undocumented |
python_version:Tuple[ | Undocumented |
options:Options | Undocumented |
Returns | |
Dict[ | Undocumented |
Parameters | |
module_id:str | Undocumented |
module_tree:MypyFile | Undocumented |
target:Node | Undocumented |
type_map:Dict[ | Undocumented |
python_version:Tuple[ | Undocumented |
Returns | |
Dict[ | Undocumented |
Parameters | |
typ:Type | Undocumented |
use_logical_deps:bool | Undocumented |
Returns | |
List[ | Undocumented |