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 May 27, 2023
1 parent 5e70c85 commit 823855c
Show file tree
Hide file tree
Showing 3 changed files with 44 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 @@ -37,6 +37,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.22.0"
hooks:
Expand Down
17 changes: 17 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,23 @@ module = [
]
ignore_missing_imports = true

[tool.pyright]
include = [
"bin/tmt",
"setup.py"
]
ignore = [
"docs/**",
"examples/**",
"tests/**",
"tmt/**"
]

pythonVersion = "3.7"
pythonPlatform = "Linux"

typeCheckingMode = "strict"

# code is currently formatted with default isort config
#[tool.isort]
#line_length = 99
Expand Down
8 changes: 8 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,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

0 comments on commit 823855c

Please sign in to comment.