forked from python/mypy
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtrigger.py
More file actions
24 lines (15 loc) · 784 Bytes
/
trigger.py
File metadata and controls
24 lines (15 loc) · 784 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
"""AST triggers that are used for fine-grained dependency handling."""
from typing_extensions import Final
# Used as a suffix for triggers to handle "from m import *" dependencies (see also
# make_wildcard_trigger)
WILDCARD_TAG = '[wildcard]' # type: Final
def make_trigger(name: str) -> str:
return '<%s>' % name
def make_wildcard_trigger(module: str) -> str:
"""Special trigger fired when any top-level name is changed in a module.
Note that this is different from a module trigger, as module triggers are only
fired if the module is created, deleted, or replaced with a non-module, whereas
a wildcard trigger is triggered for namespace changes.
This is used for "from m import *" dependencies.
"""
return '<%s%s>' % (module, WILDCARD_TAG)