The WSGI validator could allow anything that inherits from tuple[str, str] for the headers, instead of literally just tuple[str, str] and nothing else.
Pitch
This is so I can use classes that extend str and tuple[str, str] as headers.
Symbolic types that add essentially nothing but a pretty constructor and type checks avoid silly mistakes by encoding intent.
Previous discussion
On IRC I was told about contravariance. https://peps.python.org/pep-0484/#covariance-and-contravariance
I think it might be fine, because no matter which class extending its type I will feed it, it's never coming back, so there is no risk of an item of a less precise type bubbling up to the caller somehow.
The text was updated successfully, but these errors were encountered:
Feature or enhancement
The WSGI validator could allow anything that inherits from tuple[str, str] for the headers, instead of literally just tuple[str, str] and nothing else.
Pitch
This is so I can use classes that extend str and tuple[str, str] as headers.
Symbolic types that add essentially nothing but a pretty constructor and type checks avoid silly mistakes by encoding intent.
Previous discussion
On IRC I was told about contravariance. https://peps.python.org/pep-0484/#covariance-and-contravariance
I think it might be fine, because no matter which class extending its type I will feed it, it's never coming back, so there is no risk of an item of a less precise type bubbling up to the caller somehow.
The text was updated successfully, but these errors were encountered: