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

pytest 8.1.dev gives {'path'} are declared in the hookimpl but can not be found in the hookspec #11779

Closed
pllim opened this issue Jan 5, 2024 · 4 comments

Comments

@pllim
Copy link
Contributor

pllim commented Jan 5, 2024

Hi. With pytest 8.1.dev , I see this error when collecting plugins in a couple of repos:

{'path'} are declared in the hookimpl but can not be found in the hookspec

This is not a problem even with pytest 8.0rc.

Related issues/comments:

Example logs:

Plugins:

Can you please advise how to fix? Thank you! 🙏

@bluetech
Copy link
Member

bluetech commented Jan 5, 2024

As part of the py.path -> pathlib.Path transition, the py.path hook parameters have been deprecated in the 7.x series, changed to an error in 8.0, and finally removed in 8.1. It seems like the pytest_ignore_collect hook implementation in the pytest_filter_subpackage plugin still uses the deprecated path argument, should use collection_path instead (available since pytest 7.0.0).

If you can require pytest>=7, then can just replace path -> collection_path (and possibly adjust for py.path.local -> Path).

If you still need to support pytest<7, you'll have to do something like the following I'm afraid:

if PYTEST_GTE_7:
   def pytest_ignore_collect(collection_path):
       ...
else:
   def pytest_ignore_collect(path):
       ...

@pllim
Copy link
Contributor Author

pllim commented Jan 6, 2024

Thank you for your prompt response!

@bsipocz
Copy link
Contributor

bsipocz commented Jan 8, 2024

parameters have been deprecated in the 7.x series

@pllim - I wonder why we didn't choke on the deprecation warning

@pllim
Copy link
Contributor Author

pllim commented Jan 8, 2024

Not sure. In doctestplus, look like updates were made to handle things as Path post pytest 7 but we did not change the actual function signature.

gnufede added a commit to DataDog/dd-trace-py that referenced this issue Mar 4, 2024
8R0WNI3 added a commit to gardener/cc-utils that referenced this issue Mar 4, 2024
As part of the upgrade from pytest 8.0.0 -> 8.1.0, a deprecated
function is used, which only emitted a warning before but since
8.1.0 it raises an error upon usage. So, if the usage of this
function is changed in a future pytest release, the hardcoded
version can be removed again ([ref]
(pytest-dev/pytest#11779)).
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

No branches or pull requests

3 participants