Skip to content

[aiofiles] Narrow NamedTemporaryFile.name to str or bytes - #16770

Open
sumit-2007-git wants to merge 1 commit into
python:mainfrom
sumit-2007-git:fix/aiofiles-named-tempfile-name
Open

sumit-2007-git wants to merge 1 commit into
python:mainfrom
sumit-2007-git:fix/aiofiles-named-tempfile-name

Conversation

@sumit-2007-git

Copy link
Copy Markdown

Makes _UnknownAsyncTextIO, _UnknownAsyncBinaryIO, and their wrapper subclasses generic over _NameT_co (bound=FileDescriptorOrPath, default=FileDescriptorOrPath) so callers like aiofiles.open keep FileDescriptorOrPath by default while aiofiles.tempfile.NamedTemporaryFile preserves str or bytes for .name:

  • Calls with str / StrPath / omitted suffix, prefix, and dir return ...[str]
  • Calls with bytes / BytesPath suffix, prefix, or dir return ...[bytes]
  • Mixed or union str | bytes path/prefix/suffix arguments fall back to ...[str | bytes]

Fixes #13551.

@github-actions

Copy link
Copy Markdown
Contributor

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

This branch has not been deployed

No deployments
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