1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2025-01-11 16:00:57 +00:00

feat(python): enable pyright-based type checking

This commit is contained in:
grdddj 2021-11-26 14:18:30 +01:00 committed by matejcik
parent 1a0b590914
commit 26173c243a
5 changed files with 35 additions and 0 deletions

View File

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

View File

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

View File

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

12
python/pyrightconfig.json Normal file
View File

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

View File

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