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
Itai Steinherz and GitHub
b9909b121e
Add missing typings to unittest.mock ( #7431 )
2022-03-06 15:43:39 -08:00
Alex Waygood and GitHub
bc72b25a2a
Make more miscellaneous fields read-only, annotate _json.make_encoder ( #7439 )
2022-03-06 15:41:49 -08:00
6cdecae6f9
Rename Github workflow ( #7445 )
...
Calling this "stubtest.yml" is a little confusing, since most of the
time stubtest is actually run out of "tests.yml". I renamed the workflow
in #7306 and this gets the filename to match.
Co-authored-by: hauntsaninja <>
2022-03-06 15:24:18 -08:00
Shantanu and GitHub
77e5a2d468
Upgrade to stubtest with dunder pos only reverted ( #7442 )
2022-03-05 18:38:08 -08:00
Alex Waygood and GitHub
cda3d9cf72
Use latest stubtest in CI ( #7438 )
2022-03-04 15:19:29 +01:00
Alex Waygood and GitHub
fbde20797e
Add tomllib.__all__ ( #7433 )
2022-03-03 15:25:30 -08:00
Taneli Hukkinen and GitHub
31b11c6eae
Add type hints for tomllib ( #7432 )
2022-03-03 15:04:33 -08:00
Alex Waygood and GitHub
c50cb066e0
Improve two classes which are namedtuples at runtime, but cannot be namedtuples in typeshed ( #7429 )
2022-03-03 07:22:40 -08:00
342e384fb1
Add threading._profile_hook ( #7427 )
...
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com >
2022-03-02 23:47:02 +02:00
Alex Waygood and GitHub
39c8202eaf
Increase pyright strictness when checking __all__ ( #7356 )
2022-03-02 03:31:21 -08:00
Jelle Zijlstra and GitHub
0a6b6b095c
Add asyncio.windows_utils.Popen ( #7396 )
2022-03-02 12:37:54 +02:00
Martin Fischer and GitHub
5802e889c7
Correct str.__new__ argument name ( #7422 )
2022-03-02 12:20:45 +02:00
Bas van Beek and GitHub
01244bb68f
Add annotations for missing disutils.extension.Extension attributes ( #7417 )
2022-03-01 21:08:11 -08:00
Bas van Beek and GitHub
cf12a2c88f
Fix the pickle_function parameter from copyreg.pickle ( #7415 )
...
The pickle functions should accept an instance of a to-be pickled object, not the respective type objects itself.
2022-03-01 21:05:36 -08:00
a5ec3c69b2
bs4: expose several other classes ( #7420 )
...
On the same lines as #7419
These are all imports that are not used within bs4/__init__.py
My main interest here is in exposing NavigableString
Co-authored-by: hauntsaninja <>
2022-03-01 17:59:11 -08:00
Sebastian Rittau and GitHub
24616d65d9
6-12 months -> six months ( #7411 )
...
"At least 6-12 months" is equivalent to "at least six months" and we
usually remove after six month, unless there are issues.
2022-03-01 17:37:53 -08:00
2f27eaab44
bs4: expose bs4.PageElement ( #7419 )
...
This is generally useful. It's also imported in the source without being
used in bs4/__init__.py which in well maintained packages is a pretty
good marker of intention to export
Co-authored-by: hauntsaninja <>
2022-03-01 16:59:50 -08:00
Alex Waygood and GitHub
fd750bf065
asyncio.unix_events: Make AbstractChildWatcher abstract, add PidfdChildWatcher (#7412 )
2022-03-01 16:23:46 +01:00
Sebastian Rittau and GitHub
7f2cf525e9
Add six.create_bound_method dunders to allowlist ( #7409 )
...
Closes : #7404
2022-03-01 07:16:49 -08:00
Sebastian Rittau and GitHub
000b466b21
Remove orjson stubs ( #7410 )
2022-03-01 10:59:31 +01:00
Shantanu and GitHub
ebcfe7bc4e
random: use bound methods ( #7408 )
2022-03-01 09:27:44 +01:00
Alex Waygood and GitHub
3bbc36c92d
Add two missing ForwardRef attributes ( #7402 )
...
These look somewhat like implementation details, but no more so than any of the other dunder attributes that are already on the class.
2022-02-28 21:44:28 -08:00
Alex Waygood and GitHub
1575c1b3b8
Add sys.__unraisablehook__ ( #7403 )
...
Docs [here](https://docs.python.org/3/library/sys.html#sys.__breakpointhook__ ). The similar functions `sys.__displayhook__` and `sys.__breakpointhook__` are already included in the stub.
2022-02-28 21:43:48 -08:00
Jelle Zijlstra and GitHub
cf3ea5b6e6
ctypes.memmove and memset return ints ( #7407 )
...
They actually return pointers, but ctypes turns them into ints.
Fixes #7406
2022-02-28 18:00:16 -08:00
Guido van Rossum and GitHub
47cccff9cb
asyncio.Task: .cancelling() and .uncancel() now return int, not bool ( #7405 )
2022-02-28 17:35:42 -08:00
Alex Waygood and GitHub
4b7d2a76cb
Add __all__ for pickle and turtle ( #7401 )
2022-02-28 14:50:29 -08:00
Shantanu and GitHub
b5f32a609a
random: add new default args in py311 ( #7400 )
2022-03-01 00:19:05 +02:00
Hugo and GitHub
ba1482bba4
Add DEFAULT_CIPHERS to urllib3.util.ssl_ ( #7399 )
2022-02-28 19:08:16 +01:00
Martin Fischer and GitHub
98d9ed44cd
docutils: complete nodes.Node & bump version to 0.18.* ( #7380 )
2022-02-28 17:59:56 +01:00
Rebecca Chen and GitHub
64133df6eb
Add stripe.util.convert_to_stripe_object ( #7386 )
2022-02-28 13:47:53 +01:00
Alex Waygood and GitHub
1ebedcc2b4
Mark fields as readonly in builtins.pyi and types.pyi ( #7392 )
...
Add FunctionType.__builtins__
2022-02-28 13:23:34 +01:00
Alex Waygood and GitHub
bf167d4df4
Add __all__ for asyncio.unix_events & asyncio.taskgroups, and simplify asyncio.__init__ ( #7343 )
2022-02-28 12:51:32 +01:00
Alex Waygood and GitHub
b8421eb5d4
Delete the contents of distutils.command.__init__ ( #7370 )
2022-02-27 16:43:11 -08:00
Alex Waygood and GitHub
a0b41959ec
stdlib: fix many attributes which are read-only at runtime but read-write in the stub ( #7395 )
2022-02-27 16:23:09 -08:00
Alex Waygood and GitHub
46da0b87ea
Add collections.ChainMap.__bool__ ( #7391 )
2022-02-27 16:02:01 -08:00
Alex Waygood and GitHub
95885c96ed
Add subprocess.__all__ ( #7390 )
2022-02-27 16:01:51 -08:00
Alex Waygood and GitHub
3000bb8d91
lib2to3: add Leaf.__unicode__ and Node.__unicode__ ( #7394 )
2022-02-27 14:49:28 -08:00
Alex Waygood and GitHub
4f0d8c593e
Delete EnumMeta.__setattr__ and EnumMeta.__delattr__ ( #7388 )
2022-02-26 17:55:53 -08:00
Alex Waygood and GitHub
2d6ab4d3bf
Fix several mypy errors when run on the 3.11 stdlib ( #7389 )
2022-02-26 17:49:36 -08:00
Alex Waygood and GitHub
95df201a78
Add tokenize.__all__ ( #7387 )
2022-02-26 16:35:55 -08:00
yejia-stripe and GitHub
ee8aa1e012
Improve annotation for stripe DeletableAPIResource delete method ( #7230 )
2022-02-25 08:04:36 -08:00
Sebastian Rittau and GitHub
3afcc1b2b1
Mark selenium stubs as obsolete ( #7383 )
2022-02-25 15:46:39 +01:00
Alex Waygood and GitHub
d2ddda00cf
Fix various __all__-related typos and omissions ( #7378 )
2022-02-25 15:10:00 +02:00
f4b43daba0
Update importlib.metadata typings for 3.10 ( #7331 )
...
Co-authored-by: Sebastian Rittau <srittau@rittau.biz >
2022-02-24 19:15:13 -08:00
Martin Fischer and GitHub
a342a49d38
docutils: Add missing dunders to nodes.Element ( #7377 )
2022-02-24 11:46:05 +01:00
Rebecca Chen and GitHub
da093c395c
Allow multiprocessing.pool.ThreadPool.__exit__ to accept None ( #7376 )
2022-02-23 19:21:25 -08:00
Alex Waygood and GitHub
6a743348ca
Add __all__ for most modules beginning with 't' ( #7373 )
2022-02-23 18:25:28 -08:00
Alex Waygood and GitHub
062fc75d73
Upgrade pytype to 22.2.23 ( #7375 )
...
Unblocks #7343
2022-02-23 17:39:27 -08:00
Fares Ahmed and GitHub
b55fed42ed
Add stubs for pynput package ( #7177 )
...
Fixes #4328
2022-02-23 23:10:20 +01:00