A logical node representing all the variants of a multi-declaration function. A multi-declaration function is often an @overload, but can also be a @property with a setter and a/or a deleter. This node has no explicit representation in the source program. Overloaded variants must b
| 784 | |
| 785 | |
| 786 | class OverloadedFuncDef(FuncBase, SymbolNode, Statement): |
| 787 | """A logical node representing all the variants of a multi-declaration function. |
| 788 | |
| 789 | A multi-declaration function is often an @overload, but can also be a |
| 790 | @property with a setter and a/or a deleter. |
| 791 | |
| 792 | This node has no explicit representation in the source program. |
| 793 | Overloaded variants must be consecutive in the source file. |
| 794 | """ |
| 795 | |
| 796 | __slots__ = ( |
| 797 | "items", |
| 798 | "unanalyzed_items", |
| 799 | "impl", |
| 800 | "deprecated", |
| 801 | "setter_index", |
| 802 | "_is_trivial_self", |
| 803 | ) |
| 804 | |
| 805 | items: list[OverloadPart] |
| 806 | unanalyzed_items: list[OverloadPart] |
| 807 | impl: OverloadPart | None |
| 808 | deprecated: str | None |
| 809 | setter_index: int | None |
| 810 | |
| 811 | def __init__(self, items: list[OverloadPart]) -> None: |
| 812 | super().__init__() |
| 813 | self.items = items |
| 814 | self.unanalyzed_items = items.copy() |
| 815 | self.impl = None |
| 816 | self.deprecated = None |
| 817 | self.setter_index = None |
| 818 | self._is_trivial_self: bool | None = None |
| 819 | if items: |
| 820 | # TODO: figure out how to reliably set end position (we don't know the impl here). |
| 821 | self.set_line(items[0].line, items[0].column) |
| 822 | |
| 823 | @property |
| 824 | def name(self) -> str: |
| 825 | if self.items: |
| 826 | return self.items[0].name |
| 827 | else: |
| 828 | # This may happen for malformed overload |
| 829 | assert self.impl is not None |
| 830 | return self.impl.name |
| 831 | |
| 832 | @property |
| 833 | def is_trivial_self(self) -> bool: |
| 834 | """Check we can use bind_self() fast path for this overload. |
| 835 | |
| 836 | This will return False if at least one overload: |
| 837 | * Has an explicit self annotation, or Self in signature. |
| 838 | * Has a non-trivial decorator. |
| 839 | """ |
| 840 | if self._is_trivial_self is not None: |
| 841 | return self._is_trivial_self |
| 842 | for i, item in enumerate(self.items): |
| 843 | # Note: bare @property is removed in visit_decorator(). |
no outgoing calls
no test coverage detected
searching dependent graphs…