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

Change http.cookie.Morsel to Dict[str, any] #3060

Merged
merged 1 commit into from
Jun 19, 2019

Conversation

FlorianLudwig
Copy link
Contributor

Morsel does cast any value to string and therfor any is the correct
typehint. For some keys other types then strings are more
appropiate anyway, max-age can take an integer (unix time) and http-only
a boolean.

Closes #3059

@@ -7,7 +7,7 @@ _T = TypeVar('_T')

class CookieError(Exception): ...

class Morsel(Dict[str, str], Generic[_T]):
class Morsel(Dict[str, any], Generic[_T]):
Copy link
Member

Choose a reason for hiding this comment

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

Any, not any

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed, thanks.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

also rebased to current master.

Morsel does cast any value to string and therfor any is the correct
typehint. For some keys other types then strings are more
appropiate anyway, max-age can take an integer (unix time) and http-only
a boolean.

Closes python#3059
@asvetlov
Copy link
Contributor

@JelleZijlstra could I ask why TypedDict from mypy_extensions cannot be used here?

@JelleZijlstra
Copy link
Member

Mostly because that wasn't the PR I received, and what was already here seemed like an improvement.

Also, there are no current usages of TypedDict in typeshed, and as long as it lives in mypy_extensions we can't expect it to work in other type checkers. It's going to be moved into typing very soon though.

@asvetlov
Copy link
Contributor

So if I create a PR that uses from typing_extensions import TypedDict would you accept it?
Note, typing_extensions looks more generic that another existing project mypy_extensions.

@JelleZijlstra
Copy link
Member

If it works with typecheckers and passes CI, sure. I think python/mypy#7028 will have to be fixed first though.

@asvetlov
Copy link
Contributor

Aha, I see. Thanks!

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

Successfully merging this pull request may close these issues.

http.cookies.Morsel type for flags should allow for bool
3 participants