A variable. It can refer to global/local variable or a data attribute.
| 1418 | |
| 1419 | |
| 1420 | class Var(SymbolNode): |
| 1421 | """A variable. |
| 1422 | |
| 1423 | It can refer to global/local variable or a data attribute. |
| 1424 | """ |
| 1425 | |
| 1426 | __slots__ = ( |
| 1427 | "_name", |
| 1428 | "_fullname", |
| 1429 | "info", |
| 1430 | "type", |
| 1431 | "setter_type", |
| 1432 | "final_value", |
| 1433 | "is_self", |
| 1434 | "is_cls", |
| 1435 | "is_ready", |
| 1436 | "is_inferred", |
| 1437 | "is_initialized_in_class", |
| 1438 | "is_staticmethod", |
| 1439 | "is_classmethod", |
| 1440 | "is_property", |
| 1441 | "is_settable_property", |
| 1442 | "is_classvar", |
| 1443 | "is_abstract_var", |
| 1444 | "is_final", |
| 1445 | "is_index_var", |
| 1446 | "final_unset_in_class", |
| 1447 | "final_set_in_init", |
| 1448 | "is_suppressed_import", |
| 1449 | "explicit_self_type", |
| 1450 | "from_module_getattr", |
| 1451 | "has_explicit_value", |
| 1452 | "allow_incompatible_override", |
| 1453 | "invalid_partial_type", |
| 1454 | "is_argument", |
| 1455 | ) |
| 1456 | |
| 1457 | __match_args__ = ("name", "type", "final_value") |
| 1458 | |
| 1459 | def __init__(self, name: str, type: mypy.types.Type | None = None) -> None: |
| 1460 | super().__init__() |
| 1461 | self._name = name # Name without module prefix |
| 1462 | # TODO: Should be Optional[str] |
| 1463 | self._fullname = "" # Name with module prefix |
| 1464 | # TODO: Should be Optional[TypeInfo] |
| 1465 | self.info = VAR_NO_INFO |
| 1466 | self.type: mypy.types.Type | None = type # Declared or inferred type, or None |
| 1467 | # The setter type for settable properties. |
| 1468 | self.setter_type: mypy.types.CallableType | None = None |
| 1469 | # Is this the first argument to an ordinary method (usually "self")? |
| 1470 | self.is_self = False |
| 1471 | # Is this the first argument to a classmethod (typically "cls")? |
| 1472 | self.is_cls = False |
| 1473 | self.is_ready = True # If inferred, is the inferred type available? |
| 1474 | self.is_inferred = self.type is None |
| 1475 | # Is this variable declared in class body? The name is confusing, but it |
| 1476 | # is a very old attribute, and changing will break some plugins. |
| 1477 | self.is_initialized_in_class = False |
no outgoing calls
no test coverage detected