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

Allow derived classes for str and tuple in WSGI validator #93637

Open
calimeroteknik opened this issue Jun 9, 2022 · 0 comments
Open

Allow derived classes for str and tuple in WSGI validator #93637

calimeroteknik opened this issue Jun 9, 2022 · 0 comments
Labels
type-feature

Comments

@calimeroteknik
Copy link

@calimeroteknik calimeroteknik commented Jun 9, 2022

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.

@calimeroteknik calimeroteknik added the type-feature label Jun 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-feature
Projects
None yet
Development

No branches or pull requests

1 participant