Wrong type for hdrs in urllib.error.HTTPError
Open
Nobody has claimed this yet.
stubs: false positive
- Dominant language
- Python
- Stars
- 5.1k
- Forks
- 2.1k
- Avg merge
- 1d 19h
- Merged PRs (30d)
- 82
Description
Example code code.py:
import urllib.error
raise urllib.error.HTTPError("https://example.com/", 502, "Bad Gateway", hdrs={}, fp=None)
mypy complains:
code.py:2: error: Argument "hdrs" to "HTTPError" has incompatible type "Dict[<nothing>, <nothing>]"; expected "Message" [arg-type]
Looking at the Python stdlib code, hdrs is always a dict[str, str].
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 urllib.error.HTTPError stub and inspect the hdrs parameter annotation against the stdlib behavior described in the issue. Use the provided code.py example with mypy to verify that passing a dictionary no longer produces the incompatible-type error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100