-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Expand file tree
/
Copy path__init__.pyi
More file actions
1757 lines (1607 loc) · 56.6 KB
/
__init__.pyi
File metadata and controls
1757 lines (1607 loc) · 56.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
import sys
from _typeshed import (
AnyStr_co,
BytesPath,
FileDescriptor,
FileDescriptorLike,
FileDescriptorOrPath,
GenericPath,
OpenBinaryMode,
OpenBinaryModeReading,
OpenBinaryModeUpdating,
OpenBinaryModeWriting,
OpenTextMode,
ReadableBuffer,
StrOrBytesPath,
StrPath,
SupportsLenAndGetItem,
Unused,
WriteableBuffer,
structseq,
)
from abc import ABC, abstractmethod
from builtins import OSError
from collections.abc import Callable, Iterable, Iterator, Mapping, MutableMapping, Sequence
from io import BufferedRandom, BufferedReader, BufferedWriter, FileIO, TextIOWrapper
from subprocess import Popen
from types import GenericAlias, TracebackType
from typing import (
IO,
Any,
AnyStr,
BinaryIO,
Final,
Generic,
Literal,
NoReturn,
Protocol,
TypeVar,
final,
overload,
runtime_checkable,
type_check_only,
)
from typing_extensions import LiteralString, Self, TypeAlias, Unpack, deprecated
from . import path as _path
# Re-export common definitions from os.path to reduce duplication
from .path import (
altsep as altsep,
curdir as curdir,
defpath as defpath,
devnull as devnull,
extsep as extsep,
pardir as pardir,
pathsep as pathsep,
sep as sep,
)
__all__ = [
"F_OK",
"O_APPEND",
"O_CREAT",
"O_EXCL",
"O_RDONLY",
"O_RDWR",
"O_TRUNC",
"O_WRONLY",
"P_NOWAIT",
"P_NOWAITO",
"P_WAIT",
"R_OK",
"SEEK_CUR",
"SEEK_END",
"SEEK_SET",
"TMP_MAX",
"W_OK",
"X_OK",
"DirEntry",
"_exit",
"abort",
"access",
"altsep",
"chdir",
"chmod",
"close",
"closerange",
"cpu_count",
"curdir",
"defpath",
"device_encoding",
"devnull",
"dup",
"dup2",
"environ",
"error",
"execl",
"execle",
"execlp",
"execlpe",
"execv",
"execve",
"execvp",
"execvpe",
"extsep",
"fdopen",
"fsdecode",
"fsencode",
"fspath",
"fstat",
"fsync",
"ftruncate",
"get_exec_path",
"get_inheritable",
"get_terminal_size",
"getcwd",
"getcwdb",
"getenv",
"getlogin",
"getpid",
"getppid",
"isatty",
"kill",
"linesep",
"link",
"listdir",
"lseek",
"lstat",
"makedirs",
"mkdir",
"name",
"open",
"pardir",
"path",
"pathsep",
"pipe",
"popen",
"putenv",
"read",
"readlink",
"remove",
"removedirs",
"rename",
"renames",
"replace",
"rmdir",
"scandir",
"sep",
"set_inheritable",
"spawnl",
"spawnle",
"spawnv",
"spawnve",
"stat",
"stat_result",
"statvfs_result",
"strerror",
"supports_bytes_environ",
"symlink",
"system",
"terminal_size",
"times",
"times_result",
"truncate",
"umask",
"uname_result",
"unlink",
"unsetenv",
"urandom",
"utime",
"waitpid",
"waitstatus_to_exitcode",
"walk",
"write",
]
if sys.version_info >= (3, 14):
# reload_environ was added to __all__ in Python 3.14.1
__all__ += ["readinto", "reload_environ"]
if sys.platform == "darwin" and sys.version_info >= (3, 12):
__all__ += ["PRIO_DARWIN_BG", "PRIO_DARWIN_NONUI", "PRIO_DARWIN_PROCESS", "PRIO_DARWIN_THREAD"]
if sys.platform == "darwin" and sys.version_info >= (3, 10):
__all__ += ["O_EVTONLY", "O_NOFOLLOW_ANY", "O_SYMLINK"]
if sys.platform == "linux":
__all__ += [
"GRND_NONBLOCK",
"GRND_RANDOM",
"MFD_ALLOW_SEALING",
"MFD_CLOEXEC",
"MFD_HUGETLB",
"MFD_HUGE_16GB",
"MFD_HUGE_16MB",
"MFD_HUGE_1GB",
"MFD_HUGE_1MB",
"MFD_HUGE_256MB",
"MFD_HUGE_2GB",
"MFD_HUGE_2MB",
"MFD_HUGE_32MB",
"MFD_HUGE_512KB",
"MFD_HUGE_512MB",
"MFD_HUGE_64KB",
"MFD_HUGE_8MB",
"MFD_HUGE_MASK",
"MFD_HUGE_SHIFT",
"O_DIRECT",
"O_LARGEFILE",
"O_NOATIME",
"O_PATH",
"O_RSYNC",
"O_TMPFILE",
"P_PIDFD",
"RTLD_DEEPBIND",
"SCHED_BATCH",
"SCHED_IDLE",
"SCHED_RESET_ON_FORK",
"XATTR_CREATE",
"XATTR_REPLACE",
"XATTR_SIZE_MAX",
"copy_file_range",
"getrandom",
"getxattr",
"listxattr",
"memfd_create",
"pidfd_open",
"removexattr",
"setxattr",
]
if sys.platform == "linux" and sys.version_info >= (3, 14):
__all__ += ["SCHED_DEADLINE", "SCHED_NORMAL"]
if sys.platform == "linux" and sys.version_info >= (3, 13):
__all__ += [
"POSIX_SPAWN_CLOSEFROM",
"TFD_CLOEXEC",
"TFD_NONBLOCK",
"TFD_TIMER_ABSTIME",
"TFD_TIMER_CANCEL_ON_SET",
"timerfd_create",
"timerfd_gettime",
"timerfd_gettime_ns",
"timerfd_settime",
"timerfd_settime_ns",
]
if sys.platform == "linux" and sys.version_info >= (3, 12):
__all__ += [
"CLONE_FILES",
"CLONE_FS",
"CLONE_NEWCGROUP",
"CLONE_NEWIPC",
"CLONE_NEWNET",
"CLONE_NEWNS",
"CLONE_NEWPID",
"CLONE_NEWTIME",
"CLONE_NEWUSER",
"CLONE_NEWUTS",
"CLONE_SIGHAND",
"CLONE_SYSVSEM",
"CLONE_THREAD",
"CLONE_VM",
"setns",
"unshare",
"PIDFD_NONBLOCK",
]
if sys.platform == "linux" and sys.version_info >= (3, 10):
__all__ += [
"EFD_CLOEXEC",
"EFD_NONBLOCK",
"EFD_SEMAPHORE",
"RWF_APPEND",
"SPLICE_F_MORE",
"SPLICE_F_MOVE",
"SPLICE_F_NONBLOCK",
"eventfd",
"eventfd_read",
"eventfd_write",
"splice",
]
if sys.platform == "win32":
__all__ += [
"O_BINARY",
"O_NOINHERIT",
"O_RANDOM",
"O_SEQUENTIAL",
"O_SHORT_LIVED",
"O_TEMPORARY",
"O_TEXT",
"P_DETACH",
"P_OVERLAY",
"get_handle_inheritable",
"set_handle_inheritable",
"startfile",
]
if sys.platform == "win32" and sys.version_info >= (3, 12):
__all__ += ["listdrives", "listmounts", "listvolumes"]
if sys.platform != "win32":
__all__ += [
"CLD_CONTINUED",
"CLD_DUMPED",
"CLD_EXITED",
"CLD_KILLED",
"CLD_STOPPED",
"CLD_TRAPPED",
"EX_CANTCREAT",
"EX_CONFIG",
"EX_DATAERR",
"EX_IOERR",
"EX_NOHOST",
"EX_NOINPUT",
"EX_NOPERM",
"EX_NOUSER",
"EX_OSERR",
"EX_OSFILE",
"EX_PROTOCOL",
"EX_SOFTWARE",
"EX_TEMPFAIL",
"EX_UNAVAILABLE",
"EX_USAGE",
"F_LOCK",
"F_TEST",
"F_TLOCK",
"F_ULOCK",
"NGROUPS_MAX",
"O_ACCMODE",
"O_ASYNC",
"O_CLOEXEC",
"O_DIRECTORY",
"O_DSYNC",
"O_NDELAY",
"O_NOCTTY",
"O_NOFOLLOW",
"O_NONBLOCK",
"O_SYNC",
"POSIX_SPAWN_CLOSE",
"POSIX_SPAWN_DUP2",
"POSIX_SPAWN_OPEN",
"PRIO_PGRP",
"PRIO_PROCESS",
"PRIO_USER",
"P_ALL",
"P_PGID",
"P_PID",
"RTLD_GLOBAL",
"RTLD_LAZY",
"RTLD_LOCAL",
"RTLD_NODELETE",
"RTLD_NOLOAD",
"RTLD_NOW",
"SCHED_FIFO",
"SCHED_OTHER",
"SCHED_RR",
"SEEK_DATA",
"SEEK_HOLE",
"ST_NOSUID",
"ST_RDONLY",
"WCONTINUED",
"WCOREDUMP",
"WEXITED",
"WEXITSTATUS",
"WIFCONTINUED",
"WIFEXITED",
"WIFSIGNALED",
"WIFSTOPPED",
"WNOHANG",
"WNOWAIT",
"WSTOPPED",
"WSTOPSIG",
"WTERMSIG",
"WUNTRACED",
"chown",
"chroot",
"confstr",
"confstr_names",
"ctermid",
"environb",
"fchdir",
"fchown",
"fork",
"forkpty",
"fpathconf",
"fstatvfs",
"fwalk",
"getegid",
"getenvb",
"geteuid",
"getgid",
"getgrouplist",
"getgroups",
"getloadavg",
"getpgid",
"getpgrp",
"getpriority",
"getsid",
"getuid",
"initgroups",
"killpg",
"lchown",
"lockf",
"major",
"makedev",
"minor",
"mkfifo",
"mknod",
"nice",
"openpty",
"pathconf",
"pathconf_names",
"posix_spawn",
"posix_spawnp",
"pread",
"preadv",
"pwrite",
"pwritev",
"readv",
"register_at_fork",
"sched_get_priority_max",
"sched_get_priority_min",
"sched_yield",
"sendfile",
"setegid",
"seteuid",
"setgid",
"setgroups",
"setpgid",
"setpgrp",
"setpriority",
"setregid",
"setreuid",
"setsid",
"setuid",
"spawnlp",
"spawnlpe",
"spawnvp",
"spawnvpe",
"statvfs",
"sync",
"sysconf",
"sysconf_names",
"tcgetpgrp",
"tcsetpgrp",
"ttyname",
"uname",
"wait",
"wait3",
"wait4",
"writev",
]
if sys.platform != "win32" and sys.version_info >= (3, 13):
__all__ += ["grantpt", "posix_openpt", "ptsname", "unlockpt"]
if sys.platform != "win32" and sys.version_info >= (3, 11):
__all__ += ["login_tty"]
if sys.platform != "win32" and sys.version_info >= (3, 10):
__all__ += ["O_FSYNC"]
if sys.platform != "darwin" and sys.platform != "win32":
__all__ += [
"POSIX_FADV_DONTNEED",
"POSIX_FADV_NOREUSE",
"POSIX_FADV_NORMAL",
"POSIX_FADV_RANDOM",
"POSIX_FADV_SEQUENTIAL",
"POSIX_FADV_WILLNEED",
"RWF_DSYNC",
"RWF_HIPRI",
"RWF_NOWAIT",
"RWF_SYNC",
"ST_APPEND",
"ST_MANDLOCK",
"ST_NOATIME",
"ST_NODEV",
"ST_NODIRATIME",
"ST_NOEXEC",
"ST_RELATIME",
"ST_SYNCHRONOUS",
"ST_WRITE",
"fdatasync",
"getresgid",
"getresuid",
"pipe2",
"posix_fadvise",
"posix_fallocate",
"sched_getaffinity",
"sched_getparam",
"sched_getscheduler",
"sched_param",
"sched_rr_get_interval",
"sched_setaffinity",
"sched_setparam",
"sched_setscheduler",
"setresgid",
"setresuid",
]
if sys.platform != "linux" and sys.platform != "win32":
__all__ += ["O_EXLOCK", "O_SHLOCK", "chflags", "lchflags"]
if sys.platform != "linux" and sys.platform != "win32" and sys.version_info >= (3, 13):
__all__ += ["O_EXEC", "O_SEARCH"]
if sys.platform != "darwin" or sys.version_info >= (3, 13):
if sys.platform != "win32":
__all__ += ["waitid", "waitid_result"]
if sys.platform != "win32" or sys.version_info >= (3, 13):
__all__ += ["fchmod"]
if sys.platform != "linux":
__all__ += ["lchmod"]
if sys.platform != "win32" or sys.version_info >= (3, 12):
__all__ += ["get_blocking", "set_blocking"]
if sys.platform != "win32" or sys.version_info >= (3, 11):
__all__ += ["EX_OK"]
# This unnecessary alias is to work around various errors
path = _path
_T = TypeVar("_T")
_T1 = TypeVar("_T1")
_T2 = TypeVar("_T2")
# ----- os variables -----
error = OSError
supports_bytes_environ: bool
supports_dir_fd: set[Callable[..., Any]]
supports_fd: set[Callable[..., Any]]
supports_effective_ids: set[Callable[..., Any]]
supports_follow_symlinks: set[Callable[..., Any]]
if sys.platform != "win32":
# Unix only
PRIO_PROCESS: Final[int]
PRIO_PGRP: Final[int]
PRIO_USER: Final[int]
F_LOCK: Final[int]
F_TLOCK: Final[int]
F_ULOCK: Final[int]
F_TEST: Final[int]
if sys.platform != "darwin":
POSIX_FADV_NORMAL: Final[int]
POSIX_FADV_SEQUENTIAL: Final[int]
POSIX_FADV_RANDOM: Final[int]
POSIX_FADV_NOREUSE: Final[int]
POSIX_FADV_WILLNEED: Final[int]
POSIX_FADV_DONTNEED: Final[int]
if sys.platform != "linux" and sys.platform != "darwin":
# In the os-module docs, these are marked as being available
# on "Unix, not Emscripten, not WASI."
# However, in the source code, a comment indicates they're "FreeBSD constants".
# sys.platform could have one of many values on a FreeBSD Python build,
# so the sys-module docs recommend doing `if sys.platform.startswith('freebsd')`
# to detect FreeBSD builds. Unfortunately that would be too dynamic
# for type checkers, however.
SF_NODISKIO: Final[int]
SF_MNOWAIT: Final[int]
SF_SYNC: Final[int]
if sys.version_info >= (3, 11):
SF_NOCACHE: Final[int]
if sys.platform == "linux":
XATTR_SIZE_MAX: Final[int]
XATTR_CREATE: Final[int]
XATTR_REPLACE: Final[int]
P_PID: Final[int]
P_PGID: Final[int]
P_ALL: Final[int]
if sys.platform == "linux":
P_PIDFD: Final[int]
WEXITED: Final[int]
WSTOPPED: Final[int]
WNOWAIT: Final[int]
CLD_EXITED: Final[int]
CLD_DUMPED: Final[int]
CLD_TRAPPED: Final[int]
CLD_CONTINUED: Final[int]
CLD_KILLED: Final[int]
CLD_STOPPED: Final[int]
SCHED_OTHER: Final[int]
SCHED_FIFO: Final[int]
SCHED_RR: Final[int]
if sys.platform != "darwin" and sys.platform != "linux":
SCHED_SPORADIC: Final[int]
if sys.platform == "linux":
SCHED_BATCH: Final[int]
SCHED_IDLE: Final[int]
SCHED_RESET_ON_FORK: Final[int]
if sys.version_info >= (3, 14) and sys.platform == "linux":
SCHED_DEADLINE: Final[int]
SCHED_NORMAL: Final[int]
if sys.platform != "win32":
RTLD_LAZY: Final[int]
RTLD_NOW: Final[int]
RTLD_GLOBAL: Final[int]
RTLD_LOCAL: Final[int]
RTLD_NODELETE: Final[int]
RTLD_NOLOAD: Final[int]
if sys.platform == "linux":
RTLD_DEEPBIND: Final[int]
GRND_NONBLOCK: Final[int]
GRND_RANDOM: Final[int]
if sys.platform == "darwin" and sys.version_info >= (3, 12):
PRIO_DARWIN_BG: Final[int]
PRIO_DARWIN_NONUI: Final[int]
PRIO_DARWIN_PROCESS: Final[int]
PRIO_DARWIN_THREAD: Final[int]
SEEK_SET: Final = 0
SEEK_CUR: Final = 1
SEEK_END: Final = 2
if sys.platform != "win32":
SEEK_DATA: Final = 3
SEEK_HOLE: Final = 4
O_RDONLY: Final[int]
O_WRONLY: Final[int]
O_RDWR: Final[int]
O_APPEND: Final[int]
O_CREAT: Final[int]
O_EXCL: Final[int]
O_TRUNC: Final[int]
if sys.platform == "win32":
O_BINARY: Final[int]
O_NOINHERIT: Final[int]
O_SHORT_LIVED: Final[int]
O_TEMPORARY: Final[int]
O_RANDOM: Final[int]
O_SEQUENTIAL: Final[int]
O_TEXT: Final[int]
if sys.platform != "win32":
O_DSYNC: Final[int]
O_SYNC: Final[int]
O_NDELAY: Final[int]
O_NONBLOCK: Final[int]
O_NOCTTY: Final[int]
O_CLOEXEC: Final[int]
O_ASYNC: Final[int] # Gnu extension if in C library
O_DIRECTORY: Final[int] # Gnu extension if in C library
O_NOFOLLOW: Final[int] # Gnu extension if in C library
O_ACCMODE: Final[int] # TODO: when does this exist?
if sys.platform == "linux":
O_RSYNC: Final[int]
O_DIRECT: Final[int] # Gnu extension if in C library
O_NOATIME: Final[int] # Gnu extension if in C library
O_PATH: Final[int] # Gnu extension if in C library
O_TMPFILE: Final[int] # Gnu extension if in C library
O_LARGEFILE: Final[int] # Gnu extension if in C library
if sys.platform != "linux" and sys.platform != "win32":
O_SHLOCK: Final[int]
O_EXLOCK: Final[int]
if sys.platform == "darwin" and sys.version_info >= (3, 10):
O_EVTONLY: Final[int]
O_NOFOLLOW_ANY: Final[int]
O_SYMLINK: Final[int]
if sys.platform != "win32" and sys.version_info >= (3, 10):
O_FSYNC: Final[int]
if sys.platform != "linux" and sys.platform != "win32" and sys.version_info >= (3, 13):
O_EXEC: Final[int]
O_SEARCH: Final[int]
if sys.platform != "win32" and sys.platform != "darwin":
# posix, but apparently missing on macos
ST_APPEND: Final[int]
ST_MANDLOCK: Final[int]
ST_NOATIME: Final[int]
ST_NODEV: Final[int]
ST_NODIRATIME: Final[int]
ST_NOEXEC: Final[int]
ST_RELATIME: Final[int]
ST_SYNCHRONOUS: Final[int]
ST_WRITE: Final[int]
if sys.platform != "win32":
NGROUPS_MAX: Final[int]
ST_NOSUID: Final[int]
ST_RDONLY: Final[int]
linesep: Literal["\n", "\r\n"]
name: LiteralString
F_OK: Final = 0
R_OK: Final = 4
W_OK: Final = 2
X_OK: Final = 1
_EnvironCodeFunc: TypeAlias = Callable[[AnyStr], AnyStr]
class _Environ(MutableMapping[AnyStr, AnyStr], Generic[AnyStr]):
encodekey: _EnvironCodeFunc[AnyStr]
decodekey: _EnvironCodeFunc[AnyStr]
encodevalue: _EnvironCodeFunc[AnyStr]
decodevalue: _EnvironCodeFunc[AnyStr]
def __init__(
self,
data: MutableMapping[AnyStr, AnyStr],
encodekey: _EnvironCodeFunc[AnyStr],
decodekey: _EnvironCodeFunc[AnyStr],
encodevalue: _EnvironCodeFunc[AnyStr],
decodevalue: _EnvironCodeFunc[AnyStr],
) -> None: ...
@overload
def get(self, key: AnyStr, default: None = None) -> AnyStr | None: ...
@overload
def get(self, key: AnyStr, default: AnyStr) -> AnyStr: ...
@overload
def get(self, key: AnyStr, default: _T) -> AnyStr | _T: ...
@overload
def pop(self, key: AnyStr) -> AnyStr: ...
@overload
def pop(self, key: AnyStr, default: AnyStr) -> AnyStr: ...
@overload
def pop(self, key: AnyStr, default: _T) -> AnyStr | _T: ...
def setdefault(self, key: AnyStr, value: AnyStr) -> AnyStr: ...
def copy(self) -> dict[AnyStr, AnyStr]: ...
def __delitem__(self, key: AnyStr) -> None: ...
def __getitem__(self, key: AnyStr) -> AnyStr: ...
def __setitem__(self, key: AnyStr, value: AnyStr) -> None: ...
def __iter__(self) -> Iterator[AnyStr]: ...
def __len__(self) -> int: ...
def __or__(self, other: Mapping[_T1, _T2]) -> dict[AnyStr | _T1, AnyStr | _T2]: ...
def __ror__(self, other: Mapping[_T1, _T2]) -> dict[AnyStr | _T1, AnyStr | _T2]: ...
# We use @overload instead of a Union for reasons similar to those given for
# overloading MutableMapping.update in stdlib/typing.pyi
# The type: ignore is needed due to incompatible __or__/__ior__ signatures
@overload # type: ignore[misc]
def __ior__(self, other: Mapping[AnyStr, AnyStr]) -> Self: ...
@overload
def __ior__(self, other: Iterable[tuple[AnyStr, AnyStr]]) -> Self: ...
environ: _Environ[str]
if sys.platform != "win32":
environb: _Environ[bytes]
if sys.version_info >= (3, 14):
def reload_environ() -> None: ...
if sys.version_info >= (3, 11) or sys.platform != "win32":
EX_OK: Final[int]
if sys.platform != "win32":
confstr_names: dict[str, int]
pathconf_names: dict[str, int]
sysconf_names: dict[str, int]
EX_USAGE: Final[int]
EX_DATAERR: Final[int]
EX_NOINPUT: Final[int]
EX_NOUSER: Final[int]
EX_NOHOST: Final[int]
EX_UNAVAILABLE: Final[int]
EX_SOFTWARE: Final[int]
EX_OSERR: Final[int]
EX_OSFILE: Final[int]
EX_CANTCREAT: Final[int]
EX_IOERR: Final[int]
EX_TEMPFAIL: Final[int]
EX_PROTOCOL: Final[int]
EX_NOPERM: Final[int]
EX_CONFIG: Final[int]
# Exists on some Unix platforms, e.g. Solaris.
if sys.platform != "win32" and sys.platform != "darwin" and sys.platform != "linux":
EX_NOTFOUND: Final[int]
P_NOWAIT: Final[int]
P_NOWAITO: Final[int]
P_WAIT: Final[int]
if sys.platform == "win32":
P_DETACH: Final[int]
P_OVERLAY: Final[int]
# wait()/waitpid() options
if sys.platform != "win32":
WNOHANG: Final[int] # Unix only
WCONTINUED: Final[int] # some Unix systems
WUNTRACED: Final[int] # Unix only
TMP_MAX: Final[int] # Undocumented, but used by tempfile
# ----- os classes (structures) -----
@final
class stat_result(structseq[float], tuple[int, int, int, int, int, int, int, float, float, float]):
# The constructor of this class takes an iterable of variable length (though it must be at least 10).
#
# However, this class behaves like a tuple of 10 elements,
# no matter how long the iterable supplied to the constructor is.
# https://github.com/python/typeshed/pull/6560#discussion_r767162532
#
# The 10 elements always present are st_mode, st_ino, st_dev, st_nlink,
# st_uid, st_gid, st_size, st_atime, st_mtime, st_ctime.
#
# More items may be added at the end by some implementations.
if sys.version_info >= (3, 10):
__match_args__: Final = ("st_mode", "st_ino", "st_dev", "st_nlink", "st_uid", "st_gid", "st_size")
@property
def st_mode(self) -> int: ... # protection bits,
@property
def st_ino(self) -> int: ... # inode number,
@property
def st_dev(self) -> int: ... # device,
@property
def st_nlink(self) -> int: ... # number of hard links,
@property
def st_uid(self) -> int: ... # user id of owner,
@property
def st_gid(self) -> int: ... # group id of owner,
@property
def st_size(self) -> int: ... # size of file, in bytes,
@property
def st_atime(self) -> float: ... # time of most recent access,
@property
def st_mtime(self) -> float: ... # time of most recent content modification,
# platform dependent (time of most recent metadata change on Unix, or the time of creation on Windows)
if sys.version_info >= (3, 12) and sys.platform == "win32":
@property
@deprecated(
"""\
Use st_birthtime instead to retrieve the file creation time. \
In the future, this property will contain the last metadata change time."""
)
def st_ctime(self) -> float: ...
else:
@property
def st_ctime(self) -> float: ...
@property
def st_atime_ns(self) -> int: ... # time of most recent access, in nanoseconds
@property
def st_mtime_ns(self) -> int: ... # time of most recent content modification in nanoseconds
# platform dependent (time of most recent metadata change on Unix, or the time of creation on Windows) in nanoseconds
@property
def st_ctime_ns(self) -> int: ...
if sys.platform == "win32":
@property
def st_file_attributes(self) -> int: ...
@property
def st_reparse_tag(self) -> int: ...
if sys.version_info >= (3, 12):
@property
def st_birthtime(self) -> float: ... # time of file creation in seconds
@property
def st_birthtime_ns(self) -> int: ... # time of file creation in nanoseconds
else:
@property
def st_blocks(self) -> int: ... # number of blocks allocated for file
@property
def st_blksize(self) -> int: ... # filesystem blocksize
@property
def st_rdev(self) -> int: ... # type of device if an inode device
if sys.platform != "linux":
# These properties are available on MacOS, but not Ubuntu.
# On other Unix systems (such as FreeBSD), the following attributes may be
# available (but may be only filled out if root tries to use them):
@property
def st_gen(self) -> int: ... # file generation number
@property
def st_birthtime(self) -> float: ... # time of file creation in seconds
if sys.platform == "darwin":
@property
def st_flags(self) -> int: ... # user defined flags for file
# Attributes documented as sometimes appearing, but deliberately omitted from the stub: `st_creator`, `st_rsize`, `st_type`.
# See https://github.com/python/typeshed/pull/6560#issuecomment-991253327
# mypy and pyright object to this being both ABC and Protocol.
# At runtime it inherits from ABC and is not a Protocol, but it will be
# on the allowlist for use as a Protocol starting in 3.14.
@runtime_checkable
class PathLike(ABC, Protocol[AnyStr_co]): # type: ignore[misc] # pyright: ignore[reportGeneralTypeIssues]
__slots__ = ()
@abstractmethod
def __fspath__(self) -> AnyStr_co: ...
@overload
def listdir(path: StrPath | None = None) -> list[str]: ...
@overload
def listdir(path: BytesPath) -> list[bytes]: ...
@overload
def listdir(path: int) -> list[str]: ...
@final
class DirEntry(Generic[AnyStr]):
# This is what the scandir iterator yields
# The constructor is hidden
@property
def name(self) -> AnyStr: ...
@property
def path(self) -> AnyStr: ...
def inode(self) -> int: ...
def is_dir(self, *, follow_symlinks: bool = True) -> bool: ...
def is_file(self, *, follow_symlinks: bool = True) -> bool: ...
def is_symlink(self) -> bool: ...
def stat(self, *, follow_symlinks: bool = True) -> stat_result: ...
def __fspath__(self) -> AnyStr: ...
def __class_getitem__(cls, item: Any, /) -> GenericAlias: ...
if sys.version_info >= (3, 12):
def is_junction(self) -> bool: ...
@final
class statvfs_result(structseq[int], tuple[int, int, int, int, int, int, int, int, int, int, int]):
if sys.version_info >= (3, 10):
__match_args__: Final = (
"f_bsize",
"f_frsize",
"f_blocks",
"f_bfree",
"f_bavail",
"f_files",
"f_ffree",
"f_favail",
"f_flag",
"f_namemax",
)
@property
def f_bsize(self) -> int: ...
@property
def f_frsize(self) -> int: ...
@property
def f_blocks(self) -> int: ...
@property
def f_bfree(self) -> int: ...
@property
def f_bavail(self) -> int: ...
@property
def f_files(self) -> int: ...
@property
def f_ffree(self) -> int: ...
@property
def f_favail(self) -> int: ...
@property
def f_flag(self) -> int: ...
@property
def f_namemax(self) -> int: ...
@property
def f_fsid(self) -> int: ...
# ----- os function stubs -----
def fsencode(filename: StrOrBytesPath) -> bytes: ...
def fsdecode(filename: StrOrBytesPath) -> str: ...
@overload
def fspath(path: str) -> str: ...
@overload
def fspath(path: bytes) -> bytes: ...
@overload
def fspath(path: PathLike[AnyStr]) -> AnyStr: ...
def get_exec_path(env: Mapping[str, str] | None = None) -> list[str]: ...
def getlogin() -> str: ...
def getpid() -> int: ...
def getppid() -> int: ...
def strerror(code: int, /) -> str: ...
def umask(mask: int, /) -> int: ...
@final
class uname_result(structseq[str], tuple[str, str, str, str, str]):
if sys.version_info >= (3, 10):
__match_args__: Final = ("sysname", "nodename", "release", "version", "machine")
@property
def sysname(self) -> str: ...
@property
def nodename(self) -> str: ...
@property
def release(self) -> str: ...
@property
def version(self) -> str: ...
@property
def machine(self) -> str: ...
if sys.platform != "win32":
def ctermid() -> str: ...
def getegid() -> int: ...
def geteuid() -> int: ...
def getgid() -> int: ...
def getgrouplist(user: str, group: int, /) -> list[int]: ...
def getgroups() -> list[int]: ... # Unix only, behaves differently on Mac
def initgroups(username: str, gid: int, /) -> None: ...
def getpgid(pid: int) -> int: ...
def getpgrp() -> int: ...
def getpriority(which: int, who: int) -> int: ...
def setpriority(which: int, who: int, priority: int) -> None: ...
if sys.platform != "darwin":
def getresuid() -> tuple[int, int, int]: ...
def getresgid() -> tuple[int, int, int]: ...
def getuid() -> int: ...
def setegid(egid: int, /) -> None: ...
def seteuid(euid: int, /) -> None: ...
def setgid(gid: int, /) -> None: ...