Missing import in wax stub .pyi file, Deprecated functions placed there (?), A tool to verify the stub files during CI
Related: clive@4d9450b5
-
Missing import in wax stub .pyi file -
Deprecated functions placed in the .pyi file -
A tool to verify the stub files during CI
Missing import in wax stub .pyi file
While bumping wax version from 0.0.3a2.dev16+af71c58
to 0.0.3a2.dev39+44db07f
in the clive
repo I encountered the following error messages from one of our code static analysis tools (mypy
)
clive/__private/core/iwax.py:146: error: Returning Any from function declared to return "python_ref_block_data" [no-any-return]
and it resulted these lines (this is `clive` code adding a simple layer around the rough wax interface, so we don't have to encode every time):
def get_tapos_data(block_id: str) -> wax.python_ref_block_data:
return wax.get_tapos_data(block_id.encode()) # <---- this line generated an error
That's because wax.get_tapos_data has a return type hinting of Any
:
When in the wax stub file (wax.pyi) it already has:
This type-hinting does not work because there is an import of python_ref_block_data
missing at the top:
solves the issue. And that probably would be a simple fix.
Deprecated functions placed there (?)
While looking at the wax.pyi I encountered a strange thing - some of the stubs defined there have the "stub for item found icon" like:
Those who don't have it are:
calculate_legacy_transaction_id
calculate_proto_legacy_transaction_id
get_tapos_data
and as I checked it seems to me that:
calculate_proto_legacy_transaction_id
is no longer available in wax. So should be removed. But IDK why:
calculate_legacy_transaction_id
get_tapos_data
also has this icon (maybe something is wrong with them also so IDE notify me about it?)
A tool to verify the stub file during CI
As you can see it's very easy to have a mismatch between stub .pyi
and actual code. In other repositories, we have a lint tool running on the CI like pre-commit
or mypy
. I think it would be very good to spend a moment on this and investigate what could we do to have some checks running on the CI if .pyi
is consistent with the actual code. (Note: as wax.py is a generated code it may be not so obvious, you may need to do this only after installation, IDK)
It may be helpful: