Function definition. This is a non-lambda function defined using 'def'.
| 1092 | |
| 1093 | |
| 1094 | class FuncDef(FuncItem, SymbolNode, Statement): |
| 1095 | """Function definition. |
| 1096 | |
| 1097 | This is a non-lambda function defined using 'def'. |
| 1098 | """ |
| 1099 | |
| 1100 | __slots__ = ( |
| 1101 | "_name", |
| 1102 | "is_decorated", |
| 1103 | "is_conditional", |
| 1104 | "abstract_status", |
| 1105 | "original_def", |
| 1106 | "is_trivial_body", |
| 1107 | "is_trivial_self", |
| 1108 | "is_invalid_redefinition", |
| 1109 | "is_mypy_only", |
| 1110 | # Present only when a function is decorated with @typing.dataclass_transform or similar |
| 1111 | "dataclass_transform_spec", |
| 1112 | "docstring", |
| 1113 | "deprecated", |
| 1114 | "original_first_arg", |
| 1115 | ) |
| 1116 | |
| 1117 | __match_args__ = ("name", "arguments", "type", "body") |
| 1118 | |
| 1119 | # Note that all __init__ args must have default values |
| 1120 | def __init__( |
| 1121 | self, |
| 1122 | name: str = "", # Function name |
| 1123 | arguments: list[Argument] | None = None, |
| 1124 | body: Block | None = None, |
| 1125 | typ: mypy.types.FunctionLike | None = None, |
| 1126 | type_args: list[TypeParam] | None = None, |
| 1127 | ) -> None: |
| 1128 | super().__init__(arguments, body, typ, type_args) |
| 1129 | self._name = name |
| 1130 | self.is_decorated = False |
| 1131 | self.is_conditional = False # Defined conditionally (within block)? |
| 1132 | self.abstract_status = NOT_ABSTRACT |
| 1133 | # Is this an abstract method with trivial body? |
| 1134 | # Such methods can't be called via super(). |
| 1135 | self.is_trivial_body = False |
| 1136 | # Original conditional definition |
| 1137 | self.original_def: None | FuncDef | Var | Decorator = None |
| 1138 | # Definitions that appear in if TYPE_CHECKING are marked with this flag. |
| 1139 | self.is_mypy_only = False |
| 1140 | self.dataclass_transform_spec: DataclassTransformSpec | None = None |
| 1141 | self.docstring: str | None = None |
| 1142 | self.deprecated: str | None = None |
| 1143 | # This is used to simplify bind_self() logic in trivial cases (which are |
| 1144 | # the majority). In cases where self is not annotated and there are no Self |
| 1145 | # in the signature we can simply drop the first argument. |
| 1146 | self.is_trivial_self = False |
| 1147 | # This is needed because for positional-only arguments the name is set to None, |
| 1148 | # but we sometimes still want to show it in error messages. |
| 1149 | if arguments: |
| 1150 | self.original_first_arg: str | None = arguments[0].variable.name |
| 1151 | else: |
no outgoing calls
no test coverage detected
searching dependent graphs…