Skip to content

Fix aiofiles NamedTemporaryFile name type#15970

Closed
ishaanlabs-gg wants to merge 1 commit into
python:mainfrom
ishaanlabs-gg:aiofiles-namedtemporaryfile-name-str
Closed

Fix aiofiles NamedTemporaryFile name type#15970
ishaanlabs-gg wants to merge 1 commit into
python:mainfrom
ishaanlabs-gg:aiofiles-namedtemporaryfile-name-str

Conversation

@ishaanlabs-gg

Copy link
Copy Markdown

Fixes #13551.

aiofiles.tempfile.NamedTemporaryFile() always creates a named temporary file, so its async file object exposes name as a string path. The generic aiofiles async file wrappers still keep the broader FileDescriptorOrPath type for other call sites, but the NamedTemporaryFile() overloads now return named wrapper variants that narrow name to str.

Validation:

  • /Volumes/STOREJET/2/Dependencies/typeshed-venv/bin/python tests/regr_test.py aiofiles --python-version 3.13 --verbosity NORMAL
  • /Volumes/STOREJET/2/Dependencies/typeshed-venv/bin/python tests/mypy_test.py stubs/aiofiles --python-version 3.13
  • /Volumes/STOREJET/2/Dependencies/typeshed-venv/bin/python tests/check_typeshed_structure.py
  • NPM_CONFIG_CACHE=/Volumes/STOREJET/Documents/OSC/repos/typeshed-aiofiles-name/.npm-cache /Volumes/STOREJET/2/Dependencies/typeshed-venv/bin/python tests/pyright_test.py stubs/aiofiles/aiofiles/tempfile/__init__.pyi
  • git diff --check

@github-actions

github-actions Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[aiofiles] aiofiles.tempfile.NamedTemporaryFile.name should probably be a str

1 participant