From 16d30254c46662c0a372acd82595569143e6ae85 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Tue, 21 Nov 2023 16:49:32 +0100 Subject: [PATCH] tox,osbuild: deal with stages that have external json data Some existing code/test assumes that anything in `stages/` is executable. This commit fixes this and excludes e.g. json from lintables. --- .ruff.toml | 5 +++++ osbuild/meta.py | 8 +++++--- tox.ini | 9 +++++---- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/.ruff.toml b/.ruff.toml index 20122a7a..93de212f 100644 --- a/.ruff.toml +++ b/.ruff.toml @@ -25,5 +25,10 @@ ignore = [ "PLW2901", # pylint: redefined loop variable ] +extend-exclude = [ + "*.json", +] +force-exclude = true + [format] quote-style = "preserve" diff --git a/osbuild/meta.py b/osbuild/meta.py index 56e401c6..ea4ee1b6 100644 --- a/osbuild/meta.py +++ b/osbuild/meta.py @@ -465,6 +465,8 @@ class ModuleInfo: docstring = ast.get_docstring(tree) doclist = docstring.split("\n") if docstring else [] + summary = doclist[0] if len(doclist) > 0 else "" + long_description = "\n".join(doclist[1:]) if len(doclist) > 0 else "" assigns = filter_type(tree.body, ast.Assign) values = { @@ -485,8 +487,8 @@ class ModuleInfo: "1": parse_schema(values.get("SCHEMA")), "2": parse_schema(values.get("SCHEMA_2")), }, - 'desc': doclist[0], - 'info': "\n".join(doclist[1:]), + 'desc': summary, + 'info': long_description, 'caps': parse_caps(values.get("CAPABILITIES")) } return cls(klass, name, path, info) @@ -616,7 +618,7 @@ class Index: raise ValueError(f"Unsupported nodule class: {klass}") path = os.path.join(self.path, module_path) - modules = filter(lambda f: os.path.isfile(f"{path}/{f}"), + modules = filter(lambda f: os.path.isfile(f"{path}/{f}") and not path.endswith("-meta.json"), os.listdir(path)) return list(modules) diff --git a/tox.ini b/tox.ini index 90b1f586..dbaf7a94 100644 --- a/tox.ini +++ b/tox.ini @@ -22,10 +22,11 @@ deps = pykickstart # required by pykickstart but not pulled in automatically :/ requests - tox-backticks setenv = - LINTABLES = osbuild/ assemblers/* devices/* inputs/*.* mounts/* runners/* sources/*.* stages/*.* inputs/test/*.py stages/test/*.py sources/test/*.py test/ `find ./tools ! -name "*.sh" -type f` + LINTABLES = osbuild/ assemblers/* devices/* inputs/*.* mounts/* runners/* sources/*.* stages/*.* inputs/test/*.py stages/test/*.py sources/test/*.py test/ tools/ + LINTABLES_EXCLUDES = "*.json,*.sh" + LINTABLES_EXCLUDES_RE = ".*\.json$,.*\.sh" TYPEABLES = osbuild TYPEABLES_STRICT = ./osbuild/main_cli.py @@ -51,14 +52,14 @@ deps = pycodestyle==2.11.0 commands = - bash -c 'python -m autopep8 --diff --max-line-length 120 -a -a -a -j0 -r --exit-code {env:LINTABLES}' + bash -c 'python -m autopep8 --diff --max-line-length 120 -a -a -a -j0 -r --exclude {env:LINTABLES_EXCLUDES} --exit-code {env:LINTABLES}' [testenv:pylint] deps = pylint==3.0.2 commands = - bash -c 'python -m pylint {env:LINTABLES}' + bash -c 'python -m pylint --ignore-patterns {env:LINTABLES_EXCLUDES_RE} {env:LINTABLES}' [testenv:mypy] deps =