Commit Graph

112 Commits

Author SHA1 Message Date
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
Alex Waygood
34c91be7e4 Add @final to NotImplementedType and ellipsis (#6291)
These aren't subclassable at runtime. (Missed these two in my previous PR due to the fact that they're exposed in the `types` module, rather than builtins, at runtime. Also they're both a little weird to say the least, so let's see what the CI thinks...)
2021-11-13 18:45:49 -08:00
Alex Waygood
f6e697f93e Add @final to slice/memoryview/range (#6289)
None of these classes can be subclassed at runtime.
2021-11-13 18:03:56 -08:00
Alex Waygood
3324e2277e Improve stubs for __pow__ (#6287) 2021-11-12 14:09:26 -08:00
Alex Waygood
16a76a604b Make staticmethod/classmethod generic in their return type (#6285) 2021-11-12 17:35:05 +01:00
Alex Waygood
59408d9c9c Add __name__/__qualname__/__wrapped__ to staticmethod/classmethod (#6281) 2021-11-12 12:53:32 +01:00
Alex Waygood
bfdb87b9fd Make callable() return TypeGuard (#6274) 2021-11-12 12:21:53 +01:00
Alex Waygood
4eea13b60f Add `__call__ to staticmethod` (#6275) 2021-11-12 12:05:21 +01:00
Alex Waygood
7f93384e6b Make arguments positional-only for `int, memoryview, classmethod, staticmethod and BaseException` (#6272) 2021-11-09 19:56:09 +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
Alex Waygood
e3180cd48f Make args positional-only for applicable methods in `list and tuple` (#6259) 2021-11-08 09:47:56 -08:00
Jelle Zijlstra
7c3c9d1a10 Remove workaround for _dict_values (#6250)
The mypy issue was fixed
2021-11-07 15:13:05 -08:00
Alex Waygood
d5d0ba158e Make `__round__ positional-only for float, int, Decimal and SupportsRound` (#6242) 2021-11-07 15:05:18 -08:00