-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Closed
Description
The type declaration for http.cookies.Morsel is based on Dict[str, str] and therefor the following code is treated as a type error:
m = http.cookies.Morsel()
m['httponly'] = True
The implementation explicitly allows for max-age and expires to be integers as well:
https://github.com/python/cpython/blob/159ae24895272dce5fd53dd8e54809743e4f394f/Lib/http/cookies.py#L407
I would have liked to directly open a pull request but I am not sure what the right way to fix it is:
- Generally all attributes can be set to any type as they are cast to strings anyway so
Dict[str, any]does reflect the implementation fine. - A
TypedDictdefining all possible keys with their intended options would have to be somewhat opinionated, for examplem['path']=1is okay from the implementation point of view ofMorselbut probably is not intended.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels