Skip to content

Commit

Permalink
Add pyright as a pre-commit check
Browse files Browse the repository at this point in the history
Another pair of eyes, pyright is a type check plus a bit more, and will
inspect the code from slightyl different point of view. As a result, it
will report issues mypy cannot spot, or cannot spot *yet* because the
set of implemented checks is simply different.

The slow, gradual approach is the key here, like the one we know from
mypy introduction, and slowly files and packages will get covered.
  • Loading branch information
happz committed Jun 23, 2023
1 parent 1ca5e37 commit 50da395
Show file tree
Hide file tree
Showing 4 changed files with 97 additions and 0 deletions.
19 changes: 19 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,25 @@ repos:
pass_filenames: false
args: [--config-file=pyproject.toml]

- repo: https://github.com/RobertCraigie/pyright-python
rev: v1.1.310
hooks:
- id: pyright
# TODO: find out how to amend pyright, pre-commit and package requirements.
# Apparently, there is no easy way to avoid some level of duplication of
# information when the package is *not* installed, which is the case of tmt
# & pre-commit in our setup.
additional_dependencies:
- 'fmf>=1.2.1'
- 'click'
- 'requests'
- 'urllib3'
- 'ruamel.yaml'
- 'jinja2'
- 'setuptools'
- 'typing-extensions>=3.7.4.3'
- importlib_metadata

- repo: https://github.com/python-jsonschema/check-jsonschema
rev: "0.23.1"
hooks:
Expand Down
69 changes: 69 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,75 @@ module = [
]
ignore_missing_imports = true

[tool.pyright]
include = [
# "bin/tmt",
"tmt/__init__.py",
"tmt/result.py",
# "tmt/__main__.py",
# "tmt/queue.py",
# "tmt/base.py",
# "tmt/log.py",
# "tmt/lint.py",
# "tmt/identifier.py",
# "tmt/utils.py",
# "tmt/options.py",
# "tmt/libraries/__init__.py",
# "tmt/libraries/beakerlib.py",
# "tmt/libraries/file.py",
# "tmt/convert.py",
# "tmt/cli.py",
# "tmt/plugins/__init__.py",
# "tmt/steps/__init__.py",
# "tmt/steps/discover/__init__.py",
# "tmt/steps/discover/shell.py",
# "tmt/steps/discover/fmf.py",
# "tmt/steps/finish/__init__.py",
# "tmt/steps/finish/ansible.py",
# "tmt/steps/finish/shell.py",
# "tmt/steps/prepare/__init__.py",
# "tmt/steps/prepare/ansible.py",
# "tmt/steps/prepare/shell.py",
# "tmt/steps/prepare/install.py",
# "tmt/steps/provision/__init__.py",
# "tmt/steps/provision/connect.py",
# "tmt/steps/provision/artemis.py",
# "tmt/steps/provision/local.py",
# "tmt/steps/provision/mrack.py",
# "tmt/steps/provision/testcloud.py",
# "tmt/steps/provision/podman.py",
# "tmt/steps/execute/__init__.py",
# "tmt/steps/execute/upgrade.py",
# "tmt/steps/execute/internal.py",
# "tmt/steps/report/__init__.py",
# "tmt/steps/report/html.py",
# "tmt/steps/report/display.py",
# "tmt/steps/report/junit.py",
# "tmt/steps/report/reportportal.py",
# "tmt/steps/report/polarion.py",
# "tmt/export/__init__.py",
# "tmt/export/template.py",
# "tmt/export/_dict.py",
# "tmt/export/nitrate.py",
# "tmt/export/_json.py",
# "tmt/export/yaml.py",
# "tmt/export/rst.py",
# "tmt/export/polarion.py",
# "tmt/templates.py",
"setup.py"
]
ignore = [
"docs/**",
"examples/**",
"tests/**",
# "tmt/**"
]

pythonVersion = "3.6"
pythonPlatform = "Linux"

typeCheckingMode = "strict"

[tool.autopep8]
max_line_length = 99
in-place = true
Expand Down
8 changes: 8 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,14 @@
__desc__ = 'Test Management Tool'
__scripts__ = ['bin/tmt']

# TODO: find out how to amend pyright, pre-commit and package requirements.
# Apparently, there is no easy way to avoid some level of duplication of
# information when the package is *not* installed, which is the case of tmt
# & pre-commit in our setup.
#
# For now, requirements are also listed in `.pre-commit-config.yaml` which
# is just ugly...

# Prepare install requires and extra requires
install_requires = [
'fmf>=1.2.1',
Expand Down
1 change: 1 addition & 0 deletions tmt/result.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import click
import fmf
import fmf.utils

import tmt.utils
from tmt.utils import Path, field
Expand Down

0 comments on commit 50da395

Please sign in to comment.