`tempfile.NamedTemporaryFile`'s return type (`_TemporaryFileWrapper`) has any attribute
Open
Nobody has claimed this yet.
topic: io
- Dominant language
- Python
- Stars
- 5.1k
- Forks
- 2.1k
- Avg merge
- 1d 19h
- Merged PRs (30d)
- 82
Description
import tempfile
with tempfile.NamedTemporaryFile() as file:
reveal_type(file) # tempfile._TemporaryFileWrapper[builtins.bytes]
file.asdfasdf # no error
tested with both mypy and pyright
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 inspecting the typeshed stub for tempfile.NamedTemporaryFile and reproduce the shown snippet with mypy and pyright. Trace how _TemporaryFileWrapper is typed, then verify that an unknown attribute is rejected while the existing context-manager and return-type behavior remains correct.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100