1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-22 15:38:11 +00:00
trezor-firmware/tools/trezor-pylint-plugin
matejcik 43677c6afd style(core): add check for utils.INTERNAL_MODEL in (tuple)
The static replacer doesn't understand tuples (it's just a dumb sed,
we'd need to teach it the python ast which is a somewhat bigger project
that would also make the build slower)
so instead we spell out every "utils.INTERNAL_MODEL == xyz" equality
check separately.

If you don't, you don't get static replacement and you're checking at
run-time in every firmware for every device.

This pylint will catch the problem.
2024-08-29 10:56:21 +02:00
..
.gitignore feat: custom Pylint plugin 2023-11-30 09:27:57 +01:00
pyproject.toml feat: custom Pylint plugin 2023-11-30 09:27:57 +01:00
README.md feat: custom Pylint plugin 2023-11-30 09:27:57 +01:00
trezor_pylint_plugin.py style(core): add check for utils.INTERNAL_MODEL in (tuple) 2024-08-29 10:56:21 +02:00

Custom Pylint rule checker

For now, it catches the following problem (async-awaitable-return):

async def show_foo() -> Awaitable[None]:
    return show_something("foo")

This is almost certainly a mistake -- the caller would need to say await (await show_foo()) to actually show the foo.

The function should be one of:

async def show_foo() -> None:
    return await show_something("foo")

# ... or ...

def show_foo() -> Awaitable[None]:
    return show_something("foo")