From 229484230ab5a4beb30cb787e6bf5cd8ffc09c8d Mon Sep 17 00:00:00 2001 From: blackstream-x Date: Sat, 16 Nov 2024 13:32:44 +0100 Subject: [PATCH 01/13] Add uvx based tool calls (#40) --- mkdocs.yml | 2 +- src/morast/__init__.py | 2 +- tools/mkdocs-serve.sh | 1 + tools/morast.sh | 1 + tools/mypy.sh | 1 + tools/pylint.sh | 2 ++ tools/pytest.sh | 1 + tools/ruff.sh | 2 ++ 8 files changed, 10 insertions(+), 2 deletions(-) create mode 100755 tools/mkdocs-serve.sh create mode 100755 tools/morast.sh create mode 100755 tools/mypy.sh create mode 100755 tools/pylint.sh create mode 100755 tools/pytest.sh create mode 100755 tools/ruff.sh diff --git a/mkdocs.yml b/mkdocs.yml index 7417415..438555c 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: !ENV CI_PROJECT_TITLE +site_name: !ENV [CI_PROJECT_TITLE, "morast local dev snapshot"] site_dir: public site_url: !ENV CI_PAGES_URL site_description: !ENV CI_PROJECT_DESCRIPTION diff --git a/src/morast/__init__.py b/src/morast/__init__.py index 77adc10..dbb0d6a 100644 --- a/src/morast/__init__.py +++ b/src/morast/__init__.py @@ -21,7 +21,7 @@ See the LICENSE file for more details. """ -__version__ = "0.3.5" +__version__ = "0.4.0" # vim: fileencoding=utf-8 ts=4 sts=4 sw=4 autoindent expandtab syntax=python: diff --git a/tools/mkdocs-serve.sh b/tools/mkdocs-serve.sh new file mode 100755 index 0000000..68392d3 --- /dev/null +++ b/tools/mkdocs-serve.sh @@ -0,0 +1 @@ +uvx --with mkdocs-material mkdocs serve diff --git a/tools/morast.sh b/tools/morast.sh new file mode 100755 index 0000000..5816834 --- /dev/null +++ b/tools/morast.sh @@ -0,0 +1 @@ +uvx morast auto diff --git a/tools/mypy.sh b/tools/mypy.sh new file mode 100755 index 0000000..3647284 --- /dev/null +++ b/tools/mypy.sh @@ -0,0 +1 @@ +uvx --with types-pyyaml --with smdg mypy . diff --git a/tools/pylint.sh b/tools/pylint.sh new file mode 100755 index 0000000..101c980 --- /dev/null +++ b/tools/pylint.sh @@ -0,0 +1,2 @@ +PYTHONPATH=src uvx --with smdg pylint tests +uvx --with smdg --with pyyaml pylint src diff --git a/tools/pytest.sh b/tools/pytest.sh new file mode 100755 index 0000000..1ec368e --- /dev/null +++ b/tools/pytest.sh @@ -0,0 +1 @@ +PYTHONPATH=src uvx --with smdg --with pyyaml --with pytest-cov pytest --cov src --cov tests --cov-report term-missing tests diff --git a/tools/ruff.sh b/tools/ruff.sh new file mode 100755 index 0000000..eafab49 --- /dev/null +++ b/tools/ruff.sh @@ -0,0 +1,2 @@ +uvx ruff check +uvx ruff format --check || ruff format --diff -- GitLab From 5c36e75fe6e8c17458963b5bd2c62fd7588f5dab Mon Sep 17 00:00:00 2001 From: blackstream-x Date: Mon, 18 Nov 2024 18:24:27 +0100 Subject: [PATCH 02/13] Improve uvx based tooling --- tools/mypy.sh | 2 +- tools/pylint.sh | 3 +-- tools/pytest.sh | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/tools/mypy.sh b/tools/mypy.sh index 3647284..ce79247 100755 --- a/tools/mypy.sh +++ b/tools/mypy.sh @@ -1 +1 @@ -uvx --with types-pyyaml --with smdg mypy . +uvx --with-requirements pyproject.toml --with types-pyyaml mypy . diff --git a/tools/pylint.sh b/tools/pylint.sh index 101c980..b206227 100755 --- a/tools/pylint.sh +++ b/tools/pylint.sh @@ -1,2 +1 @@ -PYTHONPATH=src uvx --with smdg pylint tests -uvx --with smdg --with pyyaml pylint src +uvx --with-requirements pyproject.toml pylint src tests diff --git a/tools/pytest.sh b/tools/pytest.sh index 1ec368e..232da38 100755 --- a/tools/pytest.sh +++ b/tools/pytest.sh @@ -1 +1 @@ -PYTHONPATH=src uvx --with smdg --with pyyaml --with pytest-cov pytest --cov src --cov tests --cov-report term-missing tests +uvx --with-editable . --with pytest-cov pytest --cov=src --cov=tests --cov-report term-missing tests -- GitLab From 21b459e8d6ef1264ed0cf48dfb1eb05a57e65691 Mon Sep 17 00:00:00 2001 From: blackstream-x Date: Mon, 18 Nov 2024 20:36:28 +0100 Subject: [PATCH 03/13] change --with-requirements --- .gitlab-ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index ad8f66f..c7aef2e 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -16,6 +16,6 @@ variables: include: - component: $CI_SERVER_FQDN/blackstream-x/python-uv-components/python-uv@main inputs: - uv-mypy-args: "--with-requirements requirements.txt --with types-pyyaml" - uv-pylint-args: "--with-requirements requirements.txt" + uv-mypy-args: "--with-requirements pyproject.toml --with types-pyyaml" + uv-pylint-args: "--with-requirements pyproject.toml" pylint-args: "--disable fixme" -- GitLab From 2a6c3773d51f678774784283045eaaa7fcc12002 Mon Sep 17 00:00:00 2001 From: blackstream-x Date: Mon, 18 Nov 2024 20:45:20 +0100 Subject: [PATCH 04/13] let pylint report --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index c7aef2e..afaa46a 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -18,4 +18,4 @@ include: inputs: uv-mypy-args: "--with-requirements pyproject.toml --with types-pyyaml" uv-pylint-args: "--with-requirements pyproject.toml" - pylint-args: "--disable fixme" + pylint-args: "--disable=fixme --report" -- GitLab From ca21c8f9cb2cfd6061f0916593c371092b10768d Mon Sep 17 00:00:00 2001 From: Rainer Schwarzbach Date: Mon, 18 Nov 2024 19:47:00 +0000 Subject: [PATCH 05/13] fix pylint argument --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index afaa46a..c679e95 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -18,4 +18,4 @@ include: inputs: uv-mypy-args: "--with-requirements pyproject.toml --with types-pyyaml" uv-pylint-args: "--with-requirements pyproject.toml" - pylint-args: "--disable=fixme --report" + pylint-args: "--disable=fixme --report=yes" -- GitLab From 47fed29279cb84436a2b0330d52a2c0e7077554f Mon Sep 17 00:00:00 2001 From: Rainer Schwarzbach Date: Tue, 19 Nov 2024 07:03:25 +0000 Subject: [PATCH 06/13] Reflect component changes --- .gitlab-ci.yml | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index c679e95..1ed37d5 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -7,15 +7,16 @@ # ============================================================================== -variables: - PYTHON_VERSION: "3.13" - UV_VERSION: "0.5.2" - BASE_LAYER: "alpine" - - include: - - component: $CI_SERVER_FQDN/blackstream-x/python-uv-components/python-uv@main + - component: $CI_SERVER_FQDN/blackstream-x/python-uv-components/uv@main inputs: - uv-mypy-args: "--with-requirements pyproject.toml --with types-pyyaml" - uv-pylint-args: "--with-requirements pyproject.toml" + uv-version: "0.5.2" + python-version: "3.13" + python-variant: "alpine" + uvx-args-mypy: "--with-requirements pyproject.toml --with types-pyyaml" pylint-args: "--disable=fixme --report=yes" + + +stages: + - codestyle + - test -- GitLab From aaceb72e09f80998e2affced29a653e474e2f4df Mon Sep 17 00:00:00 2001 From: Rainer Schwarzbach Date: Tue, 19 Nov 2024 07:08:49 +0000 Subject: [PATCH 07/13] Reflect components project name change --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 1ed37d5..f5ef6f5 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -8,7 +8,7 @@ include: - - component: $CI_SERVER_FQDN/blackstream-x/python-uv-components/uv@main + - component: $CI_SERVER_FQDN/blackstream-x/python-components/uv@main inputs: uv-version: "0.5.2" python-version: "3.13" -- GitLab From eabe17ee6f31b637714bafa88188aec2606abd9c Mon Sep 17 00:00:00 2001 From: Rainer Schwarzbach Date: Sun, 12 Jan 2025 13:55:59 +0000 Subject: [PATCH 08/13] use full python components pipeline --- .gitlab-ci.yml | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index f5ef6f5..3536a31 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -8,9 +8,11 @@ include: - - component: $CI_SERVER_FQDN/blackstream-x/python-components/uv@main + - component: $CI_SERVER_FQDN/blackstream-x/generic-components/meta-gitlab-security@~latest + - component: $CI_SERVER_FQDN/blackstream-x/python-components/meta-uv-pipeline@main inputs: - uv-version: "0.5.2" + module-name: morast + uv-version: "0.5.18" python-version: "3.13" python-variant: "alpine" uvx-args-mypy: "--with-requirements pyproject.toml --with types-pyyaml" @@ -20,3 +22,7 @@ include: stages: - codestyle - test + - build + - pre-build + - build + - upload -- GitLab From 80e28ec74ee8786825f9a306a1863f45f5224d6a Mon Sep 17 00:00:00 2001 From: Rainer Schwarzbach Date: Sun, 12 Jan 2025 13:58:50 +0000 Subject: [PATCH 09/13] do uv sync; do not run for merge request pipelines --- .gitlab-ci.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 3536a31..9a20120 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -6,12 +6,17 @@ # (tba) # ============================================================================== +workflow: + rules: + - if: $CI_PIPELINE_SOURCE != "merge_request" + include: - component: $CI_SERVER_FQDN/blackstream-x/generic-components/meta-gitlab-security@~latest - component: $CI_SERVER_FQDN/blackstream-x/python-components/meta-uv-pipeline@main inputs: module-name: morast + do-uv-sync: true uv-version: "0.5.18" python-version: "3.13" python-variant: "alpine" -- GitLab From 22cdbc7d049afd227f3dc555af4ba6154ce94faa Mon Sep 17 00:00:00 2001 From: blackstream-x Date: Sun, 12 Jan 2025 15:02:42 +0100 Subject: [PATCH 10/13] Reformat --- .gitlab-ci.yml | 2 +- src/morast/core.py | 5 ++--- src/morast/nodes.py | 4 ++-- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 9a20120..789b1d2 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -8,7 +8,7 @@ workflow: rules: - - if: $CI_PIPELINE_SOURCE != "merge_request" + - if: $CI_PIPELINE_SOURCE != "merge_request_event" include: diff --git a/src/morast/core.py b/src/morast/core.py index a758a53..9280de5 100644 --- a/src/morast/core.py +++ b/src/morast/core.py @@ -248,8 +248,7 @@ class MorastDocumentableItem: """Check for self.is_ignored""" if self.is_ignored: raise IgnoredItemError( - f"{self.namespace}: ignored {self.name!r} as specified" - " through override" + f"{self.namespace}: ignored {self.name!r} as specified through override" ) # return False @@ -398,7 +397,7 @@ class MorastAttribute(MorastBaseAttribute): raise ValueError(f"scope must be one of {self.supported_scopes!r}") # prefix_by_scope: Dict[str, str] = { - SCOPE_CLASS: f"{superconfig.emoji.class_attributes_prefix}" f" {namespace}", + SCOPE_CLASS: f"{superconfig.emoji.class_attributes_prefix} {namespace}", SCOPE_INSTANCE: f"{superconfig.emoji.instance_attributes_prefix} ", SCOPE_MODULE: f"{superconfig.emoji.constants_prefix} {namespace}", } diff --git a/src/morast/nodes.py b/src/morast/nodes.py index 6878c03..bb393ab 100644 --- a/src/morast/nodes.py +++ b/src/morast/nodes.py @@ -243,7 +243,7 @@ def get_node(element: Union[str, ast.AST]) -> "MorastBaseNode": # lineno = getattr(element, LINENO, UNKNOWN) return MorastErrorNode( - f"Source line {lineno}:" f" {ast.dump(element)} not implemented yet" + f"Source line {lineno}: {ast.dump(element)} not implemented yet" ) @@ -693,7 +693,7 @@ class MorastDictItem(MorastBaseNode): if isinstance(self._key, MorastBaseNode) and isinstance( self._value, MorastBaseNode ): - return f"{self._key.plain_display()}:" f" {self._value.plain_display()}" + return f"{self._key.plain_display()}: {self._value.plain_display()}" # if isinstance(self._kwarg, MorastBaseNode): return str(self._kwarg) -- GitLab From d2cb0e531e7f3ae66ab03e1fe0741ab9ed7470aa Mon Sep 17 00:00:00 2001 From: blackstream-x Date: Sun, 12 Jan 2025 15:06:31 +0100 Subject: [PATCH 11/13] Fix stages sequence --- .gitlab-ci.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 789b1d2..7b6d35b 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -27,7 +27,6 @@ include: stages: - codestyle - test - - build - pre-build - build - upload -- GitLab From 8c64c171cfd98ffccb4a0684040ecd1aaf5fcf9c Mon Sep 17 00:00:00 2001 From: blackstream-x Date: Sun, 12 Jan 2025 15:31:07 +0100 Subject: [PATCH 12/13] Improve mindmap image --- docs/assets/concepts-mindmap.mermaid | 21 +++++++++++++++++++++ docs/assets/concepts-mindmap.png | 4 ++-- 2 files changed, 23 insertions(+), 2 deletions(-) create mode 100644 docs/assets/concepts-mindmap.mermaid diff --git a/docs/assets/concepts-mindmap.mermaid b/docs/assets/concepts-mindmap.mermaid new file mode 100644 index 0000000..7925755 --- /dev/null +++ b/docs/assets/concepts-mindmap.mermaid @@ -0,0 +1,21 @@ +mindmap + root(Reference) + ::icon(fab fa-markdown) + Source package + ::icon(fab fa-python) + Module + Module + Module + Overwrites + ::icon(fab fa-markdown) + Docstring replacements + Additions + Ignores + Strip value + Configuration + ::icon(fa fa-gear) + Emoji + Source path + Overwrites path + Target path + diff --git a/docs/assets/concepts-mindmap.png b/docs/assets/concepts-mindmap.png index 7804bd0..660e63c 100644 --- a/docs/assets/concepts-mindmap.png +++ b/docs/assets/concepts-mindmap.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:ce4a903e73040350188b15a0564d41f6be471dc791fc387f53567c56ed34fee9 -size 241557 +oid sha256:9b72b1f8c64195cd63b475c049c9a8a4ca39136d7185df50144103654f70e872 +size 66355 -- GitLab From f1166f8aad5892d0a327a2a15edeaac55a4c9a59 Mon Sep 17 00:00:00 2001 From: blackstream-x Date: Sun, 19 Jan 2025 18:42:42 +0100 Subject: [PATCH 13/13] Prepare docstring offset autodetection --- src/morast/core.py | 10 ++++++++++ src/morast/nodes.py | 1 + 2 files changed, 11 insertions(+) diff --git a/src/morast/core.py b/src/morast/core.py index 9280de5..d9614ec 100644 --- a/src/morast/core.py +++ b/src/morast/core.py @@ -859,6 +859,11 @@ class MorastFunctionDef(MorastSection): self.check_private() for sub_element in element.body: if isinstance(sub_element, ast.Expr): + logging.warning( + "Function %r docstring col_offset: %s", + self.name, + sub_element.col_offset, + ) if isinstance(sub_element.value, ast.Constant): # self.docstring = sub_element.value.value self.docstring = nodes.remove_hanging_indent( @@ -964,6 +969,11 @@ class MorastClassDef(MorastSection): self._init_docstring: str = commons.EMPTY for sub_element in element.body: if isinstance(sub_element, ast.Expr): + logging.warning( + "Class %r docstring col_offset: %s", + self.name, + sub_element.col_offset, + ) if isinstance(sub_element.value, ast.Constant): self.docstring = nodes.remove_hanging_indent( sub_element.value.value.strip(), diff --git a/src/morast/nodes.py b/src/morast/nodes.py index bb393ab..833e82a 100644 --- a/src/morast/nodes.py +++ b/src/morast/nodes.py @@ -1078,6 +1078,7 @@ class DocString(MorastBaseNode): content = expression elif isinstance(expression.value, ast.Constant): content = expression.value.value + logging.warning("Docstring col offset: %s", expression.col_offset) else: raise ValueError("Must be a constant expression!") # -- GitLab