From c3aad04387a258d974828715409595aa81b13d3e Mon Sep 17 00:00:00 2001 From: benny Date: Thu, 29 Aug 2024 02:45:20 +1000 Subject: [PATCH 1/2] Handle exports better --- src/mamushi/formatting/whitespace.py | 2 +- src/mamushi/parsing/grammar.lark | 4 ++-- src/mamushi/parsing/tokens.py | 4 ++-- tests/data/{imports => modules}/imported_type_splitting.vy | 0 4 files changed, 5 insertions(+), 5 deletions(-) rename tests/data/{imports => modules}/imported_type_splitting.vy (100%) diff --git a/src/mamushi/formatting/whitespace.py b/src/mamushi/formatting/whitespace.py index 4717036..edd8054 100644 --- a/src/mamushi/formatting/whitespace.py +++ b/src/mamushi/formatting/whitespace.py @@ -113,7 +113,7 @@ def whitespace(leaf: Leaf) -> str: ): # no parentheses on calls, function sigs, logs and defs # except for returns - if t == tokens.LPAR and prev.type not in tokens.RETURN_TYPE: + if t == tokens.LPAR and prev.type not in {tokens.RETURN_TYPE}: return NO if t == tokens.LSQB: diff --git a/src/mamushi/parsing/grammar.lark b/src/mamushi/parsing/grammar.lark index c65c1cf..411e71e 100644 --- a/src/mamushi/parsing/grammar.lark +++ b/src/mamushi/parsing/grammar.lark @@ -16,7 +16,7 @@ module: ( DOCSTRING | transient_def | implements_def | uses_def - | exports_def + | export | initializes_stmt | function_def | immutable_def @@ -122,7 +122,7 @@ interface_def: _INTERFACE_DECL NAME ":" _NEWLINE _INDENT ( interface_function _N implements_def: "implements" ":" NAME uses_def: "uses" ":" NAME -exports_def: "exports" ":" (attribute | tuple) +export: "exports" ":" (attribute | "(" attribute ")"| tuple) _INITIALIZES_DECL: "initializes" initializes_stmt: _INITIALIZES_DECL ":" initializes_list diff --git a/src/mamushi/parsing/tokens.py b/src/mamushi/parsing/tokens.py index bdf75d6..4fedd6f 100644 --- a/src/mamushi/parsing/tokens.py +++ b/src/mamushi/parsing/tokens.py @@ -182,7 +182,7 @@ INTERFACE_DEF = "interface_def" IMPLEMENTS_DEF = "implements_def" USES_DEF = "uses_def" -EXPORTS_DEF = "exports_def" +EXPORT = "export" STRUCT_DEF = "struct_def" ENUM_DEF = "enum_def" EVENT_DEF = "event_def" @@ -205,7 +205,7 @@ INITIALIZES_STMT, IMPLEMENTS_DEF, USES_DEF, - EXPORTS_DEF, + EXPORT, CONSTANT_DEF, IMMUTABLE_DEF, INTERFACE_DEF, diff --git a/tests/data/imports/imported_type_splitting.vy b/tests/data/modules/imported_type_splitting.vy similarity index 100% rename from tests/data/imports/imported_type_splitting.vy rename to tests/data/modules/imported_type_splitting.vy From d7a3f354bc8988259f71c0deb2d0e59743db3211 Mon Sep 17 00:00:00 2001 From: benny Date: Thu, 29 Aug 2024 02:46:28 +1000 Subject: [PATCH 2/2] new build --- pyproject.toml | 2 +- setup.cfg | 2 +- src/mamushi/__version__.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 0f545e2..c7d9b05 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -38,7 +38,7 @@ build-backend = "setuptools.build_meta" [tool.poetry] name = "mamushi" -version = "0.0.4-a1" +version = "0.0.4-a2" description = "Vyper Formatter" authors = ["benny "] diff --git a/setup.cfg b/setup.cfg index 80bf3f9..df520f8 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 0.0.4-a1 +current_version = 0.0.4-a2 commit = False tag = True parse = (?P\d+)\.(?P\d+)\.(?P\d+)(\-(?P[a-z]+)(?P\d+))? diff --git a/src/mamushi/__version__.py b/src/mamushi/__version__.py index fa75b8d..f22196d 100644 --- a/src/mamushi/__version__.py +++ b/src/mamushi/__version__.py @@ -1 +1 @@ -__version__ = "0.0.4-a1" +__version__ = "0.0.4-a2"