-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[python] Typeguard not running as intended #2238
Comments
Thanks to #1116 (comment), my main mistake was thinking typeguard ran as part of a This (correctly) fails on my repro branch (#2239): pre-commit run -v --files src/tiledbsoma/_sparse_nd_array.py
|
run_lint: ${{ matrix.python-version == '3.10' }} |
but the build matrix only includes 3.8 and 3.11:
python-version: ['3.8', '3.11'] |
Looks like this was inadvertent, when upgrading to 3.12 in February: 798ad5c.
I'll work on a PR restoring that, cc @johnkerl. (Update: #2247)
* update pre-merge checks to run lint cf. #2238 (comment) * pre-commit fixes
#2239 has a repro of typeguard failing to raise on non-test code with intentionally broken types.
I believe the issue is, in this block:
TileDB-SOMA/apis/python/tests/__init__.py
Lines 4 to 7 in 83bfd00
Line 5 is inadvertently importing ≈all of
tiledbsoma
(it executestiledbsoma/__init__.py
, which imports most things) before the typeguard hook is initialized, meaning ≈nothing is being checked by typeguard.I suspect this has been the case since that line was added, in #496 (Nov '22).
Attempting to restore Typeguard checks
When I comment out the
_query_condition
line, typeguard raises in anypytest
command that executestiledbsoma/__init__.py
, e.g.:Full stack trace
The culprit seems to be a
@_funcs.forwards_kwargs_to
annotation in_collection.py
:TileDB-SOMA/apis/python/src/tiledbsoma/_collection.py
Lines 245 to 250 in 83bfd00
Adding
@typeguard_ignore
to theforwards_kwargs_to
declaration didn't help, nor did adding it to the@_funcs.forwards_kwargs_to
invocation above.Open to discussion re: selectively ignoring/fixing problem cases, more explicitly enabling typeguard for known-compliant modules, etc.
The text was updated successfully, but these errors were encountered: