From 61f7f4e86f09f1d7c44571cb8f0ef9f23ba54dbe Mon Sep 17 00:00:00 2001 From: tserg <8017125+tserg@users.noreply.github.com> Date: Mon, 14 Oct 2024 02:47:38 +0800 Subject: [PATCH] refactor[lang]: remove translated fields for constant nodes (#4287) This commit removes the `.s` field from the AST for string-like constants. These were deprecated in the Python AST in 3.8; we no longer need to translate them for our AST. --------- Co-authored-by: Charles Cooper --- vyper/ast/nodes.py | 12 ------------ vyper/ast/nodes.pyi | 19 ++++--------------- 2 files changed, 4 insertions(+), 27 deletions(-) diff --git a/vyper/ast/nodes.py b/vyper/ast/nodes.py index a5e3d0118d..974685f403 100644 --- a/vyper/ast/nodes.py +++ b/vyper/ast/nodes.py @@ -676,7 +676,6 @@ class DocStr(VyperNode): """ __slots__ = ("value",) - _translated_fields = {"s": "value"} class arguments(VyperNode): @@ -887,7 +886,6 @@ def bytes_value(self): class Str(Constant): __slots__ = () - _translated_fields = {"s": "value"} def validate(self): for c in self.value: @@ -897,7 +895,6 @@ def validate(self): class Bytes(Constant): __slots__ = () - _translated_fields = {"s": "value"} def __init__(self, parent: Optional["VyperNode"] = None, **kwargs: dict): super().__init__(parent, **kwargs) @@ -911,14 +908,9 @@ def to_dict(self): ast_dict["value"] = f"0x{self.value.hex()}" return ast_dict - @property - def s(self): - return self.value - class HexBytes(Constant): __slots__ = () - _translated_fields = {"s": "value"} def __init__(self, parent: Optional["VyperNode"] = None, **kwargs: dict): super().__init__(parent, **kwargs) @@ -930,10 +922,6 @@ def to_dict(self): ast_dict["value"] = f"0x{self.value.hex()}" return ast_dict - @property - def s(self): - return self.value - class List(ExprNode): __slots__ = ("elements",) diff --git a/vyper/ast/nodes.pyi b/vyper/ast/nodes.pyi index 6d05a2e200..783764271d 100644 --- a/vyper/ast/nodes.pyi +++ b/vyper/ast/nodes.pyi @@ -110,9 +110,7 @@ class ExprNode(VyperNode): class Constant(ExprNode): value: Any = ... -class Num(Constant): - @property - def n(self): ... +class Num(Constant): ... class Int(Num): value: int = ... @@ -123,18 +121,9 @@ class Hex(Num): @property def n_bytes(self): ... -class Str(Constant): - @property - def s(self): ... - -class Bytes(Constant): - @property - def s(self): ... - -class HexBytes(Constant): - @property - def s(self): ... - +class Str(Constant): ... +class Bytes(Constant): ... +class HexBytes(Constant): ... class NameConstant(Constant): ... class Ellipsis(Constant): ...