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.
This commit is contained in:
Michael Vogt 2023-11-21 16:49:32 +01:00 committed by Simon de Vlieger
parent 9b09ed9eb4
commit 16d30254c4
3 changed files with 15 additions and 7 deletions

View file

@ -25,5 +25,10 @@ ignore = [
"PLW2901", # pylint: redefined loop variable
]
extend-exclude = [
"*.json",
]
force-exclude = true
[format]
quote-style = "preserve"

View file

@ -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)

View file

@ -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 =