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 Zijlstra and Akuli
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 Zijlstra and Shantanu
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
Jelle Zijlstra
8100c0be89
subprocess: use AnyPath ( #4218 )
2020-06-11 09:15:10 +02:00
Jelle Zijlstra
d0b85d7efe
remove _types ( #4220 )
2020-06-11 09:10:52 +02:00
Jelle Zijlstra
44a852dff5
Literal: always import from typing_extensions for simplicity ( #4219 )
2020-06-10 21:23:58 -07:00
Jelle Zijlstra
43e93f803f
use _typeshed's Path aliases ( #4214 )
2020-06-10 20:57:09 -07:00
Jelle Zijlstra and Shantanu
d261f14886
add constructors for configparser errors ( #4215 )
...
Fixes #4058
Co-authored-by: Shantanu <hauntsaninja@users.noreply.github.com >
2020-06-10 12:32:18 -07:00
Jelle Zijlstra
ea577cec1f
move OpenTextMode and friends to _typeshed ( #4213 )
2020-06-10 15:36:21 +02:00
Jelle Zijlstra
adeda24fce
open: introduce concrete return types ( #4146 )
...
* make io classes inherit from typing IO classes
This makes these classes usable if type annotations are given as "IO"
or "TextIO". In the future, we'll then be able to move open() to
return a concrete class instead (#3951 ).
* open: introduce concrete return types
Fixes #3951 .
We use the values of the "mode" and "buffering" arguments to figure out
the concrete type open() will return at runtime. (Compare the CPython
code in https://github.com/python/cpython/blob/master/Modules/_io/_iomodule.c#L231 .)
2020-06-01 00:48:12 +02:00
Jelle Zijlstra
3058bec873
make io classes inherit from typing IO classes ( #4145 )
...
This makes these classes usable if type annotations are given as "IO"
or "TextIO". In the future, we'll then be able to move open() to
return a concrete class instead (#3951 ).
2020-05-30 06:50:49 -07:00
Jelle Zijlstra
c80622fbb9
remove type ignores about python/mypy#5027 ( #4119 )
...
The mypy issue got fixed by the good people of mypy. I did have to add an
override for __enter__ similar to what we're doing in #4082 .
2020-05-28 09:51:54 -07:00
Jelle Zijlstra
0cffa59e57
use a Protocol for str.format_map() ( #4122 )
...
Fixes #3824
2020-05-28 13:27:57 +02:00
Jelle Zijlstra
ca553cd589
fix type for ipaddress._BaseNetwork.overlaps ( #4124 )
2020-05-28 13:22:50 +02:00
Jelle Zijlstra and Shantanu
4a9fdcc7fc
uuid: update for py39 ( #4023 )
...
Closing the long loop started in #3715
Co-authored-by: Shantanu <hauntsaninja@users.noreply.github.com >
2020-05-16 21:30:45 -07:00
Jelle Zijlstra
d55df54ae2
upgrade flake8 ( #3980 )
2020-05-13 08:52:40 +02:00
Jelle Zijlstra
23e380ac83
add overload to difflib.get_close_matches ( #3908 )
...
Fixes #3906 . Fixes #2067 .
2020-04-05 14:12:29 +02:00
Jelle Zijlstra
e9a9103afc
bring back attribute types in warnings.WarningMessage ( #3810 )
...
Signed-off-by: Oleg Höfling <oleg.hoefling@gmail.com >
2020-03-05 17:15:13 -08:00
Jelle Zijlstra
6a4044fd9b
Make frozenset covariant ( #3808 )
...
The convariance was lost in #1057
2020-03-04 19:24:03 -08:00
Jelle Zijlstra
6b751ef408
shutil: Fix rmtree type ( #3536 )
...
See my comment in https://github.com/python/typeshed/issues/3533#issuecomment-563366251 .
2019-12-21 12:29:59 -08:00
Jelle Zijlstra
5021b30711
functools: remove first type param of cached_property ( #3553 )
...
Fixes #3547
This removes some type safety in exceptional cases, like code that interacts
directly with cached_property objects, but that seems like a price worth
paying.
2019-12-21 10:42:43 -08:00
Jelle Zijlstra
97f830030c
Simplify WatchedFileHandler.__init__ ( #3506 )
...
Fixes #3502
2019-12-03 14:54:29 +01:00
Jelle Zijlstra
d215f502c6
Improve warnings stubs ( #3501 )
...
* merge 2and3 for _warnings
* move warn and warn_explicit into _warnings
2019-12-03 14:33:37 +01:00
Jelle Zijlstra
1f0dc6ee05
timeout argument to urllib.request.urlopen is Optional ( #3487 )
...
The docs (https://docs.python.org/3/library/urllib.request.html#urllib.request.urlopen ) aren't very precise about this, but passing `None` seems to work in practice.
2019-11-24 12:51:33 +01:00
Jelle Zijlstra
a89f883878
stream argument to pprint.pprint is Optional ( #3488 )
...
None is the default; see https://docs.python.org/3/library/pprint.html#pprint.PrettyPrinter
2019-11-24 12:29:43 +01:00
Jelle Zijlstra
cd5cd12a35
asyncio: fix windows stubs ( #3424 )
2019-10-30 08:13:32 -07:00
Jelle Zijlstra
c38cf6736e
Allow callables in _SourceObjectType ( #3295 )
...
This is important because mypy doesn't generally think functions are compatible with `FunctionType`, so `inspect.getsource` on arbitrary functions is rejected by the current annotations.
2019-10-03 00:52:21 +02:00
Jelle Zijlstra
d05a9d3d83
Improve enums ( #3168 )
...
I realized while working on srittau/type-stub-pep#64 that a
few things we do in existing enum definitions in typeshed are
problematic:
- Using "= ..." doesn't allow type checkers to correctly type the
result of Enum.MEMBER.value. In fact, mypy at least infers
.value to be "Ellipsis" if you do this.
- Properties on the enum values themselves, like HTTPStatus.phrase,
should not be specified directly as attributes, because it makes
type checkers think that the properties themselves are enum
members.
I ended up doing a bit more cleanup to the signal module:
- Remove unnecessary ... initializers.
- Remove unnecessary _SIG = Signals alias.
- I don't have Windows to test, but the C code for _signal suggests
that CTRL_C_EVENT and CTRL_BREAK events are not Signals, but just ints:
https://github.com/python/cpython/blob/1dbd084f1f68d7293718b663df675cfbd0c65712/Modules/signalmodule.c#L1575
2019-08-05 08:08:57 -07:00
Jelle Zijlstra
b0c9fa4530
fix type of loop.sock_connect ( #3073 )
2019-06-21 17:31:51 +02:00
Jelle Zijlstra
ada0570efc
Revert "Define functools.partial as overloaded function instead of its own class ( #2878 )" ( #3077 )
...
This reverts commit e45f443d85 .
2019-06-20 20:39:49 -07:00
Jelle Zijlstra
cd9b7158ec
fix CI ( #2992 )
2019-05-15 14:20:08 -07:00
Jelle Zijlstra
b5493e8639
add types.FunctionType.__init__ ( #2968 )
...
Fixes #2930
2019-05-07 17:31:01 +02:00
Jelle Zijlstra
d7e9af4492
allow callables in dis() ( #2969 )
...
Fixes #2914
2019-05-07 17:21:54 +02:00
Jelle Zijlstra
bdb1de57f5
narrow signature of __contains__ for str-like classes ( #2967 )
...
Fixes #2937
2019-05-07 10:24:28 -04:00
Jelle Zijlstra
8bd744a38f
fix type of msg argument to HTTPRedirectHandler.redirect_request ( #2949 )
...
It's not really documented (https://docs.python.org/3/library/urllib.request.html#urllib.request.HTTPRedirectHandler.redirect_request ), but logically a message is a str, and reading the code for the stdlib confirms that it's intended to be a str.
2019-05-03 20:44:56 +02:00
Jelle Zijlstra
ff650d3275
socket: add .set_inheritable() ( #2935 )
2019-04-28 17:13:20 +02:00
Jelle Zijlstra
ce2b8a838c
reword "What to include" ( #2861 )
2019-04-08 19:02:01 +02:00
Jelle Zijlstra
832bf52c28
asyncio: make type alias private and CamelCase ( #2849 )
2019-03-11 08:43:00 +01:00
Jelle Zijlstra
14e387b6fd
fix some minor lint errors ( #2820 )
...
Caught by a newer version of flake8
2019-03-01 12:29:23 +01:00
Jelle Zijlstra
b5897d5643
fix undefined name in flask stub ( #2811 )
2019-02-23 10:28:03 +01:00
Jelle Zijlstra
2aee28cb6f
fix missing space in imghdr ( #2812 )
2019-02-23 10:26:51 +01:00
Jelle Zijlstra
78690405cf
add back StopIteration.value in Python 3 ( #2744 )
...
Fixes python/mypy#6209 .
2019-01-16 19:21:16 -08:00
Jelle Zijlstra
46ab77eb20
loop argument to asyncio.ensure_future is Optional ( #2708 )
...
The default value is None: https://github.com/python/cpython/blob/master/Lib/asyncio/tasks.py#L616 .
2018-12-20 15:24:03 -08:00
Jelle Zijlstra
1a42a2c3ea
fix list concatenation ( #2404 )
...
Fixes #2383 , python/mypy#5492 .
2018-11-08 06:42:57 -08:00
Jelle Zijlstra
63cf7f529b
fix lint error ( #2541 )
2018-10-23 14:00:26 +02:00
Jelle Zijlstra
bc3f9fe1d3
fix typing.Pattern in Python 2 ( #2219 )
...
Fixes #2199
2018-10-01 20:35:13 -07:00
Jelle Zijlstra
1bc1fc2117
add constructor arguments for TimeoutExpired ( #2466 )
...
Previously, constructing a TimeoutExpired directly worked because Exception allowed arbitrary kwargs. We fixed that recently, but now mypy gives an error on creating a TimeoutExpired with legal arguments.
2018-09-18 14:02:38 +02:00
Jelle Zijlstra
8b9e4c378a
fix module argument to unittest.main ( #2403 )
2018-09-10 11:04:05 -07:00
Jelle Zijlstra
9d62d6d5c5
fix __metaclass_ references ( #2402 )
2018-09-06 18:24:03 -07:00
Jelle Zijlstra
2e1c81684e
fix duplicate definitions in tornado ( #2424 )
...
Fixes #2423 .
I followed https://github.com/tornadoweb/tornado/blob/master/tornado/httpclient.py and kept the `@property` where it exists in the implementation and the attribute where it doesn't.
2018-09-03 16:39:51 -07:00
Jelle Zijlstra
6f62466d6f
fix selftest ( #2425 )
...
Now that the typeshed submodule has moved.
2018-09-03 10:35:20 -07:00
Jelle Zijlstra
761b620e1a
add @srittau to maintainers ( #2420 )
2018-08-28 16:50:50 +02:00
Jelle Zijlstra
9e023e7586
minor namedtuple fixes ( #2227 )
...
- The extra arguments aren't keyword-only in 2.7.
- Added the `defaults` argument in 3.7 (https://docs.python.org/3.7/library/collections.html#collections.namedtuple ).
2018-08-19 03:47:10 +01:00
Jelle Zijlstra
fd6f99ca2c
fix mypy-selftest ( #2341 )
2018-07-18 21:12:37 -07:00
Jelle Zijlstra
574807d9ea
os.get_terminal_size also exists on Windows ( #2338 )
...
... at least according to https://docs.python.org/3/library/os.html#os.get_terminal_size .
Related to python/mypy#5370 .
2018-07-18 10:25:12 -07:00
Jelle Zijlstra
7d3ec1e0be
Improvements to pymysql ( #2220 )
...
* don't use type comments
* split up long lines
* all the constants are ints
* fixes to pymysql stub
* drop __all__, fix tabs
2018-07-13 19:43:09 -07:00
Jelle Zijlstra
fc290167eb
Fixes to boto.s3.key stub ( #2317 )
...
* replace type comments in key.pyi
* reformat the file with black
* get_contents_as_string returns bytes unless an encoding is specified
http://boto.cloudhackers.com/en/latest/ref/s3.html#boto.s3.key.Key.get_contents_as_string
2018-07-13 19:39:24 -07:00
Jelle Zijlstra
00cda79cf5
add io.TextIOWrapper.read in 3.3 ( #2248 )
...
This is needed to make TextIOWrapper and a few classes that inherit
from it concrete in 3.3. I am actually not sure whether this method
exists at runtime; there's nothing in
https://docs.python.org/3/library/io.html#io.TextIOWrapper
that suggests it was added in 3.4. In any case, it hardly matters
since 3.3 usage should be very rare now.
2018-06-17 23:47:07 +01:00
Jelle Zijlstra
3032fbdff1
make http.client.HTTPResponse concrete in 3.4 ( #2244 )
...
Matches the implementation in https://github.com/python/cpython/blob/3.4/Lib/http/client.py#L308
The ignore works around python/mypy#5027 (commented further up in the 3.5 branch).
Part of #1476 .
2018-06-17 17:29:02 +01:00
Jelle Zijlstra
da8de48f6d
UserList and UserString in 2.7 ( #2246 )
...
Fill out UserList and UserString stubs to make the classes concrete. Compare:
https://github.com/python/cpython/blob/2.7/Lib/UserList.py
https://github.com/python/cpython/blob/2.7/Lib/UserString.py
2018-06-17 17:24:30 +01:00
Jelle Zijlstra
8084dc1c1f
Fix abstract classes in 2.7 ( #2247 )
...
Part of #1476 .
2018-06-17 17:21:17 +01:00
Jelle Zijlstra
6b36b1befe
Iterator provides a concrete __iter__ in 2.7 (#2245 )
...
This is already how it works in the Python 3 stub.
`Iterator.__iter__` also exists at runtime: https://github.com/python/cpython/blob/2.7/Lib/_abcoll.py#L73 .
2018-06-17 12:00:42 +01:00
Jelle Zijlstra
0393de4bd7
fix some abstract classes in Python 2 ( #2240 )
...
Part of #1476 .
2018-06-17 00:56:00 +01:00
Jelle Zijlstra
94ab32ba59
Fix abstract classes for Python 3 ( #2239 )
...
* add metaclass=ABCMeta to some classes
* mark some more classes as explicitly abstract
* make some more classes concrete
2018-06-16 10:18:54 -07:00