Skip to content
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 3.8: DeprecationWarning: Use inspect.signature() instead of inspect.getfullargspec() #209

Closed
hroncok opened this issue May 9, 2019 · 8 comments · Fixed by #210
Closed
Assignees

Comments

@hroncok
Copy link
Member

hroncok commented May 9, 2019

A lot of Fedora packages, when rebuilt with Python 3.8.0a4 fail to collect tests with pytest:

+ /usr/bin/python3 -m pytest -v --pyargs numpy -k 'not big_arrays and not large_archive and not test_highest_available_pickle_protocol and not test_binomial and not test_hypergeometric and not test_scalar_exception_propagation'
============================= test session starts ==============================
platform linux -- Python 3.8.0a4, pytest-4.4.1, py-1.8.0, pluggy-0.9.0 -- /usr/bin/python3
cachedir: .pytest_cache
rootdir: /builddir/build/BUILD/numpy-1.16.3, inifile: pytest.ini
collecting ... collected 0 items / 1 errors

==================================== ERRORS ====================================
________________________ ERROR collecting test session _________________________
/usr/lib/python3.8/site-packages/_pytest/config/__init__.py:435: in _importconftest
    return self._conftestpath2mod[conftestpath]
E   KeyError: local('/builddir/build/BUILDROOT/numpy-1.16.3-2.fc31.x86_64/usr/lib64/python3.8/site-packages/numpy/conftest.py')

During handling of the above exception, another exception occurred:
/usr/lib/python3.8/site-packages/pluggy/manager.py:95: in register
    hookimpl = HookImpl(plugin, plugin_name, method, hookimpl_opts)
/usr/lib/python3.8/site-packages/pluggy/hooks.py:344: in __init__
    self.argnames, self.kwargnames = varnames(self.function)
/usr/lib/python3.8/site-packages/pluggy/hooks.py:167: in varnames
    spec = _getargspec(func)
/usr/lib/python3.8/site-packages/pluggy/hooks.py:130: in _getargspec
    return inspect.getfullargspec(func)
/usr/lib64/python3.8/inspect.py:1114: in getfullargspec
    warnings.warn("Use inspect.signature() instead of inspect.getfullargspec()",
E   DeprecationWarning: Use inspect.signature() instead of inspect.getfullargspec()
!!!!!!!!!!!!!!!!!!! Interrupted: 1 errors during collection !!!!!!!!!!!!!!!!!!!!
=========================== 1 error in 0.26 seconds ============================

Now I don't know if treating this DeprecationWarning as error is the default pytest behavior or specific projects (mis)configuration, but the warning comes from pluggy. We still have 0.9.0, but I see getfullargspec() even in master.

@nicoddemus
Copy link
Member

Hi @hroncok,

Thanks for the report!

I think we should update pluggy to not use the deprecated function in Python 3.8.

@nicoddemus nicoddemus self-assigned this May 10, 2019
@hroncok
Copy link
Member Author

hroncok commented May 10, 2019

I agree. Any idea if it is pluggy, pytest or the tested project that handles the DeprecationWarning as an error?

@nicoddemus
Copy link
Member

It should be the project itself which configures this.

@hroncok
Copy link
Member Author

hroncok commented May 10, 2019

Thanks for clarifying.

@tirkarthi
Copy link

This was done as part of PEP 570 implementation in commit python/cpython@d5d2b454693 in alpha 4. There is a discussion in CPython about reverting the deprecation marked as release blocker for Python 3.8 beta 1 : https://bugs.python.org/issue36751#msg342156

@hroncok
Copy link
Member Author

hroncok commented May 13, 2019

The discussion seems ongoing. I'd say that migrating to inspect.signature() is still a good way to go.

@hroncok
Copy link
Member Author

hroncok commented May 13, 2019

This is the stuff that pluggy currently uses:

signature = inspect.signature(func)
args = tuple(signature.parameters)
defaults = tuple(param.default for param in signature.parameters.values() if param.default is not inspect.Parameter.empty)

@hroncok
Copy link
Member Author

hroncok commented May 13, 2019

@nicoddemus You've assigned this to yourself. I'll try to test the above code and submit a PR if it works. Let me know if you are already in the middle of the same.

hroncok added a commit to hroncok/pluggy that referenced this issue May 13, 2019
Avoids a possible deprecation warning with inspect.getfullargspec()

Fixes pytest-dev#209
hroncok added a commit to hroncok/pluggy that referenced this issue May 14, 2019
nicoddemus added a commit to nicoddemus/pluggy that referenced this issue May 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants