Commit Graph
100 Commits
Author SHA1 Message Date
Jelle Zijlstra 0322fb0905 errno: fix typo and add missing constants (#7553) 2022-03-25 20:30:26 +01:00
Jelle Zijlstra fa9074366b Revert "Remove google/__init__.pyi (#6106)" (#7522)
This reverts commit a11a6643a7.
2022-03-21 19:49:00 +01:00
Jelle Zijlstra b7d129f727 PEP 604: Remove some more uses of Union/Optional (#7515)
The following patterns still break mypy:

1. `type[]` at top level fails
2. `tuple[T1, T2]` at top level fails (but `tuple[T1, ...]` is fine)
3. `T1 | Callable[..., T2 | T3]` fails, but only <=3.9

This PR cleans up usage of `Union` and `Optional` outside these patterns.
2022-03-19 08:23:00 -07:00
Jelle Zijlstra d9f1f7b81f pytz: utcoffset only returns None if dt is None (#7510) 2022-03-19 08:19:09 +00:00
Jelle Zijlstra 4d23919200 Add typing.TypeVarTuple, Unpack, assert_type (#7501)
python/cpython#31021 and python/cpython#30843.
2022-03-18 18:03:45 +00:00
Jelle Zijlstra ba475a04c3 multiprocessing: args can be any Iterable (#7500)
https://github.com/python/cpython/blob/main/Lib/multiprocessing/process.py#L91
2022-03-17 01:44:25 +00:00
Jelle ZijlstraandAlex Waygood 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
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
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
Jelle Zijlstra 675de720d6 Add some missing items to sys.pyi and types.pyi (#7447) 2022-03-07 08:22:08 +01: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
Jelle Zijlstra 0a6b6b095c Add asyncio.windows_utils.Popen (#7396) 2022-03-02 12:37:54 +02:00
Jelle Zijlstra cf3ea5b6e6 ctypes.memmove and memset return ints (#7407)
They actually return pointers, but ctypes turns them into ints.

Fixes #7406
2022-02-28 18:00:16 -08:00
Jelle Zijlstra 4781dbf752 smtpd: MailmanProxy was removed in 3.11 (#7365)
python/cpython#26617
2022-02-22 17:06:39 -08:00
Jelle Zijlstra 61361ce059 contextvars, pycurl: make classes final (#7334) 2022-02-20 16:55:48 -08:00
Jelle Zijlstra 319d23a16e Add PEP 646 and 675 to typing-extensions (#7198) 2022-02-14 08:59:11 +01:00
Jelle Zijlstra 7dd2485269 New additions to typing, typing_extensions (#7169) 2022-02-08 22:40:09 -08:00
Jelle Zijlstra c1e3be1248 zip.__iter__ and reversed.__iter__ return self (#7123) 2022-02-05 15:53:29 +02:00
Jelle Zijlstra 2b72dea679 Allow ExitStack.push callbacks to return None (#7090) 2022-01-31 08:21:32 +01:00
Jelle Zijlstra 3b29006a3e email.generator: Use protocols instead of TextIO/BinaryIO (#7082) 2022-01-30 14:02:11 +01:00
Jelle Zijlstra d5101dced7 Fix float.__rpow__ (#7047)
Fixes #7046.
2022-01-26 19:18:42 -08:00
Jelle Zijlstra c8471ea631 use flake8-pyi 22.1.0 (#7004) 2022-01-23 12:43:48 -08:00
Jelle Zijlstra 3d28f0981f bs4: Expose bs4.SoupStrainer and bs4.Tag (#7002) 2022-01-23 19:11:38 +02:00
Jelle Zijlstra de5ec6a0d1 fix incorrect tuple[T] (#6996)
Found from PyCQA/flake8-pyi#135.
2022-01-22 09:37:14 -08:00
Jelle ZijlstraandShantanu 1f000d2881 Improve type for setdefault() (#6941)
- With one argument, it may return None
- With two arguments, it returns the default's type or the dict's value type.
- Also remove incorrect `= ...` from `pop()`. The one-argument case has its own overload.

Context: https://github.com/python/typing/discussions/1033#discussioncomment-1986359

Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com>
2022-01-19 21:44:15 -08:00
Jelle Zijlstra 30580a3732 disable Y026 in typing.pyi too (#6959) 2022-01-18 20:14:55 -08:00
Jelle Zijlstra 65a8825e2f Disable Y026 from flake8-pyi (#6958)
Dependent on PyCQA/flake8-pyi#101.
2022-01-18 20:07:34 -08:00
Jelle Zijlstra a0d748de2f Revert "Temporarily fix redis version to 4.1.0" (#6957)
This reverts commit 7d2de33bba.
2022-01-18 15:09:19 -08:00
Jelle Zijlstra ea93779c92 Fix TypeVar argument annotations (#6943)
Arguments like bound= accept type forms like unions, which are not themselves types.
2022-01-18 00:14:40 -08:00
Jelle Zijlstra 01f3f8abf6 Remove staticmethod.__new__ and classmethod.__new__ (#6934) 2022-01-17 09:50:04 +01:00
Jelle Zijlstra 0949e9e90d remove quoted strings (#6933) 2022-01-16 14:29:13 -08:00
Jelle Zijlstraandpre-commit-ci[bot] 85318d1b21 Cleanup: do not quote types unnecessarily (#6931)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2022-01-16 20:18:17 +02:00
Jelle Zijlstra 339bfbbfaa remove "= ..." from top-level values (#6930) 2022-01-16 18:38:00 +02:00
Jelle Zijlstra e53aa04eb2 Add typing_extensions.is_typeddict (#6923) 2022-01-15 17:02:23 -08:00
Jelle Zijlstra 1a0e0a4023 urllib3: allow allowed_methods to be False (#6909) 2022-01-13 15:26:56 +01:00
Jelle Zijlstra a4b30c4360 fix typo in _SplitCondition definition (#6903) 2022-01-12 19:51:24 +02:00
Jelle Zijlstra 49d2fa5f9d put redis.client._ScoreCastFuncReturn back (#6876)
#6829 removed it as unused but #6790 added a usage.
2022-01-09 19:03:51 +02:00
Jelle ZijlstraandSebastian Rittau b0453811ed add (Base)ExceptionGroup (#6655)
Co-authored-by: Sebastian Rittau <srittau@rittau.biz>
2021-12-22 07:56:35 -08:00
Jelle Zijlstra 85712073ac Remove duplicate type from ArgumentParser.add_argument (#6652) 2021-12-22 08:59:23 +01:00
Jelle Zijlstra 14268f64e5 Widen MutableMapping.update type (#6653) 2021-12-22 08:54:05 +01:00
Jelle Zijlstra e3ea71c018 Add comment to LogRecord.message (#6654) 2021-12-22 08:49:35 +01:00
Jelle ZijlstraandSebastian Rittau 5205efcaa4 Fix Redis.zpopmin and zpopmax (#6642)
Co-authored-by: Sebastian Rittau <srittau@rittau.biz>
2021-12-21 07:57:46 -08:00
Jelle Zijlstra 183a43a7e0 Fixes to curses stubs (#6620) 2021-12-17 18:39:00 +01:00
Jelle Zijlstra 868732098e inspect._ParameterKind.description is a property (#6587) 2021-12-15 13:39:42 +02: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
Jelle Zijlstra 943dc5f61d More permissive type for random.choice and related functions (#6562) 2021-12-10 19:50:02 +01:00
Jelle Zijlstra 7d4d58925a typing: update comments (#6558) 2021-12-09 21:15:27 -08:00
Jelle Zijlstra 384e309f53 pytz: rework stubs (#6551) 2021-12-09 09:24:44 +01:00
Jelle ZijlstraandAlex Waygood 72ee95bc0b operator: make Protocol parameters positional-only (#6519)
pyanalyze checks parameter names for protocols strictly, so `float` didn't match these protocols.

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2021-12-06 10:49:24 -08:00
Jelle Zijlstra 57e211b306 dependency upgrades (#6505) 2021-12-06 01:27:53 +02:00
Jelle Zijlstra 178b6bb8f4 csv: Make _Writer.write positional-only (#6475)
At runtime it only uses positional parameters.

I think this works fortuitously in mypy and pyright because mypy ignores parameter names in protocols and pyright has a bug that allows passing positional-only to pos-or-keyword params (microsoft/pyright#2652) and the parameter to `io.TextIO.write` happens to be `__s`.
2021-12-02 13:27:21 -08:00
Jelle ZijlstraandAkuli 2836e537c2 Fix _operator.indexOf signature (#6435)
Co-authored-by: Akuli <akuviljanen17@gmail.com>
2021-11-29 12:39:03 +02:00
1f1bc6f27c add pre-commit config (#6341)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Akuli <akuviljanen17@gmail.com>
2021-11-19 16:46:51 +02:00
Jelle Zijlstra 0d7064c357 Make Mapping/MutableMapping params positional-only (#5772)
These are positional-only on dict, so it makes sense to mark them as positional-only in these base classes too.

Fixes #5771
2021-11-18 07:54:58 +01:00
Jelle Zijlstra 0860a911e9 typing_extensions: add Self, Required, NotRequired (#6296) 2021-11-14 23:45:35 +01:00
Jelle Zijlstra 9eabedca5f Make NoReturn a SpecialForm (#6290)
This is consistent with the runtime definition: https://github.com/python/cpython/blob/main/Lib/typing.py#L434.

The previous definition was wrong; NoReturn is not and should not be equivalent to None. This fixes an issue in pyanalyze where it was interpreting NoReturn as equivalent to None.
2021-11-12 17:34:44 -08:00
Jelle Zijlstra fecf258b42 typing_extensions.get_type_hints exists only in 3.7+ (#6283) 2021-11-12 17:45:25 +02:00
Jelle ZijlstraandSebastian Rittau 98e5112195 Improve pymysql.converters stubs (#6267)
I spent far too much time being confused about why pyanalyze thought `pymysql.converters.escape_dict` only takes two arguments.

I rewrote the stubs from scratch using the implementation: https://github.com/PyMySQL/PyMySQL/blob/main/pymysql/converters.py.

The "charset" argument is ignored as far as I can tell; it gets passed to other functions but no function actually uses it.

Co-authored-by: Sebastian Rittau <srittau@rittau.biz>
2021-11-09 07:57:29 -08:00
Jelle Zijlstra 7c3c9d1a10 Remove workaround for _dict_values (#6250)
The mypy issue was fixed
2021-11-07 15:13:05 -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
Jelle Zijlstra 5f386b0575 Make args to AsyncContextManager.__aexit__ positional-only (#6172)
We already do this for `ContextManager.__exit__`. Should fix microsoft/pyright#2435.
2021-10-14 17:15:57 -07:00
Jelle Zijlstra e1b9ab3372 Remove redundant import from typing (#5827)
Fixes quora/pyanalyze#221.
2021-07-30 22:55:33 -07:00
Jelle Zijlstra 7f320c6b9e Stubs for beautifulsoup4 (#5758)
Stubgen and manual fixes, don't bother with Python 2
2021-07-11 17:02:51 +03:00
Jelle Zijlstra a90573feb2 tornado: add some types, set version (#5742) 2021-07-11 13:17:40 +02:00
Jelle Zijlstra 80591d9f99 Fix aiofiles.base.AsyncBase.__iter__ (#5750)
Fixes #5725.

This doesn't actually work properly in mypy.
2021-07-11 10:58:10 +03:00
Jelle ZijlstraandAkuli 14d7431ff1 Recommend Self in CONTRIBUTING.md (#5699)
Part of #5676.

Co-authored-by: Akuli <akuviljanen17@gmail.com>
2021-06-27 23:17:28 +03:00
Jelle Zijlstra 5fe2459779 Make SigParameter.replace and Signature.replace return Self (#5689) 2021-06-24 18:01:58 +02:00
Jelle Zijlstra 73b4c21cce Make ZipFile.__enter__ return self (#5675) 2021-06-22 17:01:11 +02:00
Jelle Zijlstra e58070cd35 socket: allow ReadableBuffer on send* methods (#5648) 2021-06-16 15:36:56 +02:00
Jelle Zijlstra 04627bfb83 Update PEP 612 status in CONTRIBUTING.md (#5635)
And add a new "Partially supported" section
2021-06-14 17:20:27 +02:00
Jelle Zijlstra 4581501c98 use ParamSpec for @contextmanager (#5476) 2021-06-14 16:38:39 +02:00
Jelle Zijlstra 967d0b2167 Add self type to requests.Session.__enter__ (#5620)
Fixes microsoft/pyright#1976
2021-06-11 16:48:48 +02:00
Jelle Zijlstra bfc83c365a Use PEP 604 in types.pyi (#5553) 2021-05-29 11:09:50 -07:00
Jelle Zijlstra b2e3c4f1d7 improve inspect.pyi (#5473)
- Use TypeGuard for various is* functions (refer to #5406)
- Use collections.abc and builtin containers
2021-05-29 19:32:39 +02:00
Jelle Zijlstra e47eff31f7 bump various dependencies (#5551) 2021-05-29 20:05:09 +03: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
Jelle Zijlstra c4e3fd92cc Adjust types for asyncio.coroutines functions (#5517)
Noticed this in mypy-primer output in #5516 on this code: https://github.com/encode/starlette/blob/master/starlette/testclient.py#L74

It calls `iscoroutinefunction()` on an object that may be None, which got flagged as an error but is actually fine; it just returns False.

We could also potentially use TypeGuard here, especially for `iscoroutine` which is just an `isinstance` call.
2021-05-21 23:07:06 +02:00
Jelle Zijlstra 19d6129624 Add __contains__ to gdbm.gnu (#5511)
Fixes #5510
2021-05-21 15:46:01 +02:00
Jelle Zijlstra 620cf38152 pyaudio: don't use ClassVar[Final] (#5498) 2021-05-18 19:25:14 -07:00
Jelle Zijlstra bce19fc206 make GeneratorType inherit from Generator (#5474)
Fixes #5496
2021-05-18 13:31:14 -07:00
Jelle Zijlstra 02be4b5da2 Add section on supported type-system features (#5479) 2021-05-17 09:30:45 +02:00
Jelle Zijlstra a47ee3245a fix renamed Python 2 modules (#5450) 2021-05-14 14:36:00 -07:00
Jelle Zijlstra 33bdde6ec4 Update maintainers list (#5430)
I removed a few people who have not been active in the typing area for a long time, and added @rchen152 who is active on the repo and has commit rights. There are a few other people who have access to the repo but are not active. Listing them here does not seem useful.
2021-05-12 17:16:09 -07:00
Jelle Zijlstra e14085014f more thorough documentation for VERSIONS (#5395) 2021-05-11 06:56:14 -07:00
Jelle Zijlstra 5f591a1a12 fix VERSIONS (#5329) 2021-05-07 08:43:22 +02:00
Jelle Zijlstra 38dfb57adf Improve asyncio.subprocess stubs (#5327) 2021-05-02 21:50:29 -07:00
Jelle Zijlstra 2c8cb60596 Fix permissions for mypy-primer-comments (#5259)
Based on https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#permissions
2021-04-27 18:05:20 +02:00
Jelle Zijlstra cb108516f6 add cProfile.Profile.stats (#5246)
* add cProfile.Profile.stats

* also add to profile.pyi
2021-04-24 18:28:22 +03:00
Jelle ZijlstraandShantanu fc0db5f2b6 Add a suggestion to CONTRIBUTING.md (#5205)
Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com>
2021-04-11 06:50:08 -07:00
Jelle Zijlstra 97c6806582 Revert "Awaitable.__await__ should accept an Iterator rather than a Generator (#5194)" (#5195)
This reverts commit c687e297ec.
2021-04-09 09:49:39 +02:00
Jelle Zijlstra 30fc2b8cd0 fix positional-only arguments to str and bytes (#5112) 2021-03-12 15:33:25 -08:00
Jelle Zijlstra 3e9ed39bec remove "Union[str, str]" (#4838)
I grepped and didn't find any other instances of redundant unions like this one.
2020-12-18 14:13:41 -06:00
Jelle Zijlstra 301325b55b Make _GeneratorContextManager covariant (#4733)
Fixes  #4732
2020-10-30 17:31:55 -07:00
Jelle Zijlstra 5f9fd3d127 upgrade black version (#4486)
Manually removed a number of trailing commas to prevent black from unnecessarily
exploding some collections.
2020-08-26 18:36:01 +02:00
Jelle Zijlstra 0142a87da8 adjust isort config (#4290)
Fixes #4288.

- Default imports to THIRD_PARTY, so in effect we merge the FIRST_PARTY and THIRD_PARTY stubs. This means import order is no longer affected by whether typing_extensions is installed locally.
- Treat typing_extensions, _typeshed and some others as standard library modules.

Note that isort master is very different from the latest release; we'll have to do something
different if and when the next isort release comes out.
2020-06-29 00:00:21 -07:00
Jelle Zijlstra 5d553c9584 apply black and isort (#4287)
* apply black and isort

* move some type ignores
2020-06-28 13:31:00 -07:00
Jelle Zijlstra e1d89e5742 remove references to "Text" in Python 3-only stubs (#4251) 2020-06-22 12:39:01 +02:00
Jelle Zijlstra f67ea2031a xml.etree: use _typeshed (#4221) 2020-06-11 12:41:57 -07:00