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

Support for requests-cache #156

Closed
glensc opened this issue Oct 20, 2024 · 3 comments
Closed

Support for requests-cache #156

glensc opened this issue Oct 20, 2024 · 3 comments

Comments

@glensc
Copy link

glensc commented Oct 20, 2024

I thought to give niquests a try, but I realized I'm using requests cache.

How would you use niquests and projects that extends requests?

I fired the same question to requests-cache repo as well:

@glensc
Copy link
Author

glensc commented Oct 20, 2024

perhaps should just override sys.modules?

@Ousret
Copy link
Member

Ousret commented Oct 21, 2024

You have two options.

First, following https://niquests.readthedocs.io/en/latest/community/recommended.html#requests-cache
Inherit CacheMixin with our Session.
The solution isn't perfect, but it work flawlessly.

Second, you may override Requests using sys.module (via https://niquests.readthedocs.io/en/latest/dev/migrate.html#maintainer-migration) only if you are not a library but an executable standalone.
To avoid forcing other non tested library to switch.

Almost every requests extension are compatible using methods described in our docs.

Regards,

@Ousret Ousret closed this as completed Oct 21, 2024
@glensc
Copy link
Author

glensc commented Oct 21, 2024

The import trick doesn't work:

  File "lib/python3.9/site-packages/trakt/core.py", line 17, in <module>
    from requests_oauthlib import OAuth2Session
  File "python-3.9/lib/python3.9/site-packages/requests_oauthlib/__init__.py", line 13, in <module>
    if requests.__version__ < "2.0.0":
TypeError: '<' not supported between instances of 'module' and 'str'

That package had other non-compatible imports as well:

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

2 participants