Alex Waygood
ceccc655db
Introduce _typeshed.GenericPath and _typeshed.AnyStr_co ( #7970 )
2022-05-27 19:02:00 +01:00
Jelle Zijlstra
963b8aa2f7
add os.login_tty for 3.11 ( #7800 )
...
python/cpython#29658
2022-05-06 22:54:58 -07:00
Alex Waygood
97a74bc1aa
Import from collections.abc wherever possible ( #7635 )
2022-04-18 12:50:37 +02:00
Alex Waygood
740193a8fc
Use TypeAlias where possible for type aliases ( #7630 )
2022-04-15 18:01:00 -07:00
Alex Waygood
414f324083
Add missing __match_args__ attributes to several unix-only structseq classes ( #7587 )
2022-04-04 21:33:49 +01:00
Alex Waygood
da3e69d093
stdlib: Improve a bunch of __(a)exit__ methods ( #7571 )
2022-04-01 08:05:25 +02:00
Alex Waygood
61b22db692
Add many missing __match_args__ attributes ( #7556 )
...
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com >
2022-03-26 19:36:28 +00:00
Alex Waygood
b63c963077
Use conditional overloads to simplify several stdlib functions ( #7540 )
2022-03-25 08:47:03 +01:00
Jelle Zijlstra
b7d129f727
PEP 604: Remove some more uses of Union/Optional ( #7515 )
...
The following patterns still break mypy:
1. `type[]` at top level fails
2. `tuple[T1, T2]` at top level fails (but `tuple[T1, ...]` is fine)
3. `T1 | Callable[..., T2 | T3]` fails, but only <=3.9
This PR cleans up usage of `Union` and `Optional` outside these patterns.
2022-03-19 08:23:00 -07:00
Alex Waygood
3ab250eec8
Use PEP 604 syntax wherever possible ( #7493 )
2022-03-16 16:01:33 +01:00
Alex Waygood
f4ae363b56
stdlib: correct many pos-or-kw arg names in dunder methods ( #7451 )
2022-03-07 16:40:03 +01:00
Alex Waygood
947724a5cb
stdlib: Add several missing @abstractmethod decorators ( #7443 )
2022-03-06 16:41:13 -08:00
Martin Fischer
182ddd9daf
stdlib: Add os.get_handle_inheritable & setter
2022-03-06 15:57:52 -08:00
Martin Fischer
352f5c3237
stdlib: Add os.copy_file_range(src, dst, count)
2022-03-06 15:57:52 -08:00
Martin Fischer
81a85f18b6
stdlib: Add os.pidfd_open(pid)
2022-03-06 15:57:52 -08:00
Shantanu
9796b9ed69
Improve open overloads when mode is a literal union ( #7428 )
...
As pointed out by @gvanrossum in https://github.com/python/typing/issues/1096
Improves type inference in cases when we know that mode is
OpenBinaryMode, but don't know anything more specific:
```
def my_open(name: str, write: bool):
mode: Literal['rb', 'wb'] = 'wb' if write else 'rb'
with open(name, mode) as f:
reveal_type(f) # previously typing.IO[Any], now typing.BinaryIO
```
You may be tempted into thinking this is some limitation of type
checkers. mypy does in fact have logic for detecting if we match
multiple overloads and union-ing up the return types of matched
overloads. The problem is the last overload interferes with this logic.
That is, if you remove the fallback overload (prior to this PR), you'd get
"Union[io.BufferedReader, io.BufferedWriter]" in the above example.
Co-authored-by: hauntsaninja <>
2022-03-06 15:45:34 -08:00
Alex Waygood
bc72b25a2a
Make more miscellaneous fields read-only, annotate _json.make_encoder ( #7439 )
2022-03-06 15:41:49 -08:00
Alex Waygood
d6ce3abd68
Add __all__ to most modules beginning with 'n', 'o' and 'p' ( #7345 )
2022-02-21 17:57:03 -08:00
Alex Waygood
26e8959279
Use _typeshed.Self in docutils.VersionInfo and os.sched_param ( #7117 )
2022-02-02 23:30:39 +01:00
Shantanu
b88a6f19cd
Upgrade black version ( #7089 )
2022-01-30 16:27:06 -08:00
Alex Waygood
dbcb38a605
Add more missing methods to os._Environ ( #6926 )
2022-01-16 06:45:11 -08:00
Matt Bogosian
f55dff80f0
Override os._Environ.__ior__ ( #6921 )
...
Supporting the `|=` operator for `os.environ` was introduced in Python 3.9. However,
this led to false negatives in type checking statements like `os.environ |= {"k": "v"}`
and `os.environ |= [("k", "v")]` because the definition inherited from
`typing.MutableMapping` was insufficient. This addresses that deficiency.
Fixes #6919 .
2022-01-15 15:52:31 -08:00
Joseph Young
e6f28c052e
Accept PathLike[bytes] in os.listdir ( #6870 )
2022-01-09 16:17:01 +02:00
Akuli
a7886bfa55
Fix several typos in comments ( #6830 )
2022-01-05 18:44:34 +01:00
Alex Waygood
6ff9020603
Clean up os.statvfs_result ( #6828 )
2022-01-05 14:53:12 +02:00
Alex Waygood
496313d875
Add various missing os constants ( #6753 )
2021-12-30 15:21:30 +02:00
Alex Waygood
8d5d2520ac
Use PEP 585 syntax wherever possible ( #6717 )
2021-12-28 11:31:43 +01:00
Alex Waygood
0b75d71303
Add a structseq class to _typeshed ( #6560 )
...
Co-authored-by: Akuli <akuviljanen17@gmail.com >
2021-12-17 13:42:09 -08:00
Shantanu
d84a03829f
Revert addition of class_getitem to PathLike ( #6591 )
...
This was added in #5869
This breaks all PathLike classes that don't have class_getitem
2021-12-15 19:25:08 -08:00
Akuli
7155bdae63
Re-export more os functions in posix, tweak availability on linux ( #6529 )
2021-12-07 16:10:41 +01:00
Alex Waygood
415d387009
Make various os functions available on Windows ( #6500 )
2021-12-05 22:06:22 +02:00
Akuli
ea3f962860
Move all definitions except environ from posix to os ( #6442 )
2021-12-01 17:07:33 +01:00
Alex Waygood
cc5a3ca9e2
Add os.waitstatus_to_exitcode ( #6444 )
2021-11-29 15:22:42 +02:00
Akuli
6d54c10387
Make posix module empty on windows ( #6427 )
2021-11-28 07:54:30 -08:00
Akuli
a5bc1e037f
Add mypy error codes to '# type: ignore' comments ( #6379 )
2021-11-26 07:07:56 +01:00
Alex Waygood
a9cfd23fc3
Further reduce use of deprecated contextlib aliases ( #6370 )
2021-11-23 15:25:39 -08:00
Alex Waygood
029cf555e7
Use lowercase set/deque in stdlib subdirectories ( #6350 )
2021-11-20 04:20:25 -08:00
Alex Waygood
10c9d8cfce
Add @final to many unsubclassable stdlib classes ( #6299 )
2021-11-15 14:45:24 +01:00
luzpaz
b95b729b9e
Fix typos ( #6263 )
...
Found via `codespell -q 3 -L alo,asend,ba,nams,spawnve`
2021-11-08 18:23:15 -08:00
Akuli
994b69ef8f
Use lowercase tuple where possible ( #6170 )
2021-10-14 17:18:19 -07:00
Oleg Höfling
64f481189f
drop ellipsis assignments from module vars, classvars and instance attrs ( #5914 )
...
Signed-off-by: oleg.hoefling <oleg.hoefling@gmail.com >
2021-08-11 19:26:58 +02:00
Akuli
9af9cca7f3
lowercase list and dict in the rest of stdlib ( #5892 )
2021-08-09 00:13:08 +02:00
Akuli
df6a211855
Use new union syntax in rest of stdlib ( #5884 )
2021-08-08 15:44:30 +02:00
Anton Grübel
39ede0242c
add missing type hints for __class_getitem__ ( #5869 )
2021-08-07 16:12:53 +02:00
an onion
f30d6f6fd0
Add stubs for posix_spawn and posix_spawnp ( #5846 )
2021-08-05 18:55:26 -07:00
Anton Grübel
d68701c0ec
Use _typeshed.Self with __enter__ ( #5723 )
...
Co-authored-by: Sebastian Rittau <srittau@rittau.biz >
Co-authored-by: Akuli <akuviljanen17@gmail.com >
2021-07-04 21:10:01 +03:00
Sebastian Rittau
f0bf6eebbd
AnyStr cleanup ( #5487 )
...
* Replace all uses of StrPath, BytesPath, and AnyPath in Python 2 stubs.
* Add StrOrBytesPath as preferred alias for AnyPath.
* Replace all remaining AnyPath instances with StrOrBytesPath.
* Mark AnyPath as obsolete.
Part of #5470
2021-05-17 20:45:48 +02:00
Sebastian Rittau
e5abd08f93
Replace PathLike unions with aliases from _typeshed ( #5467 )
...
Standardize on 'from os import PathLike'
2021-05-16 21:38:00 +02:00
Shantanu
dd73f117f0
os: fix positional-only args ( #5412 )
...
Co-authored-by: hauntsaninja <>
2021-05-11 10:47:12 +02:00
Shantanu
a91c89ea94
various path stubs: re-export to reduce duplication ( #5382 )
...
Co-authored-by: hauntsaninja <>
Co-authored-by: Akuli <akuviljanen17@gmail.com >
2021-05-10 22:27:13 -07:00