-
Notifications
You must be signed in to change notification settings - Fork 124
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
Troubles to understand the new updates on Pluggy #468
Comments
The basic gist is that before we didn't check if the function was an actual generator, So a normal function that returned one would work by accident With the introduction of new style wrappers however validation was added The easiest fix is to switch from return to That changes the function from a normal one that returns a generator into a generator function |
Thanks for reporting the changelog errors, will be fixed by #470. |
I found what was causing the issue on my side. I implemented everything as specified in the documentation, but my plugin is not able to make the condition: not inspect.isgeneratorfunction(hookimpl.function) be not (True) And then not throw the Should I proceed with my investigation here or open a new issue? I believe I can collect more info in the next weeks. If I find some time I can also contribute to it. |
Just to be clear, you're saying that when you cythonize a generator function, |
I will take a closer look at that today. But yes, the |
Seems like there is an issue in Cython about it: cython/cython#4888 I think adding some Cython-specific workaround would be fine, but I'm hesitant to drop the check entirely due to a Cython bug. |
Hi, I have paid attention to and explored this issue, and here I would like to share some of my findings. CauseFollowing the cythonization process, the sequence
return a Reproducedocker run --rm -it python:3.10.5-alpine sh -c "pip install pytest-result-log==1.2.2.dev0 && pytest" Occurrencepython <= 3.10.5 ResolutionThe issue has been addressed in the upstream Python repository: https://github.com/python/cpython/pull/94461/files if not (isfunction(f) or _signature_is_functionlike(f)): It is recommended to update Python to versions released after August 1, 2022, such as:
Verify// docker-compose.yaml
services:
python310:
image: python:3.10.6-alpine
command: sh -c "pip install pytest-result-log==1.2.2.dev0 && pytest "
working_dir: /app
python311:
image: python:3.11.0-alpine
command: sh -c "pip install pytest-result-log==1.2.2.dev0 && pytest "
working_dir: /app
python312:
image: python:3.12.0-alpine
command: sh -c "pip install pytest-result-log==1.2.2.dev0 && pytest "
working_dir: /app For older versions of Python, can also achieve a similar effect by using monkey patching to modify |
I wrote an issue on Cython Github page here, regarding the quoting:
|
So, I finished the discussion with the Cython devs (link), and has nothing that they can do. Possible solutions are to pluggy changes how to inspect those generators when they are Cythonized, or we just assume that the problem exists and is known for some older Python versions. We can also use the insights published in this quote. |
we can work around a old cpython bug within reason |
Yeah, I will wait until we deprecate support for Python 3.8, and use these newest Python versions of 3.9, 3.10, and 3.11 to cythonize our API. The question is if pluggy will work in older versions of the Python distributions when the pytest plugins are cythonized in a newer one. I don't think so but I can try that in a few days. |
Hi everybody.
I am having issues updating my pytest plugin after
pluggy==1.0.0
updates. Accordingly, with the documentation all the hooks decorated withhookwrapper=True
need to be written as a generator because, without this, it would cause an error later. In my application, the hook wrappers were always a generator but thePluginValidationError
is still being thrown. I isolated the if statement (Code snippet 1) for that Error and my hook wrapper passes, but not in the pluggy (on.\py38\lib\site-packages\pluggy\_manager.py
file) implementation which always falls on the exception:Also, the changelog for the version 1.0.0 is very confusing. First, the exception name is
PluginValidationError
and notPluggyValidationError
as is written there. Second is that the example to properly make the changes has functions that are not used and others that have no reference in the documentation for it (Code snippet 2).I considered in this example that
my_hook_real_implementation
is the functionmy_hook_implementation
but still my hook wrap falls in the same exception.I comment the Code Snippet 1 in my enviroment with the same version of Pluggy and the execution happened with no errors.
I don`t know what is needed to fix this issue on my side, maybe a more explanatory example could be provided or maybe pluggy needs updates.
Let me know which more data is needed or what I can do it to help. Since my plugin code is from the repository of the company that I work, I didn`t provided the source code here but we can arrange some way to get more data and a reproduceable example.
The text was updated successfully, but these errors were encountered: