Skip to content

Type-check test_cookies.py - #677

Merged
florimondmanca merged 1 commit into
masterfrom
typed-cookies-tests
Dec 23, 2019
Merged

florimondmanca merged 1 commit into
masterfrom
typed-cookies-tests

Conversation

@florimondmanca

Copy link
Copy Markdown
Contributor

More tests type-checking, refs #650.

@florimondmanca florimondmanca added the tooling Changes to our CI/CD, tests setup, etc. label Dec 21, 2019

client = Client(dispatch=MockDispatch())
client.cookies = cookies
client.cookies = cookies # type: ignore

@florimondmanca florimondmanca Dec 21, 2019 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

mypy doesn't yet support setters that accept arguments of a different type than what is returned by the getter. The official recommandation is to # type: ignore for now. See: python/mypy#3004

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Hrm. Well, it is a strange usage. Got me thinking that maybe we just shouldn鈥檛 be doing that in the first place...

Instead, we could enforce this style:

client.cookies = httpx.Cookies(...)

That鈥檚 possibly less surprising than setting the cookies to a dict, but having it return a Cookies instance.

We would probably want to hard check the type.

Obvs same would apply to the other setters too.

Thoughts?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yup, sure, that would sound good to me. :-)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

-> #678

@lovelydinosaur lovelydinosaur left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good. Going to suggest that we defer a decision on client.cookies, client.headers, client.params setters at this point in time.

@florimondmanca
florimondmanca merged commit 0ee0005 into master Dec 23, 2019
@florimondmanca
florimondmanca deleted the typed-cookies-tests branch December 23, 2019 09:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

tooling Changes to our CI/CD, tests setup, etc.

Development

Successfully merging this pull request may close these issues.

2 participants