diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index ad8f66f099701a09666a01a93748789f35d50a52..7b6d35b671c973d11c527bf575ced52da1260558 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -6,16 +6,27 @@ # (tba) # ============================================================================== - -variables: - PYTHON_VERSION: "3.13" - UV_VERSION: "0.5.2" - BASE_LAYER: "alpine" +workflow: + rules: + - if: $CI_PIPELINE_SOURCE != "merge_request_event" include: - - component: $CI_SERVER_FQDN/blackstream-x/python-uv-components/python-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-mypy-args: "--with-requirements requirements.txt --with types-pyyaml" - uv-pylint-args: "--with-requirements requirements.txt" - pylint-args: "--disable fixme" + module-name: morast + do-uv-sync: true + uv-version: "0.5.18" + 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 + - pre-build + - build + - upload diff --git a/docs/assets/concepts-mindmap.mermaid b/docs/assets/concepts-mindmap.mermaid new file mode 100644 index 0000000000000000000000000000000000000000..79257552f7ab46a01413339d92e51ab2c123afde --- /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 7804bd0f85406b73196f370935a1787dd32cb12a..660e63c2fe3c330eebca95a2e7494a7d55e8deda 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 diff --git a/mkdocs.yml b/mkdocs.yml index 74174151638da2b8af09b25cc424c23d9a6fef63..438555c113b03522fee997c6266a4b9376920c78 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 77adc10e1dd089195d7695b65c6946c8f19ad2bf..dbb0d6affb89763bb92440bc2a598e9f23064b2f 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/src/morast/core.py b/src/morast/core.py index a758a5322835377167c13fcbc8a47282537d33ef..d9614ec67d13dd2f6da86beee8beb5f581263dc4 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}", } @@ -860,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( @@ -965,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 6878c039da7af629b53588e8e3a4e6d543103161..833e82a99ab65dbfd2368cc0a5d0c37d0d73e305 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) @@ -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!") # diff --git a/tools/mkdocs-serve.sh b/tools/mkdocs-serve.sh new file mode 100755 index 0000000000000000000000000000000000000000..68392d38ab81f094e229d9dc057ba5c9f34f65d6 --- /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 0000000000000000000000000000000000000000..5816834d613706580900046094be7527067cbd3c --- /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 0000000000000000000000000000000000000000..ce7924738fe97b5fd0a65a031f207914cae90808 --- /dev/null +++ b/tools/mypy.sh @@ -0,0 +1 @@ +uvx --with-requirements pyproject.toml --with types-pyyaml mypy . diff --git a/tools/pylint.sh b/tools/pylint.sh new file mode 100755 index 0000000000000000000000000000000000000000..b20622796db83034d2f3ea62307e1c1317a9b496 --- /dev/null +++ b/tools/pylint.sh @@ -0,0 +1 @@ +uvx --with-requirements pyproject.toml pylint src tests diff --git a/tools/pytest.sh b/tools/pytest.sh new file mode 100755 index 0000000000000000000000000000000000000000..232da383eca00b1e06421441c56e1f83216a999c --- /dev/null +++ b/tools/pytest.sh @@ -0,0 +1 @@ +uvx --with-editable . --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 0000000000000000000000000000000000000000..eafab4928356bff386e7fc882532e567a0726fc7 --- /dev/null +++ b/tools/ruff.sh @@ -0,0 +1,2 @@ +uvx ruff check +uvx ruff format --check || ruff format --diff