Repository navigation
Use unasync - #3130
Use unasync#3130karpetrosyan wants to merge 5 commits into
Conversation
|
Oh interesting thanks! If we're using the We don't need to subclass the common parts of the class anymore, we can just replicate them, right? |
Actually yes, but we can probably keep once it's already isolated. |
|
This will break Starlette. |
I guess it will be easy to resolve |
|
Just pimping my own asynkit here, specifically |
|
Please do not merge without a plan or resolution on Starlette's side. |
T-256
left a comment
There was a problem hiding this comment.
Ok, overall, it seems great to me.
It seems we have internal-breaking-change by renaming _client.py file to _clients folder.
Also, I think using USE_CLIENT_DEFAULT instead of None can be counted as breaking change(?) So I think we need minor release for this reason.
And for last thing: Do you have any reason to not use same sync/async files structure as httpcore?
| from ._async_client import * | ||
| from ._sync_client import * |
There was a problem hiding this comment.
Do these really need to be imported all members? I think each of them only needs to expose one member.
| from ._async_client import * | |
| from ._sync_client import * | |
| from ._async_client import AsyncClient | |
| from ._sync_client import Client |
| @@ -43,6 +43,28 @@ class UnsetType: | |||
| pass # pragma: no cover | |||
There was a problem hiding this comment.
Can you please also add docstring here instead of pass like other classes?
There was a problem hiding this comment.
Let's focus on one thing. Little docstring changes could be done in a separate PR ( I guess it's not the only place we could add a docstring to make things more simple ).
There was a problem hiding this comment.
Let's focus on one thing.
+1 to that, yep.
| from ._utils import get_ca_bundle_from_env | ||
|
|
||
| __all__ = ["Limits", "Proxy", "Timeout", "create_ssl_context"] | ||
| __all__ = ["Limits", "Proxy", "Timeout", "create_ssl_context", "USE_CLIENT_DEFAULT"] |
There was a problem hiding this comment.
Why not exposing already implemented UNSET instead of creating new constant?
| pass | ||
|
|
||
|
|
||
| AnyByteStream = Union[SyncByteStream, AsyncByteStream] |
| select = ["E", "F", "I", "B", "PIE"] | ||
| ignore = ["B904", "B028"] | ||
|
|
||
| exclude = ["httpx/_clients/_sync_client.py"] |
There was a problem hiding this comment.
Revealment PR to avoid exvluding on httpcore: encode/httpcore#887
(I'm fine to use it at first step. we can pop it separately)
| ${PREFIX}ruff format $SOURCE_FILES --diff | ||
| ${PREFIX}mypy $SOURCE_FILES | ||
| ${PREFIX}ruff check $SOURCE_FILES | ||
| ${PREFIX}python scripts/unasync.py --check No newline at end of file |
|
|
||
| ${PREFIX}ruff --fix $SOURCE_FILES | ||
| ${PREFIX}ruff format $SOURCE_FILES | ||
| ${PREFIX}python scripts/unasync.py No newline at end of file |
There was a problem hiding this comment.
Is this file formatted?
Perhaps we could also include scripts to $SOURCE_FILES in lint and check.
|
Hi @karpetrosyan - Thanks, and sorry I've been paused and slow to review on this. Have been a bit stuck on it because... I'm not sure it's a great trade-off? Resolves a point of inconsistency that we've bumped into in the past, but it's also a relatively large amount of churn and in this context I think we're maybe making things more complicated, when we could instead aim at getting-reviews-correct on PRs that touch |
Hey! I disagree with you on this point:( I don't think |
No problem, let's go with it then. @T-256 suggested "Do you have any reason to not use same sync/async files structure as httpcore?", which I guess is a valid alternative here, eg...
I've probably got a marginal preference for that, but I don't think it's a blocker. Thoughts? |
|
Yes, that is more in line with our style, but I have run into some problems with the file structure. Some of the tests were developed specifically for |
Ah yeah that figures. Maybe we should start with some test refactoring so that we've got properly mirrored sync/async tests that do have 100% coverage onto the client module. |
Actually, yes. I think we should have started with refactoring the tests. So I think holding this MR for a long time has(?) certain risks. Thoughts? |
|
Closing this for now. We should definitely start with unasync(ing) tests. |
Discussed in: #3046
In order to avoid duplicating code for both the async and sync versions, this PR includes a script that converts certain async sections of the code to sync sections. By doing this, problems like these will be avoided: #3120, #3042
In order to make the review process easier, I chose to divide the massive refactoring into smaller, more manageable pieces. We can unasync client, transport, and tests in separate pull requests.