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)
| 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 | |
| 472 | class BaseLeaf(CSTNode, ABC): |