-
-
Notifications
You must be signed in to change notification settings - Fork 14
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
make celery a required dependency and the celery extra's optional dependencies #206
Conversation
15f82d9
to
28585a8
Compare
@Nusnus Let me know if |
It appears you’ve edited this PR while I was answering the other issue :) When there’s a final conclusion, we can discuss what is the preferred change. |
28585a8
to
4164b64
Compare
@Nusnus I changed this PR to include only the changes that allow |
Note that after this PR it is enough to do
When you try to use the redis or memcached backends while the celery extra's are not installed you get from pytest_celery import MemcachedContainer
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: cannot import name 'MemcachedContainer' from 'pytest_celery' I guess it would be more informative if this traceback included the Traceback (most recent call last):
File "/home/denolf/projects/pytest-celery/src/pytest_celery/vendors/memcached/__init__.py", line 10, in <module>
import memcache # noqa F401
ModuleNotFoundError: No module named 'memcache'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/denolf/projects/pytest-celery/src/pytest_celery/__init__.py", line 33, in <module>
from pytest_celery.vendors.memcached.api import *
File "/home/denolf/projects/pytest-celery/src/pytest_celery/vendors/memcached/__init__.py", line 12, in <module>
raise MissingCeleryDependency("celery extra dependency missing: celery[pymemcache]")
pytest_celery.vendors.MissingCeleryDependency: celery extra dependency missing: celery[pymemcache]
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: cannot import name 'MemcachedContainer' from 'pytest_celery' Not sure how to achieve this though. |
I tried to find a better name for |
4164b64
to
8afec66
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #206 +/- ##
==========================================
- Coverage 28.01% 25.75% -2.26%
==========================================
Files 36 39 +3
Lines 1053 1087 +34
Branches 213 215 +2
==========================================
- Hits 295 280 -15
- Misses 730 781 +51
+ Partials 28 26 -2 ☔ View full report in Codecov by Sentry. |
The modifications in #172 can cause issues like #205.
When installing
pytest-redis
withoutcelery[redis,pymemcache]
, pytest becomes unusable because the pytest plugin system causespytest-redis
to be imported, which in turn importscelery
,redis
andmemcache
.For example
We could make
celery
an optional dependency ofpytest-redis
but I doubt this is meaningful. What is meaningful is to make the celery extra's optional:celery[redis]
andcelery[pymemcache]
.That's what I tried to do in this MR by making the
memcached
andredis
vendor modules optional. I would like to do thisBut I cannot figure out how to do this in
poetry
(I believe python-poetry/poetry-core#613 is needed for that). For now I did thisbut this means we are managing the
redis
andpython-memcached
version limits ourselves which is not what we want.Edit: python-poetry/poetry-core#613 (comment) shows that there is a way to do it in poetry