From 383602d13f5f147897dde0e5d3bde64026a559d5 Mon Sep 17 00:00:00 2001 From: Nikita Sobolev Date: Tue, 4 Jan 2022 12:05:43 +0300 Subject: [PATCH 01/10] Not all constants in `fcntl` are available on macos --- stdlib/fcntl.pyi | 106 +++++++++++++++++++++++++---------------------- 1 file changed, 56 insertions(+), 50 deletions(-) diff --git a/stdlib/fcntl.pyi b/stdlib/fcntl.pyi index 47766357c83f..6f7621cb3ecb 100644 --- a/stdlib/fcntl.pyi +++ b/stdlib/fcntl.pyi @@ -6,80 +6,86 @@ from typing_extensions import Literal if sys.platform != "win32": FASYNC: int FD_CLOEXEC: int - DN_ACCESS: int - DN_ATTRIB: int - DN_CREATE: int - DN_DELETE: int - DN_MODIFY: int - DN_MULTISHOT: int - DN_RENAME: int + if sys.platform == "linux": + DN_ACCESS: int + DN_ATTRIB: int + DN_CREATE: int + DN_DELETE: int + DN_MODIFY: int + DN_MULTISHOT: int + DN_RENAME: int F_DUPFD: int F_DUPFD_CLOEXEC: int F_FULLFSYNC: int - F_EXLCK: int F_GETFD: int F_GETFL: int - F_GETLEASE: int F_GETLK: int - F_GETLK64: int + if sys.platform == "darwin": + F_GETPATH: int F_GETOWN: int F_NOCACHE: int - F_GETSIG: int - F_NOTIFY: int F_RDLCK: int F_SETFD: int F_SETFL: int - F_SETLEASE: int F_SETLK: int - F_SETLK64: int F_SETLKW: int - F_SETLKW64: int if sys.version_info >= (3, 9) and sys.platform == "linux": F_OFD_GETLK: int F_OFD_SETLK: int F_OFD_SETLKW: int F_SETOWN: int - F_SETSIG: int - F_SHLCK: int F_UNLCK: int F_WRLCK: int - I_ATMARK: int - I_CANPUT: int - I_CKBAND: int - I_FDINSERT: int - I_FIND: int - I_FLUSH: int - I_FLUSHBAND: int - I_GETBAND: int - I_GETCLTIME: int - I_GETSIG: int - I_GRDOPT: int - I_GWROPT: int - I_LINK: int - I_LIST: int - I_LOOK: int - I_NREAD: int - I_PEEK: int - I_PLINK: int - I_POP: int - I_PUNLINK: int - I_PUSH: int - I_RECVFD: int - I_SENDFD: int - I_SETCLTIME: int - I_SETSIG: int - I_SRDOPT: int - I_STR: int - I_SWROPT: int - I_UNLINK: int + if sys.platform == "linux": + F_SETLKW64: int + F_SETSIG: int + F_SHLCK: int + F_SETLK64: int + F_SETLEASE: int + F_GETSIG: int + F_NOTIFY: int + F_EXLCK: int + F_GETLEASE: int + F_GETLK64: int + + I_ATMARK: int + I_CANPUT: int + I_CKBAND: int + I_FDINSERT: int + I_FIND: int + I_FLUSH: int + I_FLUSHBAND: int + I_GETBAND: int + I_GETCLTIME: int + I_GETSIG: int + I_GRDOPT: int + I_GWROPT: int + I_LINK: int + I_LIST: int + I_LOOK: int + I_NREAD: int + I_PEEK: int + I_PLINK: int + I_POP: int + I_PUNLINK: int + I_PUSH: int + I_RECVFD: int + I_SENDFD: int + I_SETCLTIME: int + I_SETSIG: int + I_SRDOPT: int + I_STR: int + I_SWROPT: int + I_UNLINK: int LOCK_EX: int - LOCK_MAND: int LOCK_NB: int - LOCK_READ: int - LOCK_RW: int LOCK_SH: int LOCK_UN: int - LOCK_WRITE: int + if sys.platform == "linux": + LOCK_MAND: int + LOCK_READ: int + LOCK_RW: int + LOCK_WRITE: int @overload def fcntl(__fd: FileDescriptorLike, __cmd: int, __arg: int = ...) -> int: ... @overload From 159aa949d8794378aa17dfd12cd979a8450803b5 Mon Sep 17 00:00:00 2001 From: Nikita Sobolev Date: Tue, 4 Jan 2022 12:13:05 +0300 Subject: [PATCH 02/10] Update darwin.txt --- tests/stubtest_allowlists/darwin.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/stubtest_allowlists/darwin.txt b/tests/stubtest_allowlists/darwin.txt index aa8a3342d1f7..f6d21d2854c2 100644 --- a/tests/stubtest_allowlists/darwin.txt +++ b/tests/stubtest_allowlists/darwin.txt @@ -33,7 +33,6 @@ ossaudiodev spwd # Platform differences that cannot be captured by the type system -fcntl.[A-Z0-9_]+ os.SCHED_[A-Z_]+ posix.SCHED_[A-Z_]+ From 122b16a6f2a946160e540abce41b132f8e6312ad Mon Sep 17 00:00:00 2001 From: Nikita Sobolev Date: Tue, 4 Jan 2022 12:14:07 +0300 Subject: [PATCH 03/10] Update linux.txt --- tests/stubtest_allowlists/linux.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/stubtest_allowlists/linux.txt b/tests/stubtest_allowlists/linux.txt index 1052a594f061..b59746ef0194 100644 --- a/tests/stubtest_allowlists/linux.txt +++ b/tests/stubtest_allowlists/linux.txt @@ -36,7 +36,6 @@ posix.error.characters_written resource.error.characters_written # Platform differences that cannot be captured by the type system -fcntl.[A-Z0-9_]+ os.SCHED_[A-Z_]+ posix.SCHED_[A-Z_]+ From 487f52efdd8bc9d4e0169312d23559b81ba1989c Mon Sep 17 00:00:00 2001 From: Nikita Sobolev Date: Tue, 4 Jan 2022 12:21:18 +0300 Subject: [PATCH 04/10] Update fcntl.pyi --- stdlib/fcntl.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stdlib/fcntl.pyi b/stdlib/fcntl.pyi index 6f7621cb3ecb..6c04284f3816 100644 --- a/stdlib/fcntl.pyi +++ b/stdlib/fcntl.pyi @@ -20,7 +20,7 @@ if sys.platform != "win32": F_GETFD: int F_GETFL: int F_GETLK: int - if sys.platform == "darwin": + if sys.version_info >= (3, 9) and sys.platform == "darwin": F_GETPATH: int F_GETOWN: int F_NOCACHE: int From 6be3c1b71fdbf50263b624ac32f2a305aabc2fd4 Mon Sep 17 00:00:00 2001 From: Nikita Sobolev Date: Tue, 4 Jan 2022 12:28:04 +0300 Subject: [PATCH 05/10] Update fcntl.pyi --- stdlib/fcntl.pyi | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/stdlib/fcntl.pyi b/stdlib/fcntl.pyi index 6c04284f3816..f30966569bf6 100644 --- a/stdlib/fcntl.pyi +++ b/stdlib/fcntl.pyi @@ -16,14 +16,15 @@ if sys.platform != "win32": DN_RENAME: int F_DUPFD: int F_DUPFD_CLOEXEC: int - F_FULLFSYNC: int + if sys.platform == "darwin": + F_FULLFSYNC: int + F_NOCACHE: int + if sys.version_info >= (3, 9): + F_GETPATH: int F_GETFD: int F_GETFL: int F_GETLK: int - if sys.version_info >= (3, 9) and sys.platform == "darwin": - F_GETPATH: int F_GETOWN: int - F_NOCACHE: int F_RDLCK: int F_SETFD: int F_SETFL: int @@ -48,6 +49,18 @@ if sys.platform != "win32": F_GETLEASE: int F_GETLK64: int + LOCK_EX: int + LOCK_NB: int + LOCK_SH: int + LOCK_UN: int + if sys.platform == "linux": + LOCK_MAND: int + LOCK_READ: int + LOCK_RW: int + LOCK_WRITE: int + + # These are highly problematic, they might be present or not, depends on the specific OS. + if sys.platform == "linux": I_ATMARK: int I_CANPUT: int I_CKBAND: int @@ -77,15 +90,6 @@ if sys.platform != "win32": I_STR: int I_SWROPT: int I_UNLINK: int - LOCK_EX: int - LOCK_NB: int - LOCK_SH: int - LOCK_UN: int - if sys.platform == "linux": - LOCK_MAND: int - LOCK_READ: int - LOCK_RW: int - LOCK_WRITE: int @overload def fcntl(__fd: FileDescriptorLike, __cmd: int, __arg: int = ...) -> int: ... @overload From bcf4f2ada07d31a586e8369474f0ad0624f122bd Mon Sep 17 00:00:00 2001 From: Nikita Sobolev Date: Tue, 4 Jan 2022 12:28:27 +0300 Subject: [PATCH 06/10] Update linux.txt --- tests/stubtest_allowlists/linux.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/stubtest_allowlists/linux.txt b/tests/stubtest_allowlists/linux.txt index b59746ef0194..429cd4387570 100644 --- a/tests/stubtest_allowlists/linux.txt +++ b/tests/stubtest_allowlists/linux.txt @@ -36,6 +36,7 @@ posix.error.characters_written resource.error.characters_written # Platform differences that cannot be captured by the type system +fcntl.I_[A-Z0-9_]+ os.SCHED_[A-Z_]+ posix.SCHED_[A-Z_]+ From 7029b7a9ad0cb409a1c3bdd89d6edf85fd9c7a25 Mon Sep 17 00:00:00 2001 From: Nikita Sobolev Date: Tue, 4 Jan 2022 12:34:44 +0300 Subject: [PATCH 07/10] Update fcntl.pyi --- stdlib/fcntl.pyi | 41 ++++++++++++++++++++++++----------------- 1 file changed, 24 insertions(+), 17 deletions(-) diff --git a/stdlib/fcntl.pyi b/stdlib/fcntl.pyi index f30966569bf6..05a6ff7a617c 100644 --- a/stdlib/fcntl.pyi +++ b/stdlib/fcntl.pyi @@ -6,21 +6,8 @@ from typing_extensions import Literal if sys.platform != "win32": FASYNC: int FD_CLOEXEC: int - if sys.platform == "linux": - DN_ACCESS: int - DN_ATTRIB: int - DN_CREATE: int - DN_DELETE: int - DN_MODIFY: int - DN_MULTISHOT: int - DN_RENAME: int F_DUPFD: int F_DUPFD_CLOEXEC: int - if sys.platform == "darwin": - F_FULLFSYNC: int - F_NOCACHE: int - if sys.version_info >= (3, 9): - F_GETPATH: int F_GETFD: int F_GETFL: int F_GETLK: int @@ -30,13 +17,14 @@ if sys.platform != "win32": F_SETFL: int F_SETLK: int F_SETLKW: int - if sys.version_info >= (3, 9) and sys.platform == "linux": - F_OFD_GETLK: int - F_OFD_SETLK: int - F_OFD_SETLKW: int F_SETOWN: int F_UNLCK: int F_WRLCK: int + if sys.platform == "darwin": + F_FULLFSYNC: int + F_NOCACHE: int + if sys.version_info >= (3, 9): + F_GETPATH: int if sys.platform == "linux": F_SETLKW64: int F_SETSIG: int @@ -48,6 +36,25 @@ if sys.platform != "win32": F_EXLCK: int F_GETLEASE: int F_GETLK64: int + if sys.version_info >= (3, 8): + F_ADD_SEALS: int + F_GET_SEALS: int + F_SEAL_GROW: int + 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 + + DN_ACCESS: int + DN_ATTRIB: int + DN_CREATE: int + DN_DELETE: int + DN_MODIFY: int + DN_MULTISHOT: int + DN_RENAME: int LOCK_EX: int LOCK_NB: int From ed3724d856418905633f3621cc00e5592efab771 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 4 Jan 2022 09:35:51 +0000 Subject: [PATCH 08/10] [pre-commit.ci] auto fixes from pre-commit.com hooks --- stdlib/fcntl.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stdlib/fcntl.pyi b/stdlib/fcntl.pyi index 05a6ff7a617c..40bf23853b57 100644 --- a/stdlib/fcntl.pyi +++ b/stdlib/fcntl.pyi @@ -47,7 +47,7 @@ if sys.platform != "win32": F_OFD_GETLK: int F_OFD_SETLK: int F_OFD_SETLKW: int - + DN_ACCESS: int DN_ATTRIB: int DN_CREATE: int From 33f6f2acbde8fe61bb4293c65253119c28029c79 Mon Sep 17 00:00:00 2001 From: Nikita Sobolev Date: Tue, 4 Jan 2022 12:41:05 +0300 Subject: [PATCH 09/10] Finally! --- stdlib/fcntl.pyi | 3 +++ 1 file changed, 3 insertions(+) diff --git a/stdlib/fcntl.pyi b/stdlib/fcntl.pyi index 40bf23853b57..9d3515b0a492 100644 --- a/stdlib/fcntl.pyi +++ b/stdlib/fcntl.pyi @@ -47,6 +47,9 @@ if sys.platform != "win32": F_OFD_GETLK: int F_OFD_SETLK: int F_OFD_SETLKW: int + if sys.version_inf >= (3, 10): + F_GETPIPE_SZ: int + F_SETPIPE_SZ: int DN_ACCESS: int DN_ATTRIB: int From 836f1996a80475dc23fba0a8f282cec38156662c Mon Sep 17 00:00:00 2001 From: Nikita Sobolev Date: Tue, 4 Jan 2022 12:42:27 +0300 Subject: [PATCH 10/10] Update stdlib/fcntl.pyi Co-authored-by: Alex Waygood --- stdlib/fcntl.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stdlib/fcntl.pyi b/stdlib/fcntl.pyi index 9d3515b0a492..69863bf580fa 100644 --- a/stdlib/fcntl.pyi +++ b/stdlib/fcntl.pyi @@ -47,7 +47,7 @@ if sys.platform != "win32": F_OFD_GETLK: int F_OFD_SETLK: int F_OFD_SETLKW: int - if sys.version_inf >= (3, 10): + if sys.version_info >= (3, 10): F_GETPIPE_SZ: int F_SETPIPE_SZ: int