From b82ffc2873f7e4e91f4e1417087d2ccf9976c8c2 Mon Sep 17 00:00:00 2001 From: Amin Alaee Date: Fri, 22 Sep 2023 18:14:41 +0200 Subject: [PATCH] Update os.path.isdir on Windows Python3.12+ --- stdlib/ntpath.pyi | 10 ++++++++-- tests/stubtest_allowlists/win32-py312.txt | 2 -- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/stdlib/ntpath.pyi b/stdlib/ntpath.pyi index 1a58b52de050..6852924fa2de 100644 --- a/stdlib/ntpath.pyi +++ b/stdlib/ntpath.pyi @@ -1,5 +1,5 @@ import sys -from _typeshed import BytesPath, StrPath +from _typeshed import BytesPath, FileDescriptorOrPath, StrPath from genericpath import ( commonprefix as commonprefix, exists as exists, @@ -7,7 +7,6 @@ from genericpath import ( getctime as getctime, getmtime as getmtime, getsize as getsize, - isdir as isdir, isfile as isfile, samefile as samefile, sameopenfile as sameopenfile, @@ -45,6 +44,13 @@ from posixpath import ( if sys.version_info >= (3, 12): from posixpath import isjunction as isjunction, splitroot as splitroot + +if sys.version_info >= (3, 12) and sys.platform == "win32": + def isdir(path: FileDescriptorOrPath) -> bool: ... + +else: + def isdir(s: FileDescriptorOrPath) -> bool: ... + from typing import AnyStr, overload from typing_extensions import LiteralString diff --git a/tests/stubtest_allowlists/win32-py312.txt b/tests/stubtest_allowlists/win32-py312.txt index e3377eb16bfa..55fff5eb0413 100644 --- a/tests/stubtest_allowlists/win32-py312.txt +++ b/tests/stubtest_allowlists/win32-py312.txt @@ -4,5 +4,3 @@ asyncio.IocpProactor.recvfrom_into asyncio.windows_events.IocpProactor.finish_socket_func asyncio.windows_events.IocpProactor.recvfrom_into msvcrt.GetErrorMode -ntpath.isdir -os.path.isdir