Return all triggers associated with the attribute of a type.
(self, typ: Type, name: str)
| 902 | self.add_dependency(target) |
| 903 | |
| 904 | def attribute_triggers(self, typ: Type, name: str) -> list[str]: |
| 905 | """Return all triggers associated with the attribute of a type.""" |
| 906 | typ = get_proper_type(typ) |
| 907 | if isinstance(typ, TypeVarType): |
| 908 | typ = get_proper_type(typ.upper_bound) |
| 909 | if isinstance(typ, TupleType): |
| 910 | typ = typ.partial_fallback |
| 911 | if isinstance(typ, Instance): |
| 912 | member = f"{typ.type.fullname}.{name}" |
| 913 | return [make_trigger(member)] |
| 914 | elif isinstance(typ, FunctionLike) and typ.is_type_obj(): |
| 915 | member = f"{typ.type_object().fullname}.{name}" |
| 916 | triggers = [make_trigger(member)] |
| 917 | triggers.extend(self.attribute_triggers(typ.fallback, name)) |
| 918 | return triggers |
| 919 | elif isinstance(typ, UnionType): |
| 920 | targets = [] |
| 921 | for item in typ.items: |
| 922 | targets.extend(self.attribute_triggers(item, name)) |
| 923 | return targets |
| 924 | elif isinstance(typ, TypeType): |
| 925 | triggers = self.attribute_triggers(typ.item, name) |
| 926 | if isinstance(typ.item, Instance) and typ.item.type.metaclass_type is not None: |
| 927 | triggers.append( |
| 928 | make_trigger(f"{typ.item.type.metaclass_type.type.fullname}.{name}") |
| 929 | ) |
| 930 | return triggers |
| 931 | else: |
| 932 | return [] |
| 933 | |
| 934 | def add_attribute_dependency_for_expr(self, e: Expression, name: str) -> None: |
| 935 | typ = self.type_map.get(e) |
no test coverage detected