mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-07-08 23:58:09 +00:00
feat(python): enable pyright-based type checking
This commit is contained in:
parent
1a0b590914
commit
26173c243a
2
Makefile
2
Makefile
@ -29,6 +29,7 @@ pystyle_check: ## run code style check on application sources and tests
|
|||||||
@black --check $(PY_FILES)
|
@black --check $(PY_FILES)
|
||||||
@echo [PYLINT]
|
@echo [PYLINT]
|
||||||
@pylint $(PY_FILES)
|
@pylint $(PY_FILES)
|
||||||
|
@echo [PYTHON]
|
||||||
make -C python style_check
|
make -C python style_check
|
||||||
|
|
||||||
pystyle: ## apply code style on application sources and tests
|
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)
|
@flake8 $(PY_FILES)
|
||||||
@echo [PYLINT]
|
@echo [PYLINT]
|
||||||
@pylint $(PY_FILES)
|
@pylint $(PY_FILES)
|
||||||
|
@echo [PYTHON]
|
||||||
make -C python style
|
make -C python style
|
||||||
|
|
||||||
changelog_check: ## check changelog format
|
changelog_check: ## check changelog format
|
||||||
|
1
python/.changelog.d/1893.added
Normal file
1
python/.changelog.d/1893.added
Normal file
@ -0,0 +1 @@
|
|||||||
|
Full type hinting checkable with pyright
|
@ -49,10 +49,24 @@ style:
|
|||||||
isort --apply --recursive $(STYLE_TARGETS) --skip-glob "$(EXCLUDE_TARGETS)/*"
|
isort --apply --recursive $(STYLE_TARGETS) --skip-glob "$(EXCLUDE_TARGETS)/*"
|
||||||
autoflake -i --remove-all-unused-imports -r $(STYLE_TARGETS) --exclude "$(EXCLUDE_TARGETS)"
|
autoflake -i --remove-all-unused-imports -r $(STYLE_TARGETS) --exclude "$(EXCLUDE_TARGETS)"
|
||||||
flake8
|
flake8
|
||||||
|
pyright
|
||||||
|
|
||||||
style_check:
|
style_check:
|
||||||
black --check $(STYLE_TARGETS)
|
black --check $(STYLE_TARGETS)
|
||||||
isort --check-only --recursive $(STYLE_TARGETS) --skip-glob "$(EXCLUDE_TARGETS)/*"
|
isort --check-only --recursive $(STYLE_TARGETS) --skip-glob "$(EXCLUDE_TARGETS)/*"
|
||||||
flake8
|
flake8
|
||||||
|
pyright
|
||||||
|
|
||||||
.PHONY: all build install clean style style_check git-clean clean-build clean-pyc clean-test
|
.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
12
python/pyrightconfig.json
Normal file
@ -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_first_party=trezorlib
|
||||||
known_third_party=hidapi, rlp, ethjsonrpc, ecdsa, mnemonic, shamir_mnemonic, requests, click, pyblake2, \
|
known_third_party=hidapi, rlp, ethjsonrpc, ecdsa, mnemonic, shamir_mnemonic, requests, click, pyblake2, \
|
||||||
usb, construct, pytest
|
usb, construct, pytest
|
||||||
|
|
||||||
|
[mypy]
|
||||||
|
check_untyped_defs = True
|
||||||
|
show_error_codes = True
|
||||||
|
warn_unreachable = True
|
||||||
|
disable_error_code = import
|
||||||
|
Loading…
Reference in New Issue
Block a user