Skip to content

Declare http.cookies.SimpleCookie as non generic(?) #10700

Closed
@flaeppe

Description

@flaeppe

I'm a bit confused as to why http.cookies.SimpleCookie is declared as a generic class and not like below?

class SimpleCookie(BaseCookie[str]):
    ...

The documentation on SimpleCookie only talks about strings:

class http.cookies.SimpleCookie([input])
This class derives from BaseCookie and overrides value_decode() and value_encode(). SimpleCookie supports strings as cookie values. When setting the value, SimpleCookie calls the builtin str() to convert the value to a string. Values received from HTTP are kept as strings.

And from what I'm seeing, implementations value_decode and value_encode for SimpleCookie only produces strings (but perhaps I'm missing something)?

Ref: https://github.com/python/cpython/blob/1ee50e2a78f644d81d341a08562073ad169d8cc7/Lib/http/cookies.py#L607-L612

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions