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

Make client.cookies setter expect a Cookies instance #678

Closed
wants to merge 1 commit into from

Conversation

florimondmanca
Copy link
Member

@florimondmanca florimondmanca commented Dec 21, 2019

Prompted by #677 (comment)

@tomchristie IMO the only thing that does look odd (at least from a typing perspective) is the setter magic, so this PR focuses on that. In particular, not sure we really want to get rid of CookieTypes and change the cookies parameters to prevent using the convenience dict/CookieJar types.

@florimondmanca florimondmanca added the refactor Issues and PRs related to code refactoring label Dec 21, 2019
def cookies(self, cookies: CookieTypes) -> None:
self._cookies = Cookies(cookies)
def cookies(self, cookies: Cookies) -> None:
self._cookies = cookies
Copy link
Member Author

@florimondmanca florimondmanca Dec 21, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tomchristie Would we want to add an assert or any kind of runtime type check here? I'm not sure it's really needed.

Also, this change makes the cookies property equivalent to a simple variable, so we might as well switch it to just that — a plain and public .cookies variable?

@florimondmanca florimondmanca requested a review from a team December 21, 2019 23:11
@tomchristie
Copy link
Member

I think we should probably only do this if we're also doing the same for Headers and Params.
It's very possibly a good thing to do in all cases, but perhaps let's defer that decision for now, and allow the type: ignore on https://github.com/encode/httpx/pull/677/files#diff-2aeaac4c23c1f6bf49dfbd99885a3aa7L108 for the moment.

@florimondmanca
Copy link
Member Author

Closing this one for now to be addressed later with a pass on Headers and Params, then.

@florimondmanca florimondmanca deleted the tweak-cookies-types branch December 23, 2019 09:51
@tomchristie tomchristie mentioned this pull request Jan 6, 2020
10 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
refactor Issues and PRs related to code refactoring
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants