From 75487db12e77d6ef2cca49794458a7f582288a5b Mon Sep 17 00:00:00 2001 From: Maxwell Muoto <41130755+max-muoto@users.noreply.github.com> Date: Mon, 22 Jul 2024 19:54:54 -0500 Subject: [PATCH 1/5] Add missing constants --- .../@tests/stubtest_allowlists/darwin-py313.txt | 6 ------ stdlib/fcntl.pyi | 16 ++++++++++++---- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/stdlib/@tests/stubtest_allowlists/darwin-py313.txt b/stdlib/@tests/stubtest_allowlists/darwin-py313.txt index 379bff8b73e7..10dc9fd43085 100644 --- a/stdlib/@tests/stubtest_allowlists/darwin-py313.txt +++ b/stdlib/@tests/stubtest_allowlists/darwin-py313.txt @@ -1,10 +1,4 @@ # new in py313 -fcntl.F_GETNOSIGPIPE -fcntl.F_OFD_GETLK -fcntl.F_OFD_SETLK -fcntl.F_OFD_SETLKW -fcntl.F_RDAHEAD -fcntl.F_SETNOSIGPIPE posixpath.splitroot # TODO: fix diff --git a/stdlib/fcntl.pyi b/stdlib/fcntl.pyi index b7995be750e5..74def8bbe5ba 100644 --- a/stdlib/fcntl.pyi +++ b/stdlib/fcntl.pyi @@ -43,10 +43,6 @@ if sys.platform != "win32": F_SEAL_SEAL: int F_SEAL_SHRINK: int F_SEAL_WRITE: int - if sys.version_info >= (3, 9): - F_OFD_GETLK: int - F_OFD_SETLK: int - F_OFD_SETLKW: int if sys.version_info >= (3, 10): F_GETPIPE_SZ: int F_SETPIPE_SZ: int @@ -123,6 +119,18 @@ if sys.platform != "win32": RWH_WRITE_LIFE_LONG: Final = 4 RWH_WRITE_LIFE_EXTREME: Final = 5 + if (sys.version_info >= (3, 9) and sys.platform == "linux") or (sys.version_info >= (3, 11) and sys.platform == "darwin"): + F_OFD_GETLK: Final[int] + F_OFD_SETLK: Final[int] + F_OFD_SETLKW: Final[int] + + if sys.version_info >= (3, 13) and sys.platform != "linux": + # OSx and NetBSD + F_GETNOSIGPIPE: Final[int] + F_SETNOSIGPIPE: Final[int] + # OSx and FreeBSD + F_RDAHEAD: Final[int] + @overload def fcntl(fd: FileDescriptorLike, cmd: int, arg: int = 0, /) -> int: ... @overload From a0e45c286eeee8291613d3781e7b9f5c9dc6459f Mon Sep 17 00:00:00 2001 From: Maxwell Muoto <41130755+max-muoto@users.noreply.github.com> Date: Mon, 22 Jul 2024 19:59:08 -0500 Subject: [PATCH 2/5] Fix --- stdlib/fcntl.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stdlib/fcntl.pyi b/stdlib/fcntl.pyi index 74def8bbe5ba..6c28d6848f37 100644 --- a/stdlib/fcntl.pyi +++ b/stdlib/fcntl.pyi @@ -119,7 +119,7 @@ if sys.platform != "win32": RWH_WRITE_LIFE_LONG: Final = 4 RWH_WRITE_LIFE_EXTREME: Final = 5 - if (sys.version_info >= (3, 9) and sys.platform == "linux") or (sys.version_info >= (3, 11) and sys.platform == "darwin"): + if (sys.version_info >= (3, 9) and sys.platform == "linux") or (sys.version_info >= (3, 13) and sys.platform == "darwin"): F_OFD_GETLK: Final[int] F_OFD_SETLK: Final[int] F_OFD_SETLKW: Final[int] From 587fa6eb409b9f4cfe51c5c5de986f5928cb4fa6 Mon Sep 17 00:00:00 2001 From: Maxwell Muoto <41130755+max-muoto@users.noreply.github.com> Date: Mon, 22 Jul 2024 20:02:31 -0500 Subject: [PATCH 3/5] Fixes --- stdlib/fcntl.pyi | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/stdlib/fcntl.pyi b/stdlib/fcntl.pyi index 6c28d6848f37..d7a285b77085 100644 --- a/stdlib/fcntl.pyi +++ b/stdlib/fcntl.pyi @@ -43,6 +43,11 @@ if sys.platform != "win32": F_SEAL_SEAL: int F_SEAL_SHRINK: int F_SEAL_WRITE: int + if sys.version_info >= (3, 9): + F_OFD_GETLK: Final[int] + F_OFD_SETLK: Final[int] + F_OFD_SETLKW: Final[int] + if sys.version_info >= (3, 10): F_GETPIPE_SZ: int F_SETPIPE_SZ: int @@ -119,7 +124,7 @@ if sys.platform != "win32": RWH_WRITE_LIFE_LONG: Final = 4 RWH_WRITE_LIFE_EXTREME: Final = 5 - if (sys.version_info >= (3, 9) and sys.platform == "linux") or (sys.version_info >= (3, 13) and sys.platform == "darwin"): + if sys.version_info >= (3, 13) and sys.platform == "darwin": F_OFD_GETLK: Final[int] F_OFD_SETLK: Final[int] F_OFD_SETLKW: Final[int] From 296bb39a9f626b97c065c69d749fb3f9a514af94 Mon Sep 17 00:00:00 2001 From: Maxwell Muoto <41130755+max-muoto@users.noreply.github.com> Date: Mon, 22 Jul 2024 20:04:16 -0500 Subject: [PATCH 4/5] Final for macos --- stdlib/fcntl.pyi | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/stdlib/fcntl.pyi b/stdlib/fcntl.pyi index d7a285b77085..9b067befa6b7 100644 --- a/stdlib/fcntl.pyi +++ b/stdlib/fcntl.pyi @@ -125,9 +125,9 @@ if sys.platform != "win32": RWH_WRITE_LIFE_EXTREME: Final = 5 if sys.version_info >= (3, 13) and sys.platform == "darwin": - F_OFD_GETLK: Final[int] - F_OFD_SETLK: Final[int] - F_OFD_SETLKW: Final[int] + F_OFD_SETLK: Final = 90 + F_OFD_SETLKW: Final = 91 + F_OFD_GETLK: Final = 92 if sys.version_info >= (3, 13) and sys.platform != "linux": # OSx and NetBSD From a855a37e16af01fb950844358feb3fb9e9156171 Mon Sep 17 00:00:00 2001 From: Maxwell Muoto <41130755+max-muoto@users.noreply.github.com> Date: Wed, 24 Jul 2024 19:31:28 -0500 Subject: [PATCH 5/5] Address feedback --- stdlib/@tests/stubtest_allowlists/darwin-py311.txt | 5 +++++ stdlib/@tests/stubtest_allowlists/darwin-py312.txt | 5 +++++ stdlib/fcntl.pyi | 2 +- 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/stdlib/@tests/stubtest_allowlists/darwin-py311.txt b/stdlib/@tests/stubtest_allowlists/darwin-py311.txt index b2c946476187..10b3f11eeeec 100644 --- a/stdlib/@tests/stubtest_allowlists/darwin-py311.txt +++ b/stdlib/@tests/stubtest_allowlists/darwin-py311.txt @@ -13,3 +13,8 @@ webbrowser.MacOSX.__init__ spwd msilib(.[a-z]+)? ossaudiodev + +# Not present on all MacOS versions +fcntl.F_OFD_GETLK +fcntl.F_OFD_SETLK +fcntl.F_OFD_SETLKW diff --git a/stdlib/@tests/stubtest_allowlists/darwin-py312.txt b/stdlib/@tests/stubtest_allowlists/darwin-py312.txt index f96d4960829c..00571207cb22 100644 --- a/stdlib/@tests/stubtest_allowlists/darwin-py312.txt +++ b/stdlib/@tests/stubtest_allowlists/darwin-py312.txt @@ -18,3 +18,8 @@ curses.window.get_wch spwd msilib(.[a-z]+)? ossaudiodev + +# Not present on all MacOS versions +fcntl.F_OFD_GETLK +fcntl.F_OFD_SETLK +fcntl.F_OFD_SETLKW diff --git a/stdlib/fcntl.pyi b/stdlib/fcntl.pyi index 9b067befa6b7..376611f166b8 100644 --- a/stdlib/fcntl.pyi +++ b/stdlib/fcntl.pyi @@ -124,7 +124,7 @@ if sys.platform != "win32": RWH_WRITE_LIFE_LONG: Final = 4 RWH_WRITE_LIFE_EXTREME: Final = 5 - if sys.version_info >= (3, 13) and sys.platform == "darwin": + if sys.version_info >= (3, 11) and sys.platform == "darwin": F_OFD_SETLK: Final = 90 F_OFD_SETLKW: Final = 91 F_OFD_GETLK: Final = 92