Alex Waygood
2f338ce077
Further improve mypy_test.py ( #7484 )
...
* Run mypy on the 3.11 stdlib in CI, as a regression test for https://github.com/python/mypy/issues/12220
* Correct the docstring at the top of the file following the changes made in #7478
* Stop the test from crashing when run locally if there's an extra file/folder in the stubs directory.
2022-03-13 19:58:30 +00:00
Jelle Zijlstra
fa332220b7
Fix mypy test ( #7478 )
...
* Fix `mypy_test.py` so that it actually tests the third-party stubs
* Upgrade to mypy 0.940
* Skip running mypy on `SQLAlchemy` stubs for now, to workaround a mypy crash.
Because we didn't set mypy's clean_exit parameter, it was exiting immediately after checking the stdlib, meaning `mypy_test.py` wasn't checking the third-party stubs at all.
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com >
2022-03-13 13:01:14 +00:00
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
8134752ad8
requests stubs are not Python 2-compatible (#7483 )
2022-03-13 13:06:34 +01:00
Alex Waygood
d3df6da103
parsimonious: re.Match does not exist in Python 3.6 ( #7482 )
...
It has to be imported from `typing` in <3.7.
Refs https://github.com/python/typeshed/pull/7478 .
2022-03-13 00:23:31 -08:00
Jelle Zijlstra
bd449c983a
urllib3: stubs are not Python 2 compatible ( #7480 )
...
They use http.client, which is Python 3-only. Another catch from #7478 .
2022-03-13 07:09:01 +00:00
Jelle Zijlstra
c89236d1cf
passlib: fix MutableMapping import ( #7479 )
...
Found by #7478
2022-03-12 19:18:48 -08:00
Joseph Young
3a9abf850a
Stubs for parsimonious ( #7477 )
2022-03-12 18:43:07 -08:00
Andrej Shadura
a5ddf0bf0d
Add xmltodict ( #7472 )
...
Signed-off-by: Andrej Shadura <andrew.shadura@collabora.co.uk >
2022-03-11 12:19:51 +01:00
Jelle Zijlstra
9c50fe7b64
Fix overly precise typing.NewType signature ( #7474 )
...
`type` is incorrect because `NewType` can also accept another `NewType`: https://peps.python.org/pep-0484/#newtype-helper-function
The return type was also wrong; pre-3.10 `NewType()` doesn't return a type object.
2022-03-11 06:35:45 +00:00
Aaron Kau
a3e62d56fc
change Change IO/IOBase.__exit__ return type to None ( #7471 )
2022-03-10 15:57:05 +01:00
Aaron Kau
bf2049ef18
Change TemporaryFileWrapper.__exit__ return type to None ( #7470 )
...
For context we found this from quora/pyanalyze#496 , which makes pyanalyze stricter about context managers that may swallow exceptions. tempfile._TemporaryFileWrapper.__exit__ returns whatever its underlying file returns (https://github.com/python/cpython/blob/3.6/Lib/tempfile.py#L502 ), and file objects don't tend to return anything from __exit__.
2022-03-09 19:34:24 -08:00
Alex Waygood
9a1f5fb06c
Modernize syntax in various stubs ( #7469 )
...
Use `str` and `contextlib.AbstractContextManager` instead of `typing.Text` and `typing.ContextManager`.
2022-03-09 21:23:26 +00:00
Sebastian Rittau
cdb573b398
Remove explicit inheritance from object ( #7468 )
2022-03-09 19:43:44 +01:00
Sebastian Rittau
6df2274a41
Inactive maintainers policy ( #7467 )
...
Closes : #7449
2022-03-09 19:28:05 +01:00
Sebastian Rittau
c3907ab26b
Remove Python 2 support from some third-party distributions ( #7466 )
...
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com >
2022-03-09 20:19:22 +02:00
Alex Waygood
4e87b9058f
Improve collections.Counter stub ( #7464 )
2022-03-09 12:22:28 +02:00
Patrick Rauscher
c987c78077
Remove ClassVar from SSLContext.ssl{object,socket}_class ( #7465 )
...
These attributes have class-level defaults, but the docs explicitly state that it's OK to override them on instances.
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com >
2022-03-09 08:53:18 +00:00
Shantanu
9c737f1326
Re-enable stubtest on SQLAlchemy ( #7456 )
2022-03-09 07:34:12 +01:00
Akuli
f9cb7c3ed4
Use Literal for statistics.quantiles() ( #7463 )
...
I'm going to merge; I think this is consistent with what we've done with e.g. the `byteorder` argument for `int.from_bytes` :)
2022-03-08 21:38:31 +00:00
Akuli
6c967d4202
Update cachetools to 5.0.0 ( #7455 )
...
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com >
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2022-03-08 19:20:22 +00:00
Sebastian Rittau
889164cb0c
psycopg2: Annotate cursor execute* and dunder methods ( #7460 )
2022-03-08 08:13:19 -08:00
Alex Waygood
db6f912c77
Improve mmap.mmap.__enter__ ( #7461 )
...
It returns `Self` at runtime, not `mmap.mmap`, so inheriting from `AbstractContextManager` doesn't really do anything for us.
2022-03-08 07:47:56 -08:00
Bas van Beek
70988f1811
Widen the cmdclass parameter of setuptools.setup ( #7458 )
2022-03-08 15:07:44 +02:00
Henry Schreiner
967f83db09
rlcompleter: add attr_matches, global_matches ( #7453 )
...
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com >
2022-03-08 00:07:58 +00:00
Alex Waygood
f4ae363b56
stdlib: correct many pos-or-kw arg names in dunder methods ( #7451 )
2022-03-07 16:40:03 +01:00
Alex Waygood
626ccdaee2
Add @AlexWaygood as a maintainer ( #7450 )
2022-03-07 15:08:19 +00:00
Akuli
30a424c661
Finish renaming stubtest.yml to daily.yml ( #7448 )
2022-03-07 11:09:24 +02:00
Jelle Zijlstra
675de720d6
Add some missing items to sys.pyi and types.pyi ( #7447 )
2022-03-07 08:22:08 +01:00
Alex Waygood
947724a5cb
stdlib: Add several missing @abstractmethod decorators ( #7443 )
2022-03-06 16:41:13 -08:00
Jelle Zijlstra
2fb9c35ff9
Put shutil.chown back on Windows ( #7446 )
...
See #7384 and https://github.com/python/typeshed/pull/7443#issuecomment-1060071944 (thanks @AlexWaygood for diagnosing).
2022-03-06 16:27:24 -08:00
Sebastian Rittau
addce5c067
Add passlib stubs ( #7024 )
2022-03-06 16:25:00 -08:00
Sebastian Rittau
7e5d2a58aa
Add openpyxl stubs ( #6801 )
2022-03-06 16:24:17 -08:00
Martin Fischer
8034c1c48c
stdlib: shutil.chown does not work on Windows ( #7384 )
2022-03-06 16:04:05 -08:00
Martin Fischer
d63dc4b002
stdlib: dbm.gnu & dbm.ndbm are only available on Unix ( #7384 )
2022-03-06 16:04:05 -08:00
Martin Fischer
8138981492
stdlib: socket.CMSG_LEN & socket.CMSG_SPACE are only available on Unix ( #7384 )
2022-03-06 16:04:05 -08:00
Martin Fischer
af269057be
stdlib: Add errno.EDEADLK
2022-03-06 15:57:52 -08:00
Martin Fischer
182ddd9daf
stdlib: Add os.get_handle_inheritable & setter
2022-03-06 15:57:52 -08:00
Martin Fischer
aa383624cf
stdlib: Add missing re-exports for UuidCreate, FCICreate, OpenDatabase & CreateRecord
2022-03-06 15:57:52 -08:00
Martin Fischer
77829c5c99
stdlib: Add sys._enablelegacywindowsfsencoding()
2022-03-06 15:57:52 -08:00
Martin Fischer
ec87fbfe88
stdlib: Add email.iterators._structure(msg)
2022-03-06 15:57:52 -08:00
Martin Fischer
352f5c3237
stdlib: Add os.copy_file_range(src, dst, count)
2022-03-06 15:57:52 -08:00
Martin Fischer
0978ef5c60
stdlib: Add signal.pidfd_send_signal(pidfd, sig)
2022-03-06 15:57:52 -08:00
Martin Fischer
81a85f18b6
stdlib: Add os.pidfd_open(pid)
2022-03-06 15:57:52 -08:00
Martin Fischer
9abf314a5b
stdlib: Add time.pthread_getcpuclockid(thread_id)
2022-03-06 15:57:52 -08:00
Martin Fischer
14ac9f7557
stdlib: Add urllib.parse.unwrap(url)
2022-03-06 15:57:52 -08:00
Alex Waygood
1a2f718ceb
Make several fields read-only for type, staticmethod and classmethod ( #7423 )
2022-03-06 15:50:26 -08:00
Alex Waygood
ea6e06a60d
Use bound methods in pydoc ( #7426 )
2022-03-06 15:49:15 -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
Itai Steinherz
b9909b121e
Add missing typings to unittest.mock ( #7431 )
2022-03-06 15:43:39 -08:00