made dependencies on certifi and httpcore only load when required #3377
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
As per #3330 this makes certifi and httpcore only load when required.
For now I haven't done the same with ssl, because SSLContext derives from ssl, which makes it a pain to load on demand. I can make that behind an ImportError guard, with a dummy SSLContext class, but it is a bit hacky. This is what asyncio does. The alterative is dynamically reloading the class and importing ssl on first instantiation (or overriding
__new__
maybe), but again, it is a bit of a hack.Personally I think there isn't a massive overhead to just making ssl a dependency even on platforms where it isn't being used, but I'm easy to go with the dummy class or something if you don't want that; I just worry that code may assume that the dummy SSLContext is a class derived from ssl.SSLContext and bad things will occur.