Commit Graph

66 Commits

Author SHA1 Message Date
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
Jelle Zijlstra
6d318e729f Broaden type for set.union (#6249)
`set[int].union(set[str])` is well defined: it returns a set of `int | str`.
2021-11-05 13:27:45 -07:00
Alex Waygood
e7b4b73102 Make args positional-only for `str, bytes and bytearray` (#6248) 2021-11-05 20:53:22 +01:00
Alex Waygood
ac9b0746ec Make method parameters positional-only in `dict, set, frozenset and enumerate` (#6247) 2021-11-05 20:14:07 +01:00
Alex Waygood
8ba9d11cbe Make dunder method args positional-only for object (#6246) 2021-11-05 19:19:08 +01:00
Alex Waygood
a36dc9032f Make `complex and float` dunder methods have positional-only args (#6241) 2021-11-04 22:37:25 +01:00
Alex Waygood
e608205c05 Make bool() args positional-only (#6239) 2021-11-04 20:16:35 +01:00
Alex Waygood
6ed392ba5f Make `type()` method params positional-only (#6238) 2021-11-04 11:48:34 -07:00
Alex Waygood
d0964d2221 Make super() parameters positional-only (#6237) 2021-11-04 11:13:41 -07:00
Alex Waygood
aa9cd1e80e Make `range` parameters positional-only (#6236) 2021-11-04 10:56:16 -07:00
Alex Waygood
4cbc657167 Make getattr() parameters positional-only (#6235) 2021-11-04 18:28:33 +01:00
Alex Waygood
26f2c702d3 Make slice parameters positional-only (#6234) 2021-11-04 15:29:15 +01:00
Alex Waygood
e2ee7c297d Make property method args positional-only (#6231) 2021-11-03 09:33:08 -07:00
Kyle Altendorf
9052674aa8 bytes.fromhex() returns cls instance, not bytes (#6201)
```console
$ cat y.py
import typing

class MyBytes(bytes):
    pass


x = MyBytes.fromhex("abcd")
if typing.TYPE_CHECKING:
    reveal_type(x)
else:
    print(x.__class__.__name__)
```

```console
$ for v in 3.6 3.7 3.8 3.9 3.10; do echo -n "$v: " ; python$v y.py; done
3.6: MyBytes
3.7: MyBytes
3.8: MyBytes
3.9: MyBytes
3.10: MyBytes
```

```console
$ venv/bin/mypy y.py
y.py:9: note: Revealed type is "builtins.bytes"
```
2021-10-25 16:28:33 -07:00
Akuli
994b69ef8f Use lowercase tuple where possible (#6170) 2021-10-14 17:18:19 -07:00
Marti Raudsepp
c38c03bab8 builtins: next() does not allow keyword args for default (#6169) 2021-10-14 09:51:58 +02:00
Shantanu
55cf343ba9 zip: update for PEP 618 (#6123)
Resolves #6122

Co-authored-by: hauntsaninja <>
2021-10-06 12:54:47 -07:00
Akuli
196f69b27e dict.__init__: support dict(string.split(sep) for string in iterable) (#6050) 2021-09-20 13:52:41 +02:00
KotlinIsland
1b5c4e1d57 Add support for dict.{keys,values,items}.mapping (#6039)
Co-authored-by: KotlinIsland <kotlinisland@users.noreply.github.com>
2021-09-19 22:30:14 -07:00
Sebastian Rittau
b562d233ae (a)next only requires __(a)next__, not Iterator (#6036) 2021-09-14 11:43:21 +03:00
Gabe Joseph
92aecadf6b Memoryview.cast: shape= can be tuple of any number of ints (#5918) 2021-08-13 00:04:35 +02:00
Bas van Beek
7edad1034e Use a typevar in object.__new__ (#5891) 2021-08-08 20:45:22 +02:00
Akuli
ce11072dbe Big diff: use lower-case list and dict (#5888) 2021-08-08 09:26:35 -07:00
Akuli
ef5b4b6820 setattr: Any --> object (#5877) 2021-08-08 11:12:23 +02:00
Akuli
ee487304d7 Big diff: Use new "|" union syntax (#5872) 2021-08-08 11:05:21 +02:00
Ron Frederick
309e7bda32 Update builtins.pyi (#5874)
Change getattr/hasattr first argument from Any to object

Fixes #5848
2021-08-07 20:46:03 -07:00
Bas van Beek
475417fa97 Mark final and unhashable classes in types as such (#5837) 2021-08-02 13:46:14 -07:00
Bas van Beek
7c37d6117d Allow reversed to take any object implementing __len__ and __getitem__ (#5820)
`reversed` is currently annotated as accepting either a `Sequence` or objects implementing the `__reversed__` protocol.
This however is too strict as, per its [docs](https://docs.python.org/3/library/functions.html#reversed), it can take any object that implements `__len__` and `__getitem__`.
2021-07-29 07:48:14 -07:00
Bas van Beek
5e23e2c19a Use SupportsIndex where applicable in builtins.pyi (#5739)
* Use `SupportsIndex` where applicable in `builtins.pyi`

* Remove `None` from the `int.__round__` ndigits parameter
2021-07-09 13:08:19 +03:00
Akuli
b06352556d Use Literal["little", "big"] for byteorder (#5715) 2021-06-30 13:15:50 -07:00
Anton Grübel
c38171a0b3 Use _typeshed.Self with __enter__ (#5712) 2021-06-29 15:19:25 -07:00
Bas van Beek
50f5858a56 Use SupportsIndex where applicable for 5 classes (#5694)
Use `SupportsIndex` where applicable:

* `str`
* `bytes`
* `bytearray`
* `memoryview`
* `markupsafe.Markup`
2021-06-26 19:05:40 +03:00
Sebastian Speitel
04d81a8499 Allow merging dicts of different types (#5520) 2021-06-16 06:03:15 -07:00
Ethan Smith
cb76f32826 Allow passing complex to complex constructor (#5609) 2021-06-09 22:58:22 +02:00
Shantanu
04fb7ceb3c builtins: add a getattr overload for bool (#5518)
As brought up in https://github.com/python/typeshed/pull/5516

Alternatives include:
- Use another type var that has a value restriction
- Doing something fancy with Protocols that have a __bool__ that returns
  a Literal (which may not work)
- Doing nothing
2021-05-29 07:09:38 -07:00
Jelle Zijlstra
c4da3757d7 Improve tuple.__add__ type (#5522)
Noticed this while browsing the stub. This feels safe but we'll see what mypy-primer has to say.
2021-05-26 22:17:30 +02:00
Neil Vyas
8d56328a24 change getattr stubs to better type the default argument and return type (#5516)
Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com>
Co-authored-by: Akuli <akuviljanen17@gmail.com>
2021-05-21 16:44:11 -07:00
Andrey
dbaaa3a103 PEP 604: Add ror operator and modify isinstance and subclass (#5509)
Add operators or and ror for types.Union and ror to the type class.
Also, add modified isinstance and issubclass signatures to support old-style and new-style unions inside.
2021-05-21 16:30:27 -07:00
Sebastian Rittau
acca3181ed Improve dict.fromkeys() with None value (#5514)
Closes: #5512
2021-05-21 20:30:33 +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
Adrian Freund
a2058829fa Make memoryview inherit from Sequence (#5393) 2021-05-10 12:46:17 +02:00
sachindavra
1048250c04 ror implementation (#5369)
Signed-off-by: sachindavra <raju.davra@gmail.com>
2021-05-07 21:10:07 +03:00
James
dbaf4c6390 Improve `type.__new__` (#5331)
Fixes #3386
2021-05-03 18:33:29 -07:00
Shantanu
1517438aba builtins: more updates for py310 (#5290) 2021-05-01 21:58:39 -07:00
Shantanu
0ea437f02a builtins: use SupportsLessThan over SupportsLessThanT if possible (#5288)
Co-authored-by: hauntsaninja <>
2021-05-01 21:39:25 -07:00
Eric Traut
58e083fef9 Marked the bool class as @final because it cannot be subclassed. (#5286)
Co-authored-by: Eric Traut <erictr@microsoft.com>
2021-05-01 21:38:10 -07:00
Shantanu
445a86f4c9 builtins: add aiter, anext (#5289) 2021-05-01 21:10:30 -07:00