(
itype: Instance, name: str, mx: MemberContext
)
| 1350 | |
| 1351 | |
| 1352 | def analyze_enum_class_attribute_access( |
| 1353 | itype: Instance, name: str, mx: MemberContext |
| 1354 | ) -> Type | None: |
| 1355 | # Skip these since Enum will remove it |
| 1356 | if name in EXCLUDED_ENUM_ATTRIBUTES: |
| 1357 | return report_missing_attribute(mx.original_type, itype, name, mx) |
| 1358 | |
| 1359 | node = itype.type.get(name) |
| 1360 | if node and node.type: |
| 1361 | proper = get_proper_type(node.type) |
| 1362 | # Support `A = nonmember(1)` function call and decorator. |
| 1363 | if ( |
| 1364 | isinstance(proper, Instance) |
| 1365 | and proper.type.fullname == "enum.nonmember" |
| 1366 | and proper.args |
| 1367 | ): |
| 1368 | return proper.args[0] |
| 1369 | |
| 1370 | if name not in itype.type.enum_members: |
| 1371 | return None |
| 1372 | |
| 1373 | enum_literal = LiteralType(name, fallback=itype) |
| 1374 | return itype.copy_modified(last_known_value=enum_literal) |
| 1375 | |
| 1376 | |
| 1377 | def analyze_typeddict_access( |
no test coverage detected
searching dependent graphs…