From 2490301be031b15bf3e4446d755fcfee855d0be7 Mon Sep 17 00:00:00 2001 From: benny Date: Sat, 24 Aug 2024 17:39:31 +1000 Subject: [PATCH] v0.0.3 --- .pre-commit-config.yaml | 6 ++--- pyproject.toml | 6 ++--- setup.cfg | 22 ++++++++-------- src/mamushi/__version__.py | 2 +- src/mamushi/utils/files.py | 4 +-- tests/const.py | 2 +- tests/data/builtins/extcall_staticcall.vy | 26 +++++++++++++++++++ .../data/interfaces/interface_blank_lines.vyi | 14 ++++++++++ tests/reader.py | 13 ++++++---- 9 files changed, 69 insertions(+), 26 deletions(-) create mode 100644 tests/data/builtins/extcall_staticcall.vy create mode 100644 tests/data/interfaces/interface_blank_lines.vyi diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 440a115..48a150b 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -10,14 +10,14 @@ repos: rev: 23.1.0 hooks: - id: black - language_version: python3.10 + language_version: python3.11 args: [ --line-length=79 ] - repo: https://github.com/pycqa/flake8 rev: 3.9.2 hooks: - id: flake8 - language_version: python3.10 + language_version: python3.11 args: [ --max-line-length=79 ] stages: [ commit, push ] @@ -25,6 +25,6 @@ repos: rev: v0.971 hooks: - id: mypy - language_version: python3.10 + language_version: python3.11 additional_dependencies: ['types-requests'] stages: [ commit, push ] diff --git a/pyproject.toml b/pyproject.toml index 47cbf5d..9dbfabd 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -8,7 +8,7 @@ ensure_newline_before_comments = true [tool.black] line-length = 79 -target-version = ['py39', 'py310', 'py311', 'py312'] +target-version = ['py39', 'py310', 'py311'] include = '\.pyi?$' exclude = ''' ( @@ -38,7 +38,7 @@ build-backend = "setuptools.build_meta" [tool.poetry] name = "mamushi" -version = "0.0.2-b0" +version = "0.0.3" description = "Vyper Formatter" authors = ["benny "] @@ -58,4 +58,4 @@ coverage = ">=6.5.0" bump2version = ">=1.0.0" [tool.poetry.scripts] -mamushi = "mamushi.__main__:main" \ No newline at end of file +mamushi = "mamushi.__main__:main" diff --git a/setup.cfg b/setup.cfg index 4c2f9c8..f8f43b2 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,18 +1,18 @@ [bumpversion] -current_version = 0.0.2-b0 +current_version = 0.0.3 commit = False tag = True parse = (?P\d+)\.(?P\d+)\.(?P\d+)(\-(?P[a-z]+)(?P\d+))? -serialize = +serialize = {major}.{minor}.{patch}-{release}{build} {major}.{minor}.{patch} [options] -package_dir = +package_dir = = src packages = find: python_requires = >= 3.9 -install_requires = +install_requires = click>=8.0.0 pathspec>=0.9.0 lark>=1.0.0 @@ -24,11 +24,11 @@ include_package_data = True mamushi.parsing = *.lark [options.entry_points] -console_scripts = +console_scripts = mamushi=mamushi:main [options.extras_require] -dev = +dev = black==23.1.0 pre-commit==2.20.0 mypy_extensions==0.4.3 @@ -42,7 +42,7 @@ dev = [options.packages.find] where = src -exclude = +exclude = tests [metadata] @@ -53,10 +53,10 @@ long_description = file: README.md long_description_content_type = text/markdown version = attr: mamushi.__version__.__version__ url = https://github.com/benber86/mamushi -project_urls = +project_urls = Source = https://github.com/benber86/mamushi Tracker = https://github.com/benber86/mamushi/issues -classifiers = +classifiers = Development Status :: 4 - Beta Environment :: Console Intended Audience :: Developers @@ -71,7 +71,7 @@ classifiers = [bumpversion:part:release] optional_value = release -values = +values = a b release @@ -82,4 +82,4 @@ values = [bumpversion:file:pyproject.toml] search = version = "{current_version}" -replace = version = "{new_version}" \ No newline at end of file +replace = version = "{new_version}" diff --git a/src/mamushi/__version__.py b/src/mamushi/__version__.py index e4b4786..27fdca4 100644 --- a/src/mamushi/__version__.py +++ b/src/mamushi/__version__.py @@ -1 +1 @@ -__version__ = "0.0.2-b0" +__version__ = "0.0.3" diff --git a/src/mamushi/utils/files.py b/src/mamushi/utils/files.py index 282c5b9..9a10bc3 100644 --- a/src/mamushi/utils/files.py +++ b/src/mamushi/utils/files.py @@ -1,7 +1,7 @@ -from typing import Iterator, Optional +from typing import Iterator from pathlib import Path -VYPER_EXTENSIONS = {".vy"} +VYPER_EXTENSIONS = {".vy", ".vyi"} BLACKLISTED_DIRECTORIES = { "build", "buck-out", diff --git a/tests/const.py b/tests/const.py index 1db1ccc..264301e 100644 --- a/tests/const.py +++ b/tests/const.py @@ -3,7 +3,7 @@ THIS_DIR = Path(__file__).parent DATA_DIR = THIS_DIR / "data" PROJECT_ROOT = THIS_DIR.parent -VYPER_SUFFIX = ".vy" +VYPER_SUFFIXES = [".vy", ".vyi"] MINIMAL_CONTRACT = """@external def a(): diff --git a/tests/data/builtins/extcall_staticcall.vy b/tests/data/builtins/extcall_staticcall.vy new file mode 100644 index 0000000..e4027bc --- /dev/null +++ b/tests/data/builtins/extcall_staticcall.vy @@ -0,0 +1,26 @@ +def foo(): + extcall foobar.test1() + +def bar(): + return extcall foobar.test1() + +def foo_two(): + extcall staticcall.test1() + +def bar_two(): + return staticcall foobar.test1() +# output +def foo(): + extcall foobar.test1() + + +def bar(): + return extcall foobar.test1() + + +def foo_two(): + extcall staticcall.test1() + + +def bar_two(): + return staticcall foobar.test1() diff --git a/tests/data/interfaces/interface_blank_lines.vyi b/tests/data/interfaces/interface_blank_lines.vyi new file mode 100644 index 0000000..a212393 --- /dev/null +++ b/tests/data/interfaces/interface_blank_lines.vyi @@ -0,0 +1,14 @@ +@view +@external +def foo(): + + + + + + ... +# output +@view +@external +def foo(): + ... diff --git a/tests/reader.py b/tests/reader.py index 0f427a9..d884627 100644 --- a/tests/reader.py +++ b/tests/reader.py @@ -1,7 +1,7 @@ from pathlib import Path from typing import List, Tuple -from tests.const import DATA_DIR, PROJECT_ROOT, VYPER_SUFFIX +from tests.const import DATA_DIR, PROJECT_ROOT, VYPER_SUFFIXES def get_base_dir(data: bool) -> Path: @@ -20,10 +20,13 @@ def all_data_cases(subdir_name: str, data: bool = True) -> List[str]: def get_case_path(subdir_name: str, name: str, data: bool = True) -> Path: """Get case path from name""" - case_path = get_base_dir(data) / subdir_name / name - case_path = case_path.with_suffix(VYPER_SUFFIX) - assert case_path.is_file(), f"{case_path} is not a file." - return case_path + base_path = get_base_dir(data) / subdir_name / name + + for suffix in VYPER_SUFFIXES: + case_path = base_path.with_suffix(suffix) + if case_path.is_file(): + return case_path + raise FileNotFoundError(f"No .vy or .vyi file found for {base_path}") def read_data(