MCPcopy
hub / github.com/Instagram/LibCST / field

Method field

libcst/_nodes/base.py:461–469  ·  view source on GitHub ↗

A helper that allows us to easily use CSTNodes in dataclass constructor defaults without accidentally aliasing nodes by identity across multiple instances.

(cls, *args: object, **kwargs: object)

Source from the content-addressed store, hash-verified

459 @classmethod
460 # pyre-fixme[3]: Return annotation cannot be `Any`.
461 def field(cls, *args: object, **kwargs: object) -> Any:
462 """
463 A helper that allows us to easily use CSTNodes in dataclass constructor
464 defaults without accidentally aliasing nodes by identity across multiple
465 instances.
466 """
467 # pyre-ignore Pyre is complaining about CSTNode not being instantiable,
468 # but we're only going to call this from concrete subclasses.
469 return field(default_factory=lambda: cls(*args, **kwargs))
470
471
472class BaseLeaf(CSTNode, ABC):

Callers 15

SemicolonClass · 0.80
ColonClass · 0.80
CommaClass · 0.80
DotClass · 0.80
AssignEqualClass · 0.80
PlusClass · 0.80
MinusClass · 0.80
BitInvertClass · 0.80
NotClass · 0.80
AndClass · 0.80
OrClass · 0.80
AddClass · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected