Common method for applying class decorators. Called on regular classes, typeddicts, and namedtuples.
(
self, defn: ClassDef, info: TypeInfo, decorator: Expression
)
| 2248 | defn.info.dataclass_transform_spec = self.parse_dataclass_transform_spec(decorator) |
| 2249 | |
| 2250 | def analyze_class_decorator_common( |
| 2251 | self, defn: ClassDef, info: TypeInfo, decorator: Expression |
| 2252 | ) -> None: |
| 2253 | """Common method for applying class decorators. |
| 2254 | |
| 2255 | Called on regular classes, typeddicts, and namedtuples. |
| 2256 | """ |
| 2257 | if refers_to_fullname(decorator, FINAL_DECORATOR_NAMES): |
| 2258 | info.is_final = True |
| 2259 | elif refers_to_fullname(decorator, DISJOINT_BASE_DECORATOR_NAMES): |
| 2260 | if info.is_protocol: |
| 2261 | self.fail("@disjoint_base cannot be used with protocol class", decorator) |
| 2262 | elif info.typeddict_type is not None: |
| 2263 | self.fail("@disjoint_base cannot be used with TypedDict", decorator) |
| 2264 | else: |
| 2265 | info.is_disjoint_base = True |
| 2266 | elif refers_to_fullname(decorator, TYPE_CHECK_ONLY_NAMES): |
| 2267 | info.is_type_check_only = True |
| 2268 | elif (deprecated := self.get_deprecated(decorator)) is not None: |
| 2269 | info.deprecated = f"class {defn.fullname} is deprecated: {deprecated}" |
| 2270 | |
| 2271 | def clean_up_bases_and_infer_type_variables( |
| 2272 | self, defn: ClassDef, base_type_exprs: list[Expression], context: Context |
no test coverage detected