Commit Graph

3903 Commits

Author SHA1 Message Date
wouter bolsterlee
757d962237 Improve ssl module annotations (#5934)
This improves the type annotations for the ‘ssl’ module:

- Various APIs taking file names (e.g. keyfile=, certfile=, cafile=,
  capath=, ...) were annotated as accepting only strings, while actually
  they accept str, bytes, and os.PathLike (such as pathlib.Path).
  CPython's _ssl.c module has always used PyUnicode_FSConverter to
  handle (normalize) these. Change the annotations accordingly using the
  internal _typeshed.StrOrBytesPath alias.

- Tighten the ‘purpose=’ argument in various functions to use the
  already defined ‘Purpose’ enum instead of accepting ‘Any’.
2021-08-18 08:23:31 -07:00
Nathan Naze
34b3f0bf7c Add missing attributes to IncompleteRead (#5933) 2021-08-17 21:27:09 -07:00
Jeremy Nation
0e62c8ab06 Add missing stub for _CursesWindow.noutrefresh (#5928) 2021-08-14 23:55:43 +02:00
Oleg Höfling
ff63953188 Switch to PEP-604 syntax in python2 stubs (#5915)
Signed-off-by: oleg.hoefling <oleg.hoefling@gmail.com>
2021-08-14 11:12:30 +02:00
Rebecca Chen
431c4f7fc1 Improve a few types in xml.dom.minidom. (#5923)
* Changes the return type of getDOMImplementation from implicit Any to
  DOMImplementation | None.
* DOMImplementation.createDocument() and createDocumentType() allow None for all arguments.
2021-08-13 23:28:47 +02:00
Rebecca Chen
774da45449 Add some missing properties to xml.dom.minidom.Node. (#5919) 2021-08-13 21:57:22 +02:00
jack1142
e415a7fad8 Make ChainMap's new_child() and parents return subclass (#5922) 2021-08-13 19:30:48 +02:00
Gabe Joseph
92aecadf6b Memoryview.cast: shape= can be tuple of any number of ints (#5918) 2021-08-13 00:04:35 +02:00
Anton Grübel
ae86a93f45 add ParamSpec to atexit (#5896)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2021-08-11 20:49:30 -07:00
Oleg Höfling
64f481189f drop ellipsis assignments from module vars, classvars and instance attrs (#5914)
Signed-off-by: oleg.hoefling <oleg.hoefling@gmail.com>
2021-08-11 19:26:58 +02:00
Sténio Jacinto
32a6257de0 Add missing stdlib xml stubs (#5895) 2021-08-09 22:41:55 +02:00
Akuli
9af9cca7f3 lowercase list and dict in the rest of stdlib (#5892) 2021-08-09 00:13:08 +02:00
Bas van Beek
7edad1034e Use a typevar in object.__new__ (#5891) 2021-08-08 20:45:22 +02:00
Hasan Ramezani
8b9d771b67 Add filters to stdlib/warnings.pyi (#5889) 2021-08-08 21:18:47 +03:00
Akuli
24780a3e03 imaplib, nntplib, plistlib, poplib: use lower-case list and dict (#5890) 2021-08-08 18:46:23 +02:00
Akuli
ce11072dbe Big diff: use lower-case list and dict (#5888) 2021-08-08 09:26:35 -07:00
Akuli
b1d1551bbc tkinter.Canvas: types for addtag_foo() and find_foo() methods (#5886) 2021-08-08 17:14:45 +03:00
Kyle Altendorf
4b77d454bd dataclasses: Allow Any keys for the metadata field (#5823) 2021-08-08 15:50:52 +02:00
Akuli
1409f6e892 change ast files to use new union syntax (#5880) 2021-08-08 15:47:33 +02:00
Akuli
c12c93ebe4 use new union syntax in stdlib/types.pyi (#5882) 2021-08-08 15:46:09 +02:00
Akuli
1395318faa use new union syntax in ctypes/__init__.pyi (#5883) 2021-08-08 15:45:28 +02:00
Akuli
df6a211855 Use new union syntax in rest of stdlib (#5884) 2021-08-08 15:44:30 +02:00
Akuli
ebacd320a3 support passing coordinate tuples to tkinter.Canvas.create_foobar() (#5885) 2021-08-08 15:43:28 +02:00
Matt Vollrath
753cb4caba Override argument type of DatagramProtocol.connection_made() (#5873) 2021-08-08 11:16:26 +02:00
Akuli
ef5b4b6820 setattr: Any --> object (#5877) 2021-08-08 11:12:23 +02:00
Akuli
ee487304d7 Big diff: Use new "|" union syntax (#5872) 2021-08-08 11:05:21 +02:00
Ron Frederick
309e7bda32 Update builtins.pyi (#5874)
Change getattr/hasattr first argument from Any to object

Fixes #5848
2021-08-07 20:46:03 -07:00
Akuli
e3f662b648 switch to lower-case "# undocumented" comments (#5871) 2021-08-07 08:00:41 -07:00
Anton Grübel
39ede0242c add missing type hints for __class_getitem__ (#5869) 2021-08-07 16:12:53 +02:00
Akuli
1cd719ba8d Add types to some untyped tkinter.Canvas methods (#5868)
* coords
* gettags
* itemconfigure, itemconfig
* tag_raise, tag_lower, their aliases
* dtag

Co-authored-by: Sebastian Rittau <srittau@rittau.biz>
2021-08-07 17:01:56 +03:00
Akuli
9301131976 fix tkinter.Canvas tags option (#5866) 2021-08-07 15:53:46 +02:00
Anton Grübel
25e9733389 add missing type hints in trace (#5865)
* Parameter func in Trace.runfunc() became positional only in Python 3.9
* Add is_ignored_filename()
2021-08-07 15:53:26 +02:00
Akuli
36799fd63c tkinter.Canvas: fix dash (#5867) 2021-08-07 15:38:05 +02:00
Henry Schreiner
ae51d5264b fix: standalone logger functions do not accept arbitrary keywords (#5862) 2021-08-06 23:58:24 +02:00
Henry Schreiner
4965e95f84 fix: arbitrary keyword arguments are not accepted in logging functions (#5849)
While the implementation uses `**kwargs`, this is just forwarded to `_log()`, which accepts a fixed set of arguments.
2021-08-06 10:59:43 +02:00
Maarten ter Huurne
9bba8a4b83 Correct annotation of headers parameter of HTTP event handlers (#5854)
* Use HTTPMessage for the headers parameter of HTTP event handlers

While the documentation of `BaseHandler.http_error_default()` describes
the `hdrs` (`headers` in most other handlers) as "a mapping object with
the headers of the error", the implementation that is located in
`URLopener._open_generic_http()` will pass `response.msg` instead,
which is of type `http.client.HTTPMessage`.

* Use Message for the headers parameter of HTTPError

When the standard library constructs `HTTPError`, it will
pass an `http.client.HTTPMessage`, which is a subclass of
`email.message.Message`. Picking the superclass for the
annotations gives users the flexibility to for example
the result of the `email.message_from_X()` functions.

The only thing unique to `HTTPMessage` is the undocumented
`getallmatchingheaders()` method, which is only called by
`http.server.CGIHTTPRequestHandler.run_cgi()`. That class
gets its headers from `http.client.parse_headers()` and not
from `HTTPError`, so I think it's safe to use `Message`
as the annotation.
2021-08-06 10:55:49 +02:00
an onion
f30d6f6fd0 Add stubs for posix_spawn and posix_spawnp (#5846) 2021-08-05 18:55:26 -07:00
Anton Grübel
34d94d780c add ssl.get_ciphers (#5838) 2021-08-04 15:39:46 -07:00
Sebastian Rittau
840df19501 Switch to Python 3.10.0-rc.1 in CI (#5845)
* Switch to Python 3.10.0-rc.1 in CI

* Add module argument to ForwardRef.__init__()
2021-08-04 07:14:38 -07:00
Jon Dufresne
b2e429cd41 Add typing for TarFile._extract_member method (#5841)
Refs: #2673
2021-08-03 08:53:35 +02:00
Bas van Beek
475417fa97 Mark final and unhashable classes in types as such (#5837) 2021-08-02 13:46:14 -07:00
Sebastian Rittau
acc576659a Use Python 3.10 beta 4 instead of beta 1 in CI (#5839)
Quote all Python versions to make sure they are interpreted as strings,
not floats.
2021-08-02 07:30:32 -07:00
Oleg Höfling
836690e150 Add attribute types to code.InteractiveInterpreter and code.InteractiveConsole (#5830)
* mark undocumented attributes
* use pep 585 generics, replace optional types with pep 604-style hints
2021-08-02 14:04:42 +02:00
Ran Benita
2d0f3c5211 python2/tempfile: dir argument can be None (#5836) 2021-08-02 11:36:19 +02:00
Oleg Höfling
41630486e3 Add Typeguard back to inspect.isclass() return type (#5829) 2021-08-02 09:19:11 +02:00
Eric Traut
ea4be02bab Redefined dataclasses.KW_ONLY (#5826)
Redefined dataclasses.KW_ONLY so it's a type alias rather than a class instance. Class instances are illegal to use within a type annotation.
2021-08-01 08:06:48 -07:00
Jelle Zijlstra
e1b9ab3372 Remove redundant import from typing (#5827)
Fixes quora/pyanalyze#221.
2021-07-30 22:55:33 -07:00
Rebecca Chen
8da23e0634 Broaden the signature of subprocess.list2cmdline. (#5824)
Although the parameter is called 'seq', the implementation shows that it
can be anything that can be passed to map(), which takes iterables:
0f42b726c8/Lib/subprocess.py (L565).
2021-07-30 12:15:27 -07:00
Bas van Beek
95a45eb4ab Improve the annotations of types.MappingProxyType (#5822)
* Annotate three previously missing `MappingProxyType` methods

* `__hash__`
* `__reversed__`
* `__class_getitem__`

* Improve 5 `MappingProxyType` methods

The assumption here is that the underlying mapping is a `dict`,
just is done for `MappingProxyType.copy`

* Make the value type of `types.MappingProxyType` covariant
2021-07-30 17:05:15 +02:00
MapleCCC
089dd43eb7 Update stdblib/shelve.pyi (#5816)
Several things done:

1. Replace all occurrences of `Any` by respective concrete types.
2. Make `Shelf` and its subclassses generic. (Fixes #5815)
3. `shelve.open` should return a general `Shelf` object, not `DbfilenameShelf`. The documentation does not expose such implementation detail.
4. The argument `dict` is annotated with an abstract type `MutableMapping` rather than concrete type `Dict`.
5. Remove unnecessary methods. Some of them are inherited from `MutableMapping`, so no need to repeat them here.
6. Use builtin-in generics instead of importing from `typing`.
2021-07-30 06:50:27 -07:00