From c968614bae58652900669909bcd56b477c50fc38 Mon Sep 17 00:00:00 2001 From: Thomas Grainger Date: Thu, 8 Jul 2021 21:50:56 +0100 Subject: [PATCH] fix type of FileIO.__init__ opener kwarg (#5738) Co-authored-by: Akuli --- stdlib/io.pyi | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/stdlib/io.pyi b/stdlib/io.pyi index c362a8587..5092d0ee3 100644 --- a/stdlib/io.pyi +++ b/stdlib/io.pyi @@ -1,7 +1,8 @@ import builtins import codecs import sys -from _typeshed import ReadableBuffer, Self, WriteableBuffer +from _typeshed import ReadableBuffer, Self, StrOrBytesPath, WriteableBuffer +from os import _Opener from types import TracebackType from typing import IO, Any, BinaryIO, Callable, Iterable, Iterator, List, Optional, TextIO, Tuple, Type, Union @@ -64,14 +65,9 @@ class BufferedIOBase(IOBase): class FileIO(RawIOBase, BinaryIO): mode: str - # Technically this is whatever is passed in as file, either a str, a bytes, or an int. - name: Union[int, str] # type: ignore + name: StrOrBytesPath | int # type: ignore def __init__( - self, - file: Union[str, bytes, int], - mode: str = ..., - closefd: bool = ..., - opener: Optional[Callable[[Union[int, str], str], int]] = ..., + self, file: StrOrBytesPath | int, mode: str = ..., closefd: bool = ..., opener: _Opener | None = ... ) -> None: ... @property def closefd(self) -> bool: ...