Jelle Zijlstra
3e3cc2a6d6
dict.pop: Remove default for second argument ( #7481 )
...
The first overload takes care of the case where there is only one argument, so there should be no default in the second overload.
2022-03-13 13:11:35 +01:00
Alex Waygood
1a2f718ceb
Make several fields read-only for type, staticmethod and classmethod ( #7423 )
2022-03-06 15:50:26 -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
Martin Fischer
5802e889c7
Correct str.__new__ argument name ( #7422 )
2022-03-02 12:20:45 +02:00
Alex Waygood
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
4f0d8c593e
Delete EnumMeta.__setattr__ and EnumMeta.__delattr__ ( #7388 )
2022-02-26 17:55:53 -08:00
Alex Waygood
2d6ab4d3bf
Fix several mypy errors when run on the 3.11 stdlib ( #7389 )
2022-02-26 17:49:36 -08:00
Martin Fischer
51a3cf072c
Add comments about mypy limitation regarding TypeVar constraints ( #7350 )
2022-02-22 12:29:39 +01:00
Shantanu
94127ca2f5
builtins: add __build_class__ ( #7324 )
2022-02-20 16:16:07 -08:00
Alex Waygood
5e8a2a9364
Fix various pos-only stubtest complaints previously allowlisted ( #7228 )
2022-02-15 17:51:34 +01:00
Alex Waygood
f4967618dd
Fix positional-only differences in many stdlib modules ( #7226 )
2022-02-15 15:14:06 +01:00
Alex Waygood
a67c316d08
Add a few missing dunders in builtins ( #7214 )
2022-02-14 15:07:38 -08:00
Dmitry Volodin
be5a109c03
Fix zero exponent for ints ( #7163 )
2022-02-08 14:08:00 -08:00
Alex Waygood
b1b3471c76
Improve in-place BinOp methods for sets ( #7161 )
2022-02-08 14:57:50 +01:00
Alex Waygood
a62fd92fb0
Improve some in-place BinOp methods ( #7149 )
2022-02-06 15:36:57 -08:00
Jelle Zijlstra
c1e3be1248
zip.__iter__ and reversed.__iter__ return self ( #7123 )
2022-02-05 15:53:29 +02:00
Alex Waygood
7ccbbdb30a
stdlib: Improve many __iter__ and constructor methods ( #7112 )
2022-02-02 19:14:57 +01:00
Sebastian Rittau
2dc53caffe
Improve abc module and builtin function decorators ( #5703 )
2022-02-02 16:22:32 +01:00
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