Open opoplawski opened 2 weeks ago
Fixing the test_except
error is trivial, I have a commit for that already, but working on the others before sending a PR. The test_curried_namespace
and test_num_required_args
failures are ultimately caused by a CPython bug - sent a fix as https://github.com/python/cpython/pull/120528 . Will look at the test_inspect_wrapped_property
failure now.
The test_inspect_wrapped_property
failure doesn't seem to be Python 3.13 specific; it's also failing in Fedora 39 and Fedora 40 builds, which use Python 3.12.3. The assertion it makes seems odd, actually:
def test_inspect_wrapped_property():
class Wrapped(object):
def __init__(self, func):
self.func = func
def __call__(self, *args, **kwargs):
return self.func(*args, **kwargs)
@property
def __wrapped__(self):
return self.func
func = lambda x: x
wrapped = Wrapped(func)
assert inspect.signature(func) == inspect.signature(wrapped)
assert num_required_args(Wrapped) is None
why should num_required_args(Wrapped)
be None
? Surely the correct answer is 1
, which is the answer we're getting now? If you recreate the test in an interpreter, you can't do Wrapped()
, it errors out:
>>> Wrapped()
Traceback (most recent call last):
File "<python-input-4>", line 1, in <module>
Wrapped()
~~~~~~~^^
TypeError: Wrapped.__init__() missing 1 required positional argument: 'func'
so...my working theory is this changed between Python 3.12.1 (the test passed in this build, which used that version of Python) and 3.12.3, but it's not really a bug. If anything it was broken before. Will dig into it a bit more and decide on a sensible resolution.
edit: Aha, yeah, so this was https://github.com/python/cpython/issues/112006 , fixed in Python 3.11.9 and Python 3.12.3. With an older Python, unwrap(Wrapped)
gives a property object, and inspect.signature(Wrapped)
raises a ValueError
. That sends us down the backup path in _check_sigspec
which tries to get the info out of _signatures.py
, but of course we don't have any info for a made-up wrapper there, so _num_required_args
just returns None
, and that's what we're asserting in this test.
But with fixed Python, unwrap(Wrapped)
gives Wrapped
itself, and inspect.signature(Wrapped)
works, so we get the right answer.
I'll patch the test to expect the appropriate answer for the version of Python it's running on, I guess.
https://github.com/pytoolz/toolz/pull/582 fixes the issues aside from the one caused by https://github.com/python/cpython/pull/120528 , we should not work around that here I don't think, just wait for cpython to be fixed.
Fedora rawhide has updated to Python 3.13b2. toolz tests are failing with:
The test_except error is likely related to:
https://docs.python.org/3.13/whatsnew/3.13.html#other-language-changes
""" Compiler now strip indents from docstrings. This will reduce the size of bytecode cache (e.g. .pyc file). For example, cache file size for sqlalchemy.orm.session in SQLAlchemy 2.0 is reduced by about 5%. This change will affect tools using docstrings, like doctest. """
https://github.com/python/cpython/issues/81283
The spaces before "dispatch" are stripped.