Allow derived classes for str and tuple in WSGI validator
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 77.2k
- Forks
- 36k
- PR merge metrics
- PR metrics pending
Description
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.
Linked PRs
- gh-93640
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the WSGI validator entry point and inspect linked PR gh-93640 before beginning, since the issue indicates related work elsewhere. Confirm whether the validator accepts subclasses of str and tuple[str, str] while preserving its current rejection behavior; done means the intended derived header classes are accepted and the existing validator behavior remains covered.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100