Skip to content

Conversation

bernhardkaindl
Copy link
Contributor

@bernhardkaindl bernhardkaindl commented Jan 6, 2024

Updates:

  • Add pyproject.toml with config for mypy, black and isort
  • Enable spell checking when pre-commit runs pylint (uses pyenchant)
  • tests/python/conftest.py: Add a pytest fixture for unit-tests
  • tests/python/test_parse_test_instance_string.py: Add an initial unit test for xtf-runner using the pytest fixture.

Updated commit message:

Also enables spell checking when pre-commit runs pylint (uses pyenchant)

- Add pyproject.toml with config for mypy, black and isort
- Add .pre-commit-config.yaml for https://github.com/pre-commit
- Add GitHub action with cache to .github/workflows/build.yml
- Fix execute permissions on files found by pre-commit checks.
- build/mkinfo.py: Add module docstring as requested by pylint.
- tests/python/conftest.py: Add a pytest fixture for unit-tests
- tests/python/test_parse_test_instance_string.py: Add an
    initial unit test for xtf-runner using the pytest fixture.
- xtf-runner:
  - Import json always as Python2.7 is the minium version
  - Add comments to locally disable checks where needed.
  - Resolve a line-too-long while resolving a no-else-return

Signed-off-by: Bernhard Kaindl <bernhard.kaindl@cloud.com>
---
 .github/workflows/build.yml                   |  35 ++++++
 .pre-commit-config.yaml                       | 108 ++++++++++++++++++
 .pylintrc                                     |  40 ++++++-
 .pylintrc.project-dict.txt                    |  45 ++++++++
 build/mkcfg.py                                |   2 +-
 build/mkinfo.py                               |  35 +++++-
 include/xen/sysctl.h                          |   0
 tests/python/conftest.py                      |  53 +++++++++
 .../python/test_parse_test_instance_string.py |  34 ++++++
 xtf-runner                                    |  21 ++--
 10 files changed, 356 insertions(+), 17 deletions(-)
 create mode 100644 .pre-commit-config.yaml
 create mode 100644 .pylintrc.project-dict.txt
 mode change 100644 => 100755 build/mkcfg.py
 mode change 100644 => 100755 build/mkinfo.py
 mode change 100755 => 100644 include/xen/sysctl.h
 create mode 100644 tests/python/conftest.py
 create mode 100644 tests/python/test_parse_test_instance_string.py

This PR is ment as an example, but it may also be taken as-is or used as starting point for more:

Add Python3 pre-commit config checks with pylint and mypy:

  • Add .pre-commit-config.yaml for https://github.com/pre-commit with a quick checks and automatic fixups:
  • Add running the minimal https://pre-commit.com/ GitHub action with setup cache to .github/workflows/build.yml
  • Update .pylintrc to also support passing the latest Python3 pylint checks while tolerating pylint config settings for old Python2-only pylint versions.
  • Add the pylint-checked module docstring to build/mkinfo.py.
  • The pre-commit checks also found that execute permissions on 3 files might be fixed, did so:
    • Changed the mode of the Python scripts which have shebangs: 100644 → 100755
    • include/xen/sysctl.h: 100755 → 100644
  • xtf-runner:
    • Add type: ignore[no-redef] to for Python3 mypy and add a Python2-compatible type comment for mypy.
    • Add pylint: disable comments to locations where appropriate
    • Resolve a line-too-long warning while resolving a no-else-return pylint warning.

@bernhardkaindl bernhardkaindl force-pushed the add-pre-commit-config branch 6 times, most recently from c94bdea to afeba10 Compare January 7, 2024 14:12
Also enables spell checking when pre-commit runs pylint.

- Add pyproject.toml with config for mypy, black and isort
- Add .pre-commit-config.yaml for https://github.com/pre-commit
- Add GitHub action with cache to .github/workflows/build.yml
- Fix execute permissions on files found by pre-commit checks.
- build/mkinfo.py: Add module docstring as requested by pylint.
- tests/python/conftest.py: Add a pytest fixture for unit-tests
- tests/python/test_parse_test_instance_string.py: Add an
    initial unit test for xtf-runner using the pytest fixture.
- xtf-runner:
  - Import json always as Python2.7 is the minium version
  - Add comments to locally disable checks where needed.
  - Resolve a line-too-long while resolving a no-else-return

Signed-off-by: Bernhard Kaindl <[email protected]>
@bernhardkaindl
Copy link
Contributor Author

Superseded by the devel branch and #8

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant