Shantanu
b88a6f19cd
Upgrade black version ( #7089 )
2022-01-30 16:27:06 -08:00
Jelle Zijlstra
d5101dced7
Fix float.__rpow__ ( #7047 )
...
Fixes #7046 .
2022-01-26 19:18:42 -08:00
Akuli
a22ca2ec51
make the default positional-or-keyword in Mapping.get and MutableMapping.pop ( #6694 )
2022-01-22 07:19:01 -08:00
Jasha10
7c4ca27083
builtins.filter compat with typing.TypeGuard (#6726 )
...
This change enables the following use-case:
```python
def is_not_none(x: Optional[int]) -> TypeGuard[int]:
return x is not None
list_optional: list[Optional[int]] = [0, None, 1, None, 2]
generate_ints: Iterable[int] = filter(is_not_none, list_optional)
```
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com >
2022-01-21 20:48:02 -08:00
Alex Waygood
aea52b35d1
Remove nearly all __str__ and __repr__ methods from typeshed ( #6968 )
2022-01-20 00:45:11 +01:00
Alex Waygood
2170693e11
Add various __*or__ methods, and improve dict.__ior__ ( #6961 )
2022-01-19 12:24:16 +01:00
Jelle Zijlstra
01f3f8abf6
Remove staticmethod.__new__ and classmethod.__new__ ( #6934 )
2022-01-17 09:50:04 +01:00
Nikita Sobolev
f42de016b8
Remove misleading comment from staticmethod and classmethod ( #6907 )
2022-01-13 12:59:28 +01:00
Jelle Zijlstra
a4b30c4360
fix typo in _SplitCondition definition ( #6903 )
2022-01-12 19:51:24 +02:00
Alex Grönholm
143d57690e
Corrected (Base)ExceptionGroup names and types ( #6895 )
...
The second argument to `ExceptionGroup` is positional-only. The `exceptions` property always returns a tuple, no matter what the type of the original `__exceptions` argument is.
2022-01-11 15:02:08 -08:00
Alex Waygood
96c9abb058
Always use _typeshed.Self, where applicable ( #6880 )
...
* Always use `_typeshed.Self`, where applicable
* Revert changes to `google-cloud-ndb` (ambiguous)
* Remove empty line added by script
* Revert changes to `stubs/python-dateutil/dateutil/relativedelta.pyi`
* Manually add a few more that the script missed
* Improve `filelock` annotation
Source code here: 79ec7b2826/src/filelock/_api.py (L207)
* Improve `opentracing/scope` annotation
Source code here: 3e1d357a34/opentracing/scope.py (L71)
* Improve `redis/client` stub
Source code here: 15f315a496/redis/client.py (L1217)
* Improve `redis/lock` annotation
Source code here: 15f315a496/redis/lock.py (L155)
* Improve `requests/models` annotation
Source code here: d718e75383/requests/models.py (L653)
2022-01-09 19:16:19 -08:00
Alex Waygood
a0b5deda40
All instance attributes on memoryview are read-only ( #6878 )
...
* All instance attributes on `memoryview` are read-only
* [pre-commit.ci] auto fixes from pre-commit.com hooks
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2022-01-09 12:07:09 -08:00
Alex Waygood
4e046163b5
Delete many redundant method redefinitions ( #6877 )
2022-01-09 11:21:03 -08:00
Nikita Sobolev
35c1d4f879
Remove __slots__ from builtins.object ( #6800 )
2022-01-09 18:27:24 +02:00
Alex Waygood
a40d79a4e6
Use lowercase type everywhere ( #6853 )
2022-01-08 16:09:29 +01:00
Alex Waygood
9558b36a45
range and slice: start, stop, step are read-only ( #6849 )
2022-01-07 19:17:28 +02:00
Alex Waygood
df6f701ba4
builtins: Fix from_bytes() and fromhex() return type ( #6842 )
2022-01-07 00:43:04 +02:00
Akuli
a7886bfa55
Fix several typos in comments ( #6830 )
2022-01-05 18:44:34 +01:00
Akuli
b5666d473d
Improve comments of builtins.function ( #6818 )
2022-01-04 14:04:33 -06:00
Joseph Young
ff64deb331
Add missing function attributes to builtins.function ( #6804 )
...
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com >
2022-01-04 20:41:59 +02:00
Alex Waygood
505ea72641
Never explicitly inherit from object in Python 3-only stubs ( #6777 )
2022-01-02 07:24:48 +01:00
Alex Waygood
8d5d2520ac
Use PEP 585 syntax wherever possible ( #6717 )
2021-12-28 11:31:43 +01:00
Alex Waygood
1ec2387da1
Fix 'object.__reduce__' ( #6662 )
...
Reverts regressions introduced by #6292 . Fixes #6661 .
2021-12-22 12:08:43 -08:00
Jelle Zijlstra
b0453811ed
add (Base)ExceptionGroup ( #6655 )
...
Co-authored-by: Sebastian Rittau <srittau@rittau.biz >
2021-12-22 07:56:35 -08:00
Sebastian Rittau
387ef81883
Return Supports(A)Next from (a)iter ( #6035 )
...
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com >
2021-12-20 19:15:59 -08:00
Pavel Karateev
b1b958def2
Add __note__ to BaseException in Python 3.11 ( #6633 )
2021-12-20 07:27:04 -08:00
Jukka Lehtosalo
7cd533e6a4
Fix unnecessary use of type variable in max() ( #6584 )
2021-12-14 07:43:06 -08:00
Alex Waygood
5670ca2f75
Add SupportsRichComparison type to _typeshed ( #6583 )
...
Use it to improve types of `max()` and other functions.
Also make some other tweaks to types related to comparison dunders.
Fixes #6575
2021-12-14 14:12:23 +00:00
Jelle Zijlstra
88c8a5829e
More precise return type for sum() ( #6573 )
...
It returns 0 on an empty iterable, and that's the only int it can return for arbitrary iterables.
2021-12-12 16:58:01 -08:00
Alex Waygood
a774e52fae
Correct builtins.help ( #6571 )
2021-12-12 17:09:34 +02:00
Alex Waygood
1718b77a1a
Remove redundant method redefinitions in builtins ( #6545 )
2021-12-08 16:29:07 +01:00
Alex Waygood
f105c79219
Harmonise UserDict.__init__ with dict.__init__ ( #6490 )
...
Co-authored-by: Akuli <akuviljanen17@gmail.com >
2021-12-04 19:50:47 +02:00
Alex Waygood
9e0ee447c6
Harmonise UserDict.fromkeys with dict.fromkeys ( #6488 )
2021-12-04 13:56:30 +01:00
Alex Waygood
a293f1e73f
Add OrderedDict.fromkeys ( #6485 )
2021-12-03 22:06:51 +02:00
Shantanu
eb16dcc2c1
builtins: change aiter argument name ( #6412 )
2021-11-28 11:41:49 +02:00
Alex Waygood
df8472f586
Improve UnicodeTranslateError stub ( #6397 )
2021-11-27 16:48:36 +02:00
Alex Waygood
98af7d667f
Improve stubs for sequence types ( #6386 )
2021-11-26 19:09:38 -08:00
Pavel Karateev
b459329cec
Add __complex__ to complex and __bytes__ to bytes for Python 3.11 ( #6369 )
2021-11-23 13:28:53 -08:00
Jukka Lehtosalo
25649bc1e5
Add getattr overload variants to help mypy type inference ( #6355 )
...
These silence errors about missing type annotations for calls
like these:
```
x = getattr(o, 'a', [])
y = getattr(o, 'b', {})
```
This is basically a generalization of #5518 and other overloads we already
have.
This works around python/mypy#11572 . I encountered the issue in several
places when testing recent typeshed against an internal repo.
2021-11-22 11:08:40 +00:00
Sebastian Rittau
a6e369906d
max() uses SupportsGreaterThanT ( #6342 )
...
Add SupportsGreaterThan and SupportsGreaterThanT
Closes : #6336
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com >
2021-11-21 13:28:46 +01:00
Alex Waygood
5c8e68f0eb
Use lowercase set, frozenset and deque where possible ( #6346 )
2021-11-19 15:05:45 -08:00
Sebastian Rittau
77810277d5
Recommend to use mypy error codes if applicable ( #6305 )
2021-11-17 21:58:05 -08:00
Alex Waygood
48cfe5d2f4
Further improve pow ( #6325 )
2021-11-17 21:33:17 -08:00
Alex Waygood
fbb89f9fd5
Fix isort w.r.t. _ast/_collections_abc/_tracemalloc/_warnings ( #6329 )
2021-11-17 08:29:44 -08:00
Alex Waygood
ce6458cf2b
Use _typeshed.SupportsTrunc in builtins ( #6326 )
2021-11-16 18:45:46 -08:00
Alex Waygood
aa2290e160
Fix print stub ( #6314 )
2021-11-16 20:11:40 +02:00
Alex Waygood
fd48026e64
Bring _collections_abc closer to runtime definition ( #6312 )
2021-11-16 09:41:22 -08:00
Alex Waygood
1274445941
Resolve builtins/importlib inconsistencies ( #6310 )
2021-11-16 15:19:21 +01:00
Alex Waygood
aa7e277adb
Harmonise return type of builtins.__import__ and importlib.import_module ( #6302 )
...
builtins.__import__ now returns ModuleType instead of Any. In addition, add __getattr__() to ModuleType to ease using imported modules.
2021-11-15 16:21:46 +01:00
Alex Waygood
88f86a0180
Reduce use of Any in builtins ( #6292 )
2021-11-14 14:02:52 -08:00