feat(python): enable pyright-based type checking

pull/1953/head
grdddj 2 years ago committed by matejcik
parent 1a0b590914
commit 26173c243a

@ -29,6 +29,7 @@ pystyle_check: ## run code style check on application sources and tests
@black --check $(PY_FILES)
@echo [PYLINT]
@pylint $(PY_FILES)
@echo [PYTHON]
make -C python style_check
pystyle: ## apply code style on application sources and tests
@ -42,6 +43,7 @@ pystyle: ## apply code style on application sources and tests
@flake8 $(PY_FILES)
@echo [PYLINT]
@pylint $(PY_FILES)
@echo [PYTHON]
make -C python style
changelog_check: ## check changelog format

@ -0,0 +1 @@
Full type hinting checkable with pyright

@ -49,10 +49,24 @@ style:
isort --apply --recursive $(STYLE_TARGETS) --skip-glob "$(EXCLUDE_TARGETS)/*"
autoflake -i --remove-all-unused-imports -r $(STYLE_TARGETS) --exclude "$(EXCLUDE_TARGETS)"
flake8
pyright
style_check:
black --check $(STYLE_TARGETS)
isort --check-only --recursive $(STYLE_TARGETS) --skip-glob "$(EXCLUDE_TARGETS)/*"
flake8
pyright
.PHONY: all build install clean style style_check git-clean clean-build clean-pyc clean-test
test:
pytest tests
mypy:
mypy --config-file ./setup.cfg ./src/trezorlib/
mypy_report:
mypy --config-file ./setup.cfg ./src/trezorlib/ --html-report mypy_report
pyright:
pyright -p pyrightconfig.json

@ -0,0 +1,12 @@
{
"include": [
"src/trezorlib",
"tools",
"helper-scripts"
],
"typeCheckingMode": "basic",
"reportMissingImports": false,
"reportUntypedFunctionDecorator": true,
"reportUntypedClassDecorator": true,
"reportMissingParameterType": true
}

@ -37,3 +37,9 @@ not_skip=__init__.py
known_first_party=trezorlib
known_third_party=hidapi, rlp, ethjsonrpc, ecdsa, mnemonic, shamir_mnemonic, requests, click, pyblake2, \
usb, construct, pytest
[mypy]
check_untyped_defs = True
show_error_codes = True
warn_unreachable = True
disable_error_code = import

Loading…
Cancel
Save