Commit Graph

6147 Commits

Author SHA1 Message Date
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
Alex Waygood
8b118b236d Run mypy on the test cases and test scripts (#7746) 2022-04-30 06:39:07 -06:00
Alex Waygood
9d450cb50c Make test scripts pass mypy --strict (#7745)
- Add several type hints to untyped functions.
- While we're at it, upgrade several annotations to use modern syntax by using `from __future__ import annotations`. This means that the tests can't be run on Python 3.6, but 3.6 is EOL, and it is already the case that some scripts in this directory can only be run on more recent Python versions. E.g. `check_new_syntax.py` uses `ast.unparse`, which is only available in Python 3.9+.
- Fix a few pieces of code that didn't type check.
2022-04-29 21:55:12 -06:00
Jelle Zijlstra
145e659482 inspect: Add positions attributes that will be new in 3.11 (#7688) 2022-04-29 17:00:37 -06:00
Akuli
205959917b sys: delete unnecessary python version check (#7742) 2022-04-29 22:58:36 +02:00
Akuli
e613fc483b Delete python 2 branches from third-party stubs (#7741)
Since #7703, we no longer have third-party stubs that support Python 2, so code like `if sys.version_info >= (3, 0)` can be simplified.
2022-04-29 20:53:01 +01:00
Alex Waygood
002c8e2586 Cleanup mypy_test.py (#7738) 2022-04-28 12:00:54 -06:00
Alex Waygood
c3ebc7e307 More improvements to pow stubs (#7737) 2022-04-28 10:49:29 -06:00
Sebastian Rittau
5df8de7693 Move a few protocol from builtins to _typeshed (#7736) 2022-04-28 17:36:47 +02:00
Sebastian Rittau
5535b7fc08 Update caldav stubs for 0.9 (#7734) 2022-04-28 17:56:43 +03:00
Milan Boers
f330e12f3e requests: allow non-mutable Mapping for files/hooks parameters (#7732) 2022-04-28 08:40:53 -06:00
Milan Boers
df06044ee8 requests: allow str and bytes for fileobj in files parameter (#7728)
* requests: allow str and bytes for fileobj in files parameter

* requests: Use SupportsRead instead of IO for files
2022-04-28 02:19:57 -06:00
Alex Waygood
59c346d031 cryptography: make oid attributes readonly (#7731) 2022-04-28 00:58:49 -06:00
Jelle Zijlstra
1deb9cb806 jack: Fix MidiPort properties (#7730)
Fixes #7729 

26b648a361/src/jack.py (L1950)

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2022-04-27 22:28:17 -06:00
Jelle Zijlstra
1f2a970b94 Upgrade mypy to 0.950 (#7726) 2022-04-27 19:25:02 +02:00
Alec Rosenbaum
63fb9af743 requests: Add None to a type alias (#7721)
Fixes #7720
2022-04-27 08:39:15 -06:00
Akuli
bfa918880f asyncio: expose WriteTransport.get_write_buffer_limits on all Python versions (#7718) 2022-04-27 16:38:25 +03:00
Sebastian Rittau
ff2feff7df dateutil.tz.tz: Replace IO with protocols (#7717) 2022-04-27 16:37:57 +03:00
Akuli
7576c5e1d5 asyncio: add missing methods to _FlowControlMixin (#7719) 2022-04-27 16:32:22 +03:00
Sebastian Rittau
02310d93da Update pyright to 1.1.240 (#7701) 2022-04-27 15:02:30 +02:00
Sebastian Rittau
f7aa41245e Drop Python 2 support in third-party stubs (#7703) 2022-04-27 15:32:17 +03:00
Sebastian Rittau
2d468966f5 Add various missing generic arguments (#7702)
Co-authored-by: Akuli <akuviljanen17@gmail.com>
2022-04-27 15:25:35 +03:00
Milan Boers
ae09e4e866 Add more typing hints for requests (#7696)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Co-authored-by: Akuli <akuviljanen17@gmail.com>
2022-04-27 14:40:20 +03:00
Sebastian Rittau
fa4677424a Remove Python 2 support from simplejson (#7704) 2022-04-27 11:57:29 +02:00
Sebastian Rittau
60f0497a72 Drop support for Python 2 in termcolor (#7707) 2022-04-27 12:56:38 +03:00
Sebastian Rittau
cfdff16e4e Drop Python 2 support from chardet (#7708) 2022-04-27 12:54:40 +03:00
Sebastian Rittau
03e1e3b4d3 Drop Python 2 support from python-gflags (#7709) 2022-04-27 12:54:12 +03:00
Sebastian Rittau
98aa6d75fe Drop Python 2 support from python-dateutil (#7715) 2022-04-27 12:52:46 +03:00
Sebastian Rittau
5edf5f0cc9 Remove Python 2 support from toml (#7713) 2022-04-27 12:52:28 +03:00
Sebastian Rittau
27af3dc6b1 Drop Python 2 support from click-spinner (#7710) 2022-04-27 12:49:27 +03:00
Sebastian Rittau
6245bc7432 Remove Python 2 support from entrypoints (#7711) 2022-04-27 12:47:50 +03:00