Commit Graph

60 Commits

Author SHA1 Message Date
Rebecca Chen f9acd5aa3b Mark http.server.SimpleHTTPRequestHandler's directory arg as optional. (#4443)
`directory` has a default value:
https://docs.python.org/3/library/http.server.html#http.server.SimpleHTTPRequestHandler.
2020-08-12 17:59:00 -07:00
Eric Traut 04c74640f0 Removed imported symbols that are not accessed or re-exported (#4387)
Co-authored-by: Eric Traut <erictr@microsoft.com>
2020-08-05 22:49:17 -07: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 44a852dff5 Literal: always import from typing_extensions for simplicity (#4219) 2020-06-10 21:23:58 -07:00
Shantanu 88440b768c http: add py39 status codes (#3955)
Co-authored-by: hauntsaninja <>
2020-04-29 20:47:28 -07:00
Philipp Hahn 84147ec9cb sockeserver: Add undocumented internals (#3924)
the `rfile` and `wfile` members are already implemented by
StreamRequestHandler. In addition to them several (undocumented)
class and instance variables exist according to
<https://github.com/python/cpython/blob/master/Lib/socketserver.py#L742>:
- `rbufsize`
- `wbufsize`
- `timeout`
- `disable_nagle_algorithm`
- `packet` and `socket` for datagrams

The already exist with Python 2.7
<https://github.com/python/cpython/blob/2.7/Lib/SocketServer.py#L677>

```mermaid
classDiagram
BaseRequestHandler <|-- DatagramRequestHandler
BaseRequestHandler <|-- StreamRequestHandler
StreamRequestHandler <|-- BaseHTTPRequestHandler
```
2020-04-14 13:22:40 -07:00
Shantanu cae73edebf http.cookies: add LegalChars for py36 and below (#3639) 2020-01-23 15:05:49 +01:00
Shantanu b8299bd58a http: update for py38 (#3606)
* http: add UNAVAILABLE_FOR_LEGAL_REASONS
* http.cookiejar: filename parameter now supports path-like
2020-01-11 17:20:46 +01:00
Jens Hedegaard Nielsen 2cff4e615e BaseHTTPRequestHandler is a subclass of StreamRequestHandler (#3579) 2020-01-06 15:00:31 +01:00
Daniel Farley 4fb4c80af7 Fix HTTPConnection timeout type (#3565)
`HTTPConnection` only passes timeout down to `socket.settimeout()` which is of type `Optional[float]` and has a specific action for `None`.  `HTTPConnection` should support the same behavior
2020-01-05 16:11:22 +01:00
Benjamin Peterson 23c531df5a Type socketserver's RequestHandlerClass as a callable. (#3422)
It's not uncommon to pass functions rather than actual types into the servers.
2019-11-25 20:18:17 -08:00
Diego Elio Pettenò 616cb0bb65 Add sock attribute for http.client.HTTPConnection in Python 3. (#3429)
The equivalent httplib.HTTPConnection class already include it for Python
2, despite the attribute not being documented for either version.
2019-10-30 23:21:50 +01:00
Sebastian Rittau d41bcd39e1 Add assorted annotations (#3335)
* Add assorted annotations

* Fix type of Purpose items
2019-10-10 20:51:49 -07:00
Sebastian Rittau 256b3ce8ab Remove a bunch of unused imports (#3323) 2019-10-08 07:59:32 -07:00
Stefan T 0abb50e20a Add http.MISDIRECTED_REQUEST introduced in 3.7 (#3293) 2019-10-01 15:42:44 -07:00
Sebastian Rittau c32e1e2280 Enable --disallow-any-generics for stubs (#3288) 2019-10-01 05:31:34 -07:00
Vasily Zakharov a2834cf24d Added stub for http.server.BaseHTTPRequestHandler useful undocumented fields (#3285) 2019-09-30 19:27:54 +02:00
秋葉 2edb36e993 Add ThreadingHTTPServer stub (#3232)
Fixes #3217
2019-09-15 16:06:19 +02:00
Michael Lee b294782183 Make most contextmanager __exit__ signatures return Optional[bool] (#3179)
This pull request is a follow-up to https://github.com/python/mypy/issues/7214.

In short, within that mypy issue, we found it would be helpful to
determine between contextmanagers that can "swallow" exceptions vs ones
that can't. This helps prevent some false positive when using flags that
analyze control flow such as `--warn-unreachable`. To do this,
Jelle proposed assuming that only contextmanagers where the `__exit__`
returns `bool` are assumed to swallow exceptions.

This unfortunately required the following typeshed changes:

1. The typing.IO, threading.Lock, and concurrent.futures.Executor
   were all modified so `__exit__` returns `Optional[None]` instead
   of None -- along with all of their subclasses.

   I believe these three types are meant to be subclassed, so I felt
   picking the more general type was correct.

2. There were also a few concrete types (e.g. see socketserver,
   subprocess, ftplib...) that I modified to return `None` -- I checked
   the source code, and these all seem to return None (and don't appear
   to be meant to be subclassable).

3. contextlib.suppress was changed to return bool. I also double-checked
   the unittest modules and modified a subset of those contextmanagers,
   leaving ones like `_AssertRaisesContext` alone.
2019-08-16 16:13:33 -07: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
Sebastian Rittau 9ccf9356bf Remove Python 3.4 support (#3147)
Closes #3123
2019-07-27 10:58:21 +02:00
Sebastian Rittau 0177dedc42 Add werkzeug.middleware (#3103)
HTTPConnection.timeout can be a float
2019-07-24 08:51:55 -07:00
Sam Zhou 4af283e1ac Fix HTTPConnection.putrequest parameter names (#3101) 2019-07-03 08:52:59 +02:00
Florian Ludwig 2e10326b50 change http.cookies.Morsel to Dict[str, Any] (#3060)
Morsel does cast any value to string and therfor any is the correct
typehint. For some keys other types then strings are more
appropiate anyway, max-age can take an integer (unix time) and http-only
a boolean.

Closes #3059
2019-06-19 15:17:16 -07:00
Rebecca Chen e7184d6dfc Add undocumented but used method LWPCookieJar.as_lwp_str. (#3041)
The method is defined here:
https://github.com/python/cpython/blob/e36ed475ea429f7cc80a4d65f80b44686a74b246/Lib/http/cookiejar.py#L1864
2019-06-08 07:06:14 -07:00
Sushain Cherivirala 67b42aff6b Add initializer for http.cookiejar.Cookie (#2932) 2019-04-29 10:34:28 +02:00
Michael Lee efb67946f8 Use variable annotations everywhere (#2909) 2019-04-13 10:40:52 +02:00
Gregory P. Smith cd4572e43c Annotate some missing http client and urllib APIs. (#2582) 2018-11-12 21:54:57 +01:00
Sebastian Rittau 006a79220f Flake8 fixes (#2549)
* Fix over-indented continuation lines

* Fix under-indented continuation lines

* Fix whitespace around default operator problems

* Limit line lengths

* Fix inconsistent files
2018-10-24 07:20:53 -07:00
Sebastian Rittau 9827132d5b Fix return types in urllib.request (#2389)
* Tighten return types of URL handlers

* urlopen() etc. return a modified HTTPResponse

* Add missing methods to HTTPResponse
2018-09-18 16:45:09 -07:00
justinpawela 2a888416b2 Remove annotations from http.HTTPStatus enum members (#2314)
These type annotations are unnecessary and seem to confuse the type system.

* Remove annotation from PlistFormat enum members

Same rationale as python/typeshed#2314; same adverse effects observed.
2018-07-09 18:59:34 -07:00
Yusuke Miyazaki 6192cce9d9 Avoid using string literals in type annotations (#2294) 2018-07-02 20:23:29 -07:00
Sebastian Rittau 95eff73ab2 Drop Python 3.3 support from several stubs (#2265)
* Drop Python 3.3 support from several stubs

* Revert wrong socketserver changes
2018-06-20 16:49:47 -07: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 de86f15fa0 Make http.client.HTTPResponse a BinaryIO (#2218)
Fixes #2189.

The errors from mypy are a false positive (see python/mypy#5027).
2018-06-12 09:20:24 -07:00
Jelle Zijlstra 28f6c095d4 make http.cookies.{Base,Simple}Cookie instantiable (#2116)
Part of #1476.
2018-06-11 14:01:17 -07:00
Anthony Sottile 270fba2e4e Add headers attribute to HTTPResponse (#2190) 2018-06-05 08:11:12 -07:00
Jelle Zijlstra 37aba00fe8 fix using ZipFile as a ContextManager (#2043) 2018-04-12 12:29:22 -07:00
Jelle Zijlstra 43e6c3c435 add more minor 3.7 new features (#2000)
part of #1965
2018-03-28 21:28:27 -07:00
rchen152 f6b60cb3ea A couple fixes to the io stubs. (#1811)
1. The 'name' argument to FileIO.init can be either a string or an integer: https://docs.python.org/2/library/io.html#io.FileIO
2. An mmap.mmap object can be used in most places that a bytearray can: https://docs.python.org/3.5/library/mmap.html
2018-01-04 16:14:38 -08:00
Martin DeMello 817c270c32 Clean out the pytype blacklist (#1667) 2017-10-24 10:38:34 -07:00
Jelle Zijlstra 1515ed9f88 fix some abstract classes in third_party/ (#1486) 2017-07-19 20:27:22 +03:00
Matthias Kramm ac0b809bf5 tweak files to fix pytype parsing errors (#1325)
* Don't use "\" to join lines
2017-05-26 08:45:52 -07:00
Jelle Zijlstra fce4424c6e add http.client.error (#1355)
It's in __all__
2017-05-25 19:35:36 -07:00
Jelle Zijlstra 11350ed8cc Fix missing argument types in py3 stdlib (#995)
Still missing a few in _subprocess (a Windows-only private module) and decimal
(I gave up).
2017-03-14 11:43:42 -07:00
Jelle Zijlstra 47a19c761c fix typo in http.client (#985) 2017-03-12 19:33:47 -07:00
David Euresti da11ecf773 Add missing __init__ and isclosed to http.client.HTTPResponse 2017-02-22 20:18:15 -08:00
Sunghyun Hwang 28f3fde09f improve HTTPStatus type definition (#920) 2017-02-07 10:39:44 -08:00
Lukasz Langa c0c982ada5 Add missing Dict imports. 2016-12-21 01:15:26 -08:00