Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions stdlib/_stat.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,22 @@ if sys.platform == "win32" and sys.version_info >= (3, 8):
IO_REPARSE_TAG_SYMLINK: int
IO_REPARSE_TAG_MOUNT_POINT: int
IO_REPARSE_TAG_APPEXECLINK: int

if sys.platform == "win32":
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not true, I can use these values on macos
Снимок экрана 2021-12-31 в 0 34 27

Copy link
Collaborator

@hauntsaninja hauntsaninja Dec 30, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I merged because a) Akuli did this intentionally (see comments in stubtest allowlists), b) they're documented as Windows only (https://docs.python.org/3/library/stat.html), c) there genuinely doesn't seem to be a use for them on other platforms and maybe that could uncover a bug.

That said, typeshed tries to avoid editorialising too much and we accomplish that by sticking close to implementation details, so if you (or anyone else) feel strongly or find this too opinionated I'm happy to have these definitions be unconditional.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, thanks for the explanation! I don't know when and why these values are used, so I don't have any strong opinions here 🙂

FILE_ATTRIBUTE_ARCHIVE: Literal[32]
FILE_ATTRIBUTE_COMPRESSED: Literal[2048]
FILE_ATTRIBUTE_DEVICE: Literal[64]
FILE_ATTRIBUTE_DIRECTORY: Literal[16]
FILE_ATTRIBUTE_ENCRYPTED: Literal[16384]
FILE_ATTRIBUTE_HIDDEN: Literal[2]
FILE_ATTRIBUTE_INTEGRITY_STREAM: Literal[32768]
FILE_ATTRIBUTE_NORMAL: Literal[128]
FILE_ATTRIBUTE_NOT_CONTENT_INDEXED: Literal[8192]
FILE_ATTRIBUTE_NO_SCRUB_DATA: Literal[131072]
FILE_ATTRIBUTE_OFFLINE: Literal[4096]
FILE_ATTRIBUTE_READONLY: Literal[1]
FILE_ATTRIBUTE_REPARSE_POINT: Literal[1024]
FILE_ATTRIBUTE_SPARSE_FILE: Literal[512]
FILE_ATTRIBUTE_SYSTEM: Literal[4]
FILE_ATTRIBUTE_TEMPORARY: Literal[256]
FILE_ATTRIBUTE_VIRTUAL: Literal[65536]
20 changes: 0 additions & 20 deletions stdlib/stat.pyi
Original file line number Diff line number Diff line change
@@ -1,21 +1 @@
from typing_extensions import Literal

from _stat import *

FILE_ATTRIBUTE_ARCHIVE: Literal[32]
FILE_ATTRIBUTE_COMPRESSED: Literal[2048]
FILE_ATTRIBUTE_DEVICE: Literal[64]
FILE_ATTRIBUTE_DIRECTORY: Literal[16]
FILE_ATTRIBUTE_ENCRYPTED: Literal[16384]
FILE_ATTRIBUTE_HIDDEN: Literal[2]
FILE_ATTRIBUTE_INTEGRITY_STREAM: Literal[32768]
FILE_ATTRIBUTE_NORMAL: Literal[128]
FILE_ATTRIBUTE_NOT_CONTENT_INDEXED: Literal[8192]
FILE_ATTRIBUTE_NO_SCRUB_DATA: Literal[131072]
FILE_ATTRIBUTE_OFFLINE: Literal[4096]
FILE_ATTRIBUTE_READONLY: Literal[1]
FILE_ATTRIBUTE_REPARSE_POINT: Literal[1024]
FILE_ATTRIBUTE_SPARSE_FILE: Literal[512]
FILE_ATTRIBUTE_SYSTEM: Literal[4]
FILE_ATTRIBUTE_TEMPORARY: Literal[256]
FILE_ATTRIBUTE_VIRTUAL: Literal[65536]
3 changes: 3 additions & 0 deletions tests/stubtest_allowlists/darwin.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ fcntl.[A-Z0-9_]+
os.SCHED_[A-Z_]+
posix.SCHED_[A-Z_]+

# Some of these exist on non-windows, but they are useless and this is not intended
stat.FILE_ATTRIBUTE_[A-Z_]+

# Loadable SQLite extensions are disabled on GitHub runners
(sqlite3(.dbapi2)?.Connection.enable_load_extension)?
(sqlite3(.dbapi2)?.Connection.load_extension)?
Expand Down
3 changes: 3 additions & 0 deletions tests/stubtest_allowlists/linux.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ fcntl.[A-Z0-9_]+
os.SCHED_[A-Z_]+
posix.SCHED_[A-Z_]+

# Some of these exist on non-windows, but they are useless and this is not intended
stat.FILE_ATTRIBUTE_[A-Z_]+

# Loadable SQLite extensions are disabled on GitHub runners
(sqlite3(.dbapi2)?.Connection.enable_load_extension)?
(sqlite3(.dbapi2)?.Connection.load_extension)?
Expand Down
1 change: 0 additions & 1 deletion tests/stubtest_allowlists/win32.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
_msi.MSI[A-Z_]+
_msi.PID_[A-Z_]+
_stat.FILE_ATTRIBUTE_[A-Z_]+
ctypes.GetLastError # Is actually a pointer
distutils.archive_util.getgrnam
distutils.archive_util.getpwnam
Expand Down