Open charlesbmi opened 8 months ago
The SonarCloud Quality Gate passed, but some issues were introduced.
13 New issues
0 Security Hotspots
No data about Coverage
No data about Duplication
File "/usr/lib/python3.11/site-packages/nptyping/typing_.py", line 87, in <module>
Float = np.float_
^^^^^^^^^
File "/usr/lib/python3.11/site-packages/numpy/__init__.py", line 397, in __getattr__
raise AttributeError(
AttributeError: `np.float_` was removed in the NumPy 2.0 release. Use `np.float64` instead.. Did you mean: 'float16'?
Just tested this PR and test suite fail
+ PYTHONPATH=/home/tkloczko/rpmbuild/BUILDROOT/python-nptyping-2.5.0-2.fc37.x86_64/usr/lib64/python3.10/site-packages:/home/tkloczko/rpmbuild/BUILDROOT/python-nptyping-2.5.0-2.fc37.x86_64/usr/lib/python3.10/site-packages
+ /usr/bin/pytest -ra -m 'not network' --ignore tests/test_package_info.py
==================================================================================== test session starts ====================================================================================
platform linux -- Python 3.10.14, pytest-8.2.1, pluggy-1.5.0
rootdir: /home/tkloczko/rpmbuild/BUILD/nptyping-2.5.0
plugins: mock-3.14.0, typeguard-4.2.1
collected 106 items / 1 error
========================================================================================== ERRORS ===========================================================================================
__________________________________________________________________________ ERROR collecting tests/test_beartype.py __________________________________________________________________________
tests/test_beartype.py:14: in <module>
def fun(_: NDArray[Shape["2, 2"], Float]) -> None:
/usr/lib/python3.10/site-packages/beartype/_decor/decorcache.py:77: in beartype
return beartype_object(obj, conf)
/usr/lib/python3.10/site-packages/beartype/_decor/decorcore.py:87: in beartype_object
_beartype_object_fatal(obj, conf=conf, **kwargs)
/usr/lib/python3.10/site-packages/beartype/_decor/decorcore.py:136: in _beartype_object_fatal
beartype_nontype(obj, **kwargs) # type: ignore[return-value]
/usr/lib/python3.10/site-packages/beartype/_decor/_decornontype.py:182: in beartype_nontype
return beartype_func(obj, **kwargs) # type: ignore[return-value]
/usr/lib/python3.10/site-packages/beartype/_decor/_decornontype.py:247: in beartype_func
func_wrapper_code = generate_code(bear_call)
/usr/lib/python3.10/site-packages/beartype/_decor/wrap/wrapmain.py:118: in generate_code
code_check_params = _code_check_args(bear_call)
/usr/lib/python3.10/site-packages/beartype/_decor/wrap/_wrapargs.py:334: in code_check_args
reraise_exception_placeholder(
/usr/lib/python3.10/site-packages/beartype/_util/error/utilerrraise.py:138: in reraise_exception_placeholder
raise exception.with_traceback(exception.__traceback__)
/usr/lib/python3.10/site-packages/beartype/_decor/wrap/_wrapargs.py:189: in code_check_args
hint = sanify_hint_root_func(
/usr/lib/python3.10/site-packages/beartype/_check/convert/convsanify.py:178: in sanify_hint_root_func
hint = reduce_hint(
/usr/lib/python3.10/site-packages/beartype/_check/convert/convreduce.py:201: in reduce_hint
hint = _reduce_hint_uncached(
/usr/lib/python3.10/site-packages/beartype/_check/convert/convreduce.py:280: in _reduce_hint_uncached
hint_sign = get_hint_pep_sign_or_none(hint)
/usr/lib/python3.10/site-packages/beartype/_util/cache/utilcachecall.py:250: in _callable_cached
raise exception
/usr/lib/python3.10/site-packages/beartype/_util/cache/utilcachecall.py:242: in _callable_cached
return_value = args_flat_to_return_value[args_flat] = func(
/usr/lib/python3.10/site-packages/beartype/_util/hint/pep/utilpepget.py:721: in get_hint_pep_sign_or_none
die_if_hint_pep604_inconsistent(hint)
/usr/lib/python3.10/site-packages/beartype/_util/hint/pep/proposal/utilpep604.py:73: in die_if_hint_pep604_inconsistent
raise BeartypeDecorHintPep604Exception(
E beartype.roar.BeartypeDecorHintPep604Exception: Type hint NDArray[Shape['2, 2'], Float] inconsistent with respect to repr() strings. Since @beartype requires consistency between type hints and repr() strings, this hint is unsupported by @beartype. Consider reporting this issue to the third-party developer implementing this hint: e.g.,
E >>> repr(NDArray[Shape['2, 2'], Float])
E NDArray[Shape['2, 2'], Float] # <-- this is fine
E >>> repr(NDArray[Shape['2, 2'], Float] | int)
E nptyping.ndarray.NDArray | int # <-- *THIS IS REALLY SUPER BAD*
E
E # Ideally, that output should instead resemble:
E >>> repr(NDArray[Shape['2, 2'], Float] | int)
E NDArray[Shape['2, 2'], Float] | int # <-- what @beartype wants!
===================================================================================== warnings summary ======================================================================================
../../../../../usr/lib64/python3.10/unittest/loader.py:66
/usr/lib64/python3.10/unittest/loader.py:66: PytestCollectionWarning: cannot collect test class 'TestLoader' because it has a __init__ constructor (from: tests/test_wheel.py)
class TestLoader(object):
-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
================================================================================== short test summary info ==================================================================================
ERROR tests/test_beartype.py - beartype.roar.BeartypeDecorHintPep604Exception: Type hint NDArray[Shape['2, 2'], Float] inconsistent with respect to repr() strings. Since @beartype requires consistency between type h...
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
================================================================================ 1 warning, 1 error in 0.76s ================================================================================
After add tests/test_beartype.py to --ignore list many units fails because missing pandas-stubs
.
Q: why test suite is not able to use regular pandas
? 🤔
Now that numpy2.0.0 is out, all those numpy deprecations are now raising exceptions, so it would be great if this PR could be merged as a first step toward compatibility with the new numpy. On my fork I made a few additional changes that numpy recommends via their ruff rule, so we could PR my fork as well: https://github.com/jasper-tms/nptyping/commit/efc78eb26886e59a303a280466c4837e1671890f
Attempt to fix:
Which error out because of deprecation of
int0
,object0
, etc. types