Commit Graph

6177 Commits

Author SHA1 Message Date
Shantanu
a27f15ef0e builtins: reorder overloads (#7828)
This is slightly more friendly for --no-strict-optional (gross)
2022-05-11 01:00:52 -07:00
Shantanu
468d8adff1 stubtest_third_party: show package versions on failure (#7826)
Co-authored-by: hauntsaninja <>
2022-05-11 08:08:02 +02:00
Shantanu
75d2f6c881 statistics: improve type for median_grouped (#7825) 2022-05-11 08:06:35 +02:00
Jelle Zijlstra
b00b4f3447 regex: accept buffers (#7680)
Similar to #7679

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Co-authored-by: Akuli <akuviljanen17@gmail.com>
2022-05-10 15:08:36 -07:00
Jelle Zijlstra
68a781d04e Upgrade pytype (#7823) 2022-05-10 14:47:10 -07:00
Alex Waygood
f8547a3f31 Use flake8-pyi 22.5.0, remove redundant parts of check_new_syntax (#7821) 2022-05-10 09:34:41 -07:00
Alex Waygood
fed1f35c32 Remove explicit inheritance from object (#7819) 2022-05-10 16:24:53 +03:00
Sebastian Rittau
b211bf31a3 Update testing_engine() annotations (#7818) 2022-05-10 12:46:01 +03:00
Shantanu
550454c9aa beautifulsoup4: small fixes and updates (#7816) 2022-05-10 09:17:40 +02:00
Shantanu
032787d867 builtins: accept old-style iterables to iter (#7817) 2022-05-10 09:06:31 +02:00
Alex Waygood
ac30b96d14 Use str instead of Text (#7812) 2022-05-09 20:47:11 +01:00
Jelle Zijlstra
5c13f8bbce ast: FormattedValue.conversion cannot be None (#7810)
```
In [4]: ast.dump(ast.parse('f"{x!r}"'))
Out[4]: "Module(body=[Expr(value=JoinedStr(values=[FormattedValue(value=Name(id='x', ctx=Load()), conversion=114)]))], type_ignores=[])"

In [5]: ast.dump(ast.parse('f"{x}"'))
Out[5]: "Module(body=[Expr(value=JoinedStr(values=[FormattedValue(value=Name(id='x', ctx=Load()), conversion=-1)]))], type_ignores=[])"
```
(On 3.9 but I don't think this has changed since 3.6.)

The stdlib also assumes this: https://github.com/python/cpython/blob/main/Lib/ast.py#L1211 (`chr(None)` doesn't work).
2022-05-08 19:42:38 -07:00
Mix
32f474d6ef subprocess: improve Popen.returncode type (#7806) 2022-05-08 16:53:44 -07:00
Alex Waygood
8d8420bc54 Fix bugs in check_new_syntax.py (#7808) 2022-05-08 21:59:19 +01:00
Alex Waygood
bb39bdfd30 Add test cases for pow that are meant to fail a type check (#7760) 2022-05-08 08:16:37 -07:00
Julian
032d937bdf #7805: Ensure all references to mode are Literals, not str. (#7807) 2022-05-08 16:51:27 +02:00
Alex Waygood
3ed7e3ba50 csv: annotate keyword arguments in various functions and methods (#7788) 2022-05-07 21:01:20 -07:00
Alex Waygood
4e946b74bf csv.pyi: minor cleanup (#7790) 2022-05-07 10:49:27 +02:00
Alex Waygood
5c6178a821 Import generics from standard modules in all third-party stubs (#7791) 2022-05-07 10:35:50 +02:00
Akuli
6c6c669ada Run mypy_primer in all pull requests (#7804) 2022-05-07 09:58:53 +03:00
Jelle Zijlstra
6b5068b11d Add new arguments to subprocess.Popen (#7798) 2022-05-07 09:49:23 +03:00
Alex Waygood
16ca92fac7 Add http.HTTPMethod (#7784)
https://github.com/python/cpython/pull/91997

`description` isn't actually read-only at runtime, but I don't think there's any other way of telling type checkers "this is an attribute that the members have, not a member itself". And pretending it's a property is already what we do for `HTTPStatus`, which has the same issue.
2022-05-06 23:48:52 -07:00
Jelle Zijlstra
031c998055 enum: Add member and nonmember (#7795)
python/cpython#92366
2022-05-07 07:48:34 +01:00
Akuli
58f2e317c1 tkinter: add _windowingsystem() (#7803) 2022-05-06 23:45:47 -07:00
Jelle Zijlstra
2fc719d3cf tkinter: add info_patchlevel for 3.11 (#7794) 2022-05-07 09:25:55 +03:00
Jelle Zijlstra
963b8aa2f7 add os.login_tty for 3.11 (#7800)
python/cpython#29658
2022-05-06 22:54:58 -07:00
Jelle Zijlstra
4856064ed7 sys.flags: add safe_path for 3.11 (#7797)
python/cpython#31542
2022-05-06 22:50:30 -07:00
Jelle Zijlstra
ab1dcafec2 socket: add SO_INCOMING_CPU for 3.11 (#7801)
python/cpython#31237
2022-05-06 22:46:34 -07:00
Jelle Zijlstra
c93f262427 Add closure argument to exec() (#7793)
python/cpython#92204
2022-05-06 22:46:01 -07:00
Shantanu
e8b361983f bs4: update to 4.11 (#7785)
Co-authored-by: hauntsaninja <>
2022-05-06 11:54:50 -07:00
Alex Waygood
5f557176b4 _csv.pyi: minor cleanup (#7789) 2022-05-06 11:38:19 -07:00
Ilya Konstantinov
0b5213a213 flask-cors.decorator: allow re.Pattern objects to origins and allow_headers parameters (#7782) 2022-05-06 19:34:51 +01:00
Rebecca Chen
46fc7768c4 Add missing 'headers' property to urllib.error.HTTPError. (#7783)
Seen here: https://docs.python.org/3/library/urllib.error.html#urllib.error.HTTPError.headers
2022-05-05 14:05:51 -07:00
kasium
92c578546a Improve types of invoke/env.pyi (#7780) 2022-05-05 07:12:51 +01:00
Sebastian Rittau
460537c7f6 Add missing redis modules and classes (#7676)
This adds asyncio support and support for redis.typing.
2022-05-04 11:29:13 +02:00
Sam Ezeh
caaf0f1bf2 datetime: add UTC alias (#7779) 2022-05-04 00:00:08 -07:00
Jelle Zijlstra
b1ccd03d51 Add GenericAlias.__unpacked__ (#7774) 2022-05-03 15:41:45 +02:00
Sam Ezeh
ef878e925f Add weakref_slot parameter to @dataclass decorator (#7772)
https://github.com/python/cpython/pull/92160
2022-05-03 10:37:06 +01:00
Shantanu
4bcb1a95ab Upgrade paramiko (#7766) 2022-05-02 20:52:14 +02:00
Sam Ezeh
bf30fbd3d3 Add ZipFile.mkdir (new in 3.11) (#7769) 2022-05-02 07:32:37 -06:00
Jelle Zijlstra
d77d848975 contextlib: Use bound TypeVar (#7764) 2022-05-02 08:57:21 +02:00
Jelle Zijlstra
9effb643b3 logging.LoggerAdapter: Use a bound TypeVar (#7763) 2022-05-02 08:56:32 +02:00
Jim Crist-Harif
23e77931f9 Fix fields arg type in dataclass.make_dataclass (#7761)
The `fields` arg of `dataclass.make_dataclass` should have type:

```
Iterable[str | tuple[str, type] | tuple[str, type, Any]]
```

Previously the 3-tuple had type `tuple[str, type, Field[Any]]`, which
was incorrect for two reasons:

- The third element in the tuple doesn't have to be a ``Field``, it can
be any RHS value valid when defining a dataclass field (e.g.
``myfield: type = ...``). This may be a ``Field``, but it may also be a
default value like ``0``. ``Any`` is the proper type here.
- The type stubs for ``dataclass.field`` lie and say that this function
returns a value with the same type as ``default``. This avoids the need
for a mypy/pyright plugin that understands dataclasses, but also means
there is no way to create a ``Field`` object that these tools
understand, since they don't think ``dataclasses.field`` returns a
``Field`` instance.

With this change, the following valid dataclasses code passes both mypy
and pyright:

```python
from dataclasses import field, make_dataclass

Point = make_dataclass("Point", [("x", int), ("y", int), ("z", int, 0)])
Point2 = make_dataclass("Point2", [("x", int), ("y", int), ("z", int, field(default=0))])
```
2022-04-30 23:02:40 -06:00
Jovan Bebic
f05bfe0315 Fix paramiko channel.setblocking() argument (#7758)
Add 0,1 as allowed arguments using `Literal[0,1]`
2022-04-30 15:15:36 -06:00
Alex Waygood
c6b3211afa Improve test-suite documentation (#7756)
- mypy_test and pyright no longer just test the stubs, they now also test other parts of typeshed as well.
- pytype_test.py can now be run on 3.10, meaning the whole test suite can now also be run on 3.10.
- Various test scripts now have from `__future__ import annotations`, meaning they can now only be run on 3.7+.
- Clean up the description of pyright_test.py, which had a slightly confusing wording.
- Also fix the `--dry-run` config option in mypy_test.py, which I accidentally broke in #7746
2022-04-30 12:43:48 -06:00
fedor
e8e74ba26f Use object for value annotation in Enum.__new__ (#7752)
This pull request reverts part of #2539 that brought back a bug discussed in https://github.com/python/mypy/issues/5788 and initially fixed in #2539

In short, the issue was that the following program always resulted
in an error when running mypy with the `--disallow-any-expr` flag:

    from enum import Enum

    class MyEnum(Enum):
        FOO = 1
        BAR = 2

    blah = MyEnum   # Error here

The root issue was that because the signature of Enum's
`__new__` method was typed as:

    def __new__(self: Type[T], value: Any) -> T: ...

This caused mypy to decide that the type of `MyEnum` was
`(Any) -> MyEnum`. This is correct based on the current
type signature, but unfortunately means that it becomes
impossible to ever use enums with the `--disallow-any-expr` flag.
2022-04-30 12:36:35 -06:00
Jelle Zijlstra
7e7562b95b Add socket.TCP_CONNECTION_INFO (#7755)
python/cpython#69256
2022-04-30 09:24:09 -06:00
Jelle Zijlstra
e6623754e9 sqlite: Blob now uses ints in getitem/setitem (#7754)
I just merged python/cpython#92020 which implemented this change (thanks @erlend-aasland!).
2022-04-30 09:15:03 -06:00
Akuli
7d046654f1 Accept lists of tuples in tkinter.Canvas.create_foo() methods (#7722)
Fixes #7698.

At runtime, these methods call `tkinter._flatten()`, which recursively turns lists or tuples (but not other sequences) into a flat tuple of items. Unfortunately we don't have recursive types yet.
2022-04-30 06:52:56 -06:00
Sebastian Rittau
fa701ab0ee Run apt-get update before installing packages (#7749)
Fixes #7743
2022-04-30 06:42:23 -06:00