Whether this type alias is recursive. Note this doesn't check generic alias arguments, but only if this alias *definition* is recursive. The property value thus can be cached on the underlying TypeAlias node. If you want to include all nested types, use has_recursive
(self)
| 383 | |
| 384 | @property |
| 385 | def is_recursive(self) -> bool: |
| 386 | """Whether this type alias is recursive. |
| 387 | |
| 388 | Note this doesn't check generic alias arguments, but only if this alias |
| 389 | *definition* is recursive. The property value thus can be cached on the |
| 390 | underlying TypeAlias node. If you want to include all nested types, use |
| 391 | has_recursive_types() function. |
| 392 | """ |
| 393 | assert self.alias is not None, "Unfixed type alias" |
| 394 | is_recursive = self.alias._is_recursive |
| 395 | if is_recursive is None: |
| 396 | is_recursive = self.alias in self.alias.target.accept(CollectAliasesVisitor()) |
| 397 | # We cache the value on the underlying TypeAlias node as an optimization, |
| 398 | # since the value is the same for all instances of the same alias. |
| 399 | self.alias._is_recursive = is_recursive |
| 400 | return is_recursive |
| 401 | |
| 402 | def can_be_true_default(self) -> bool: |
| 403 | if self.alias is not None: |
nothing calls this directly
no test coverage detected