Commit Graph
100 Commits
Author SHA1 Message Date
Sebastian Rittau d2a7889fe0 Drop support for Python 3.5 (#4675)
Python 3.5 EOL was on 2020-09-30.
2020-11-02 16:18:20 +01:00
Sebastian Rittau cdc4de1af4 Derive Reversible from Iterable (#4622)
Closes: #4615
2020-11-01 13:17:41 -08:00
Sebastian Rittau 8aa3346a9c Remove some TODOs from IO classes (#4654)
At this point, it is too late to add methods to these semi-protocols as
it would break lots of existing code. Additionally, we are moving away
from these classes to finer-grained protocols anyway.
2020-11-01 13:11:19 -08:00
Sebastian Rittau c5aca0d533 Only add a mypy_primer comment if there is output (#4725) 2020-10-28 20:07:12 +01:00
Sebastian Rittau 4603728a15 Clean up files with former forced consistency (#4717)
Replace Text with str in Python 3 code
2020-10-27 07:52:35 +01:00
0583738a41 Add a mypy self test (#4337)
Co-authored-by: Shantanu <hauntsaninja@users.noreply.github.com>
Co-authored-by: hauntsaninja <>
2020-10-24 17:58:04 -07:00
Sebastian Rittau 3de732e188 Split distutils for Python 2 and 3 (#4685)
Addresses #4679, but also starts addressing #4674.
2020-10-22 19:24:17 -07:00
Sebastian Rittau 5927e5ca30 Remove most consistency checks and split builtins.pyi into py2/3 files (#4686)
Split builtins.pyi in Python 2 and 3 versions

Partly addresses #4674
2020-10-22 13:39:06 -07:00
Sebastian Rittau 5b11606d16 CI: Update Python and mypy versions (#4656)
* Use 3.9 final instead of 3.9-dev
* Remove explicit Python versions from utility scripts
* Use mypy 0.390 for stubtests
2020-10-12 15:01:09 +02:00
Sebastian Rittau 473044cf1f Add information about removing third-party packages (#4637)
Closes: #4608
2020-10-09 16:27:56 +02:00
Sebastian Rittau 35f4ade96f Replace bool.__init__() with __new__() (#4614)
Fixes #4612
2020-10-09 00:20:03 +02:00
Sebastian Rittau 2157c4a448 Fix patch() used as decorator (#4592)
Closes: #4591
2020-10-02 09:05:25 +02:00
Sebastian Rittau bf5651e7a6 Use GitHub Actions to run mypy (#4594) 2020-10-01 14:42:31 -07:00
Sebastian Rittau 27dfbf68aa Use __new__ instead of __init__ for some builtin classes (#4555)
Closes #4514 #2630 #2686
2020-09-30 00:00:06 -07:00
Sebastian Rittau 0cd7dd7009 Fix _patch.__call__() (#4568)
_patch.call() reused the type variable _T, which is generic over
_patch. It was meant to use a separate type variable for the argument,
which is returned.

Fixes #4566
2020-09-23 14:35:19 -07:00
Sebastian Rittau 3d3dee91a3 Use overloads for Redis.sort() (#4551) 2020-09-21 20:54:46 +02:00
Sebastian Rittau fae202e2a9 Run pytype and mypy self test using GitHub Actions (#4565) 2020-09-21 16:07:08 +02:00
Sebastian Rittau f14d6eaa89 Improve unittest.mock.patch() types (#4277) 2020-09-21 15:26:39 +02:00
Sebastian Rittau 5d467a7756 Add more constants and attributes to posix (#4552)
The constants were found by running dir(posix) on a Debian 10.5 (x86_64)
system.

Resolves #616.
2020-09-19 23:19:36 -07:00
Sebastian Rittau 9a6b500909 Add various missing undocumented functions (#4554)
Mostly addresses #2149
2020-09-19 22:59:35 -07:00
Sebastian Rittau fe69ffcb0f Add a few missing stdlib modules (#4550) 2020-09-18 11:28:25 -04:00
Sebastian Rittau 4e88557666 Complete msvcrt (#4548) 2020-09-18 09:20:26 -04:00
Sebastian Rittau 4e2e02b266 Fix cls argument name of CodecInfo.__new__() (#4549) 2020-09-17 12:04:54 -07:00
Sebastian Rittau d4191de79f Upgrade pytype (#4540)
The latest version recognizes the @runtime_checkable
decorator, required for #4442.
2020-09-15 12:51:22 +02:00
Sebastian Rittau bfec448860 Use GH Actions for linters (#4528) 2020-09-11 12:05:53 -07:00
Sebastian Rittau 3c20675813 Remove pytest_mock (#4478)
pytest-mock is now type annotated, which makes typeshed's annotations
obsolete. See pytest-dev/pytest-mock#152.
2020-08-29 14:47:34 -07:00
Sebastian Rittau 4233008b4a TypeVar(bound) accepts strings for forward references (#4410) 2020-08-07 08:31:31 -07:00
Sebastian Rittau dc0bfc5889 Make FeedParser generic over Message (#4375) 2020-08-04 09:32:38 -07:00
Sebastian Rittau 7ed8c5f1da Add select.epoll.register to stubtest whitelist (#4376)
Python 3.8.5 changed the docstring slightly, possibly
a problem in stubtest.
2020-07-30 19:29:34 +02:00
Sebastian Rittau 36356b3368 Remove argument from deque.pop() (#4367)
Closes: #4364
2020-07-27 06:49:56 -07:00
Sebastian Rittau 06f87e5c92 Simplify pathlib (#4357)
* Enable some branches for Python2 pathlib2
* Define an alias _PathLike, instead of using multiple branches
* Drop a Python 3.4 branch (the Python 2 branch is identical to
  the 3.5+ branch)
* Move Path.__new__ to the top
2020-07-27 06:08:09 -07:00
Sebastian Rittau cfd06e2d3c Enable aliases in pytest_mock (#4359)
* Require newer pytype
2020-07-25 12:13:00 -07:00
Sebastian Rittau 18aab6df0f Fix type in yaml file (#4339) 2020-07-18 07:03:23 -07:00
Sebastian Rittau 6acf0ef5f2 Create a PR when there are unused stubtest whitelist entries (#4334) 2020-07-18 14:48:55 +02:00
Sebastian Rittau ee77a359eb Use 'black' profile for isort (#4336) 2020-07-17 07:20:48 -07:00
Sebastian Rittau 5e76f51930 Upgrade to isort 5 (#4323)
This now also reformats imports not at the top of files.
2020-07-16 07:01:57 -07:00
Sebastian Rittau 9ad8ed3b75 Introduce Mapping-like protocols (#4325)
typing.Mapping is not a protocol, which has caused problems in the past.
(E.g. python/typeshed#3569, see also python/typeshed#3576.) This
introduces a few narrow protocols to _typeshed.pyi that can be used in
place of Mapping.

Not all uses of Mapping can be replaced. For example, cgi.FieldStorage
explictly checks whether the supplied headers argument is a Mapping
instance.
2020-07-11 17:11:08 -07:00
Sebastian Rittau 209b6bb127 Remove tornado stubs (#4321)
Current tornado releases feature inline annotations and ship with
a py.typed file.
2020-07-09 07:20:11 -07:00
Sebastian Rittau 03d8795403 Update unused stubtest whitelist action trigger (#4315)
Now runs weekly instead of daily, but also add the ability to trigger
manually.
2020-07-07 10:12:52 -07:00
Sebastian Rittau b8f6d5fc54 Replace a few instances of IO with protocols (#4296) 2020-06-30 18:05:30 -07:00
Sebastian RittauandPhilipp Hahn 6bffc6534b Add nmap type information (#4292)
Author: Philipp Hahn <hahn@univention.de>

Co-authored-by: Philipp Hahn <hahn@univention.de>
2020-06-29 18:52:41 +02:00
Sebastian RittauandJelle Zijlstra 4586ed9adc Require black and isort for contributions (#3329)
* Add explanation to CONTRIBUTNG.md
* Add sample pre-commit script
* Check for correctly formatted files in CI

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2020-06-28 15:28:28 -07:00
Sebastian Rittau 0704214701 Add pytest_mock stubs (#4275) 2020-06-27 19:46:47 -07:00
Sebastian Rittau 564a8220f4 Add float.__ceil__ and __floor__ (#4274)
Closes: #3195
2020-06-26 22:26:39 -07:00
Sebastian Rittau ad7c1cd7eb Update pytype (#4280) 2020-06-27 00:13:12 +02:00
Sebastian Rittau b05adddf5a pytype tests: Specify files or dirs to check (#4279)
This adds the ability to check single files or directories with
tests/pytype_test.py by specifying the paths to check on the
command line.
2020-06-26 20:45:38 +02:00
Sebastian Rittau a615a17976 Update black and work around an isort bug (#4242) 2020-06-19 08:32:05 -07:00
Sebastian Rittau 32c638cc88 Run the unused stubtest check only on python/typeshed (#4240)
Without this check, it is run on daily on every personal fork.
2020-06-18 10:47:05 -07:00
Sebastian Rittau 68a7b9b178 Collate all stubtest runs into a single output (#4231) 2020-06-17 11:48:44 -07:00
Sebastian Rittau 51cf2f51b8 Add IO protocols to _typeshed (#4230) 2020-06-14 20:44:48 +02:00
Sebastian Rittau ef74bee249 Protocol naming guidelines (#4229)
Closes: #4174
2020-06-14 17:00:19 +02:00
Sebastian Rittau 89d3a55f1a Preparations for the Big Reformat (#4228)
A few comments between imports were removed or moved to the top of the
import block, due to behavioral differences between black and isort. See
psf/black#251 for details.

In two instances @overloads at the top of the file needed to be moved
due to psf/black#1490.
2020-06-14 07:58:26 -07:00
Sebastian Rittau 53431cab1d Remove unused stubtest entries (#4225)
Rename job
2020-06-12 06:57:23 -07:00
Sebastian Rittau cf3b74a0bf Move stubtest CI to GitHub Actions (#4223)
This ensures that the Python version used matches the one used in the
scheduled extraneous stubtest whitelist check.

See also PR #4206.
2020-06-11 12:39:06 -07:00
Sebastian Rittau afe1e543b3 Make multiprocessing.Namespace accept any attribute (#4204)
Update multiprocessing.dummy.Namespace as well

Closes: #4186
2020-06-09 12:34:36 -07:00
Sebastian Rittau 206bff44ed Remove BinaryIO.write() (#4203)
write() is inherited from IO[bytes], where it's defined as
`def write(self, s: AnyStr) -> int: ...`. If AnyStr is bytes,
this should accept bytes, bytearray, and memoryview, so the
overload is unnecessary.

Closes: #4201
2020-06-08 13:40:41 -07:00
Sebastian Rittau 3d84c52a4c Do not stop other checks if one check fails (#4205) 2020-06-08 07:25:52 -07:00
Sebastian Rittau 1f82564ee2 Move wsgiref.types to _typeshed.wsgi (#4175)
Re-export the types from wsgiref.types for now to avoid breaking
existing code. wsgiref.types should be removed eventually.

Also, reduce the boilerplate description in _typeshed/wsgi.pyi as it
mirrors the description in _typeshed/__init__.pyi.
2020-06-04 15:38:45 -07:00
Sebastian Rittau eea9be6e73 Add a _typeshed.pyi file and a PathLike alias (#4161) 2020-06-04 14:06:43 +02:00
Sebastian Rittau d76ad4710e Find unused stubtest whitelist entries (#4157)
* Find unused stubtest whitelist entries

This is currently a GitHub workflow that runs daily and lists all unused
whitelist entries found by running stubtest against current Python
versions on Linux and Windows. The workflow run will succeed if there
are no such entries, and fail otherwise.

In a second step, this should collate the output of the various runs and
create a PR to remove the entries. In that case, the workflow should
probably only run weekly or even monthly to keep the noise down.

Cf. #3728
2020-06-03 14:37:38 +02:00
Sebastian Rittau a913af9523 flake8: Enable F811 (#4158) 2020-06-02 14:08:54 -07:00
Sebastian Rittau b2b397c5ce Add @CraftSpider and @hauntsaninja as maintainers (#4138) 2020-05-28 16:34:45 -07:00
Sebastian Rittau adafaf1964 Add review guidlines (#4132)
Closes: #3448
2020-05-28 15:18:05 +02:00
Sebastian Rittau 694fa80596 Add dateparser module (#4106)
Based on PR 3704 by @xcthulhu (Matthew Doty)
2020-05-27 18:53:16 -07:00
Sebastian Rittau be016c6793 Add retry_after to TooManyRequests and ServiceUnavailable (#4059)
Added in werkzeug 1.0.0

While the implementation accepts any value for retry_after, the docstring
allows only datetime and int. Using any other value could lead to an
invalid HTTP response.
2020-05-23 13:39:48 -07:00
Sebastian Rittau 92f52a2615 flake8 updates and cleanups (#3940)
* flake8 updates and cleanups

* Update to flake8 3.7.9.
* Update to flake8-bugbear 20.1.4.
* Only ignore errors in stub files.
* Remove obsolete error counts.
* Sort error codes alphabetically.
* Don't ignore the following errors (unneeded):
    * E704 Multiple statements on one line (def)
    * W504 Line break occurred after a binary operator
    * B303 __metaclass__ used

* Remove obsolete comment

* Ignore F822 undefined name in __all__
2020-04-23 19:38:47 -07:00
Sebastian Rittau 733c558d60 Add msilib and _msi to stubtest whitelist (#3939)
* Add msilib and _msi to stubtest whitelist

* Group Windows-only modules

* Move win modules to bottom

Make win modules optional
2020-04-23 19:09:52 -07:00
Sebastian Rittau 68190cefde Fix stubs for pymysql (#3781) 2020-03-05 09:21:52 +01:00
Sebastian Rittau ca9505c8f4 Improve imaplib return types (#3670)
* Improve imaplib return types

Mark CommandResults as obsolete.

Also fix types of tagged_commands and untagged_responses.

Based on a discussion in #3655.

* Fix type of tagged_commands

* Fix IMAP4.tagged_commands type

* Mark CommandResults as private

* Fix
2020-02-22 09:58:14 -08:00
Sebastian Rittau c710696aed Remove obsolete stubtest whitelist entries (#3773) 2020-02-22 18:05:12 +01:00
Sebastian Rittau 0e3286bc43 Remove consent requirement for third-party stubs (#3643)
This was discussed a while ago on typing-sig. Consequently the
requirement of asking third-party maintainers for permission was
removed from PEP 484.
2020-01-23 15:01:30 +01:00
Sebastian Rittau fdeae5d00e Enable --disallow-subclassing-any (#3591)
Closes: #1446
2020-01-08 11:51:44 -08:00
Sebastian Rittau 885c2fd65e Fix example code (#3592) 2020-01-08 09:52:23 -08:00
Sebastian Rittau 595d02363a Change return type of Message.get_payload() to Any (#3504)
If, for example, is_multipart() is called before calling get_payload(),
it is guaranteed that a List[Message] is returned.
2019-11-26 08:03:15 -08:00
Sebastian Rittau c0d46a2035 Mostly undo #3372 (#3481)
readline callback must return str, not bytes.
2019-11-23 20:17:14 +01:00
Sebastian Rittau 107eaeb3d2 Add sys.addaudithook() and audit() (#3455) 2019-11-11 13:22:28 -08:00
Sebastian Rittau 66778639a5 Run CI tests against win32 and darwin platform (#3457)
Also use Python 3.8 as default Python version for tests
2019-11-11 07:52:11 -08:00
Sebastian Rittau d60b7ae26d New libs: Change permission requirement to notification (#3443)
This was discussed on the typing-sig mailing list and in
python/peps#1218, has met the approval of the steering council, and
was incorporated into PEP 484.
2019-11-07 07:35:35 -08:00
Sebastian Rittau 79d4e0dd08 Add assorted werkzeug type hints (#3444)
* Annotate is_immutable()
* Annotate ImmutableListMixin and make generic
* Make ImmutableList generic and derive from generic List
* Annotate Accept
* Annotate MIMEAccept
* Fix annotation of parse_accept_header()
2019-11-06 10:37:18 -08:00
Sebastian Rittau e4677d9ed4 Use async syntax instead of @coroutine (#3441) 2019-11-06 07:39:09 -08:00
Sebastian Rittau add0b5e930 Add functools.cached_property (#3439)
Part of #3319
2019-11-06 07:21:32 -08:00
Sebastian Rittau c8405bb5d9 Add importlib.metadata (Python >= 3.8) (#3346)
Part of #3319
2019-10-29 19:53:47 -07:00
Sebastian Rittau 5e9f66cb62 Add missing Python 3.7 and 3.8 annotations (#3399)
* Add explicit ssl_handshake_timeout arguments to open_connection and start_server

* Add context arguments to call methods

* Accept PathLike for create_unix_* paths

* Add TimerHandle.when()

Add missing version check

* AbstractServer is now an async context manager

* Add happy_eyeballs_delay and interleave arguments to create_connection

* Re-export asyncio.windows_events from asyncio

* Add name argument to Task constructor

* Add Task.get_coro()

* import and other fixes

* Fix return type of get_coro()
2019-10-29 19:49:37 -07:00
Sebastian Rittau 4770059894 Add missing ZipFile constructor arguments (#3414)
Closes: #3413
2019-10-29 19:46:31 -07:00
Sebastian Rittau 87d7dd3d95 Fix annotations with literal values (#3411) 2019-10-28 06:59:28 -07:00
Sebastian Rittau ec7960a8cb Convert namedtuples to class syntax (#3321) 2019-10-20 10:37:33 +02:00
Sebastian Rittau 299d89ab76 generate_tokens(readline) must return bytes (#3372) 2019-10-16 08:55:23 -07:00
Sebastian Rittau b969ead0ce Reorder memoryview.__setitem__ overloads (#3365)
Necessary for python/mypy#7717
2019-10-15 14:14:48 +02:00
Sebastian Rittau 6b55f5c498 Clean up multiprocessing + shared_memory (#3351)
* Make multiprocessing stubs match implementation

* Add multiprocessing.process.BaseProcess
* Use BaseProcess in multiprocessing.context where applicable
* Remove non-existing BaseContext.Process()
* Derive DefaultContext from BaseContext
* Fix BaseContext/DefaultContext.set_start_method() signatures
* Re-export multiprocessing.context.Process from multiprocessing,
  instead of using a custom definition
* Re-export multiprocessing.active_from from multiprocessing.process
  instead of using a custom definition

* Add parent_process() (Python 3.8)

* Complete BaseManager; add Server

* Add multiprocessing.shared_memory et al
2019-10-14 09:54:45 +02:00
Sebastian Rittau 0501e2b329 Annotations for remaining Python 3.8 additions (#3358)
* Add os.add_dll_directory()
* Add memfd_create() and flags
* Add type annotation to flags
* Add stat_result.st_reparse_tag and flags
* Add ncurses_version
* Add Path.link_to()
* Add Picker.reducer_override()
* Add plistlib.UID
* Add has_dualstack_ipv6() and create_server()
* Add shlex.join()
* Add SSL methods and fields
* Add Python 3.8 statistics functions and classes
* Remove obsolete sys.subversion
* Add sys.unraisablehook
* Add threading.excepthook
* Add get_native_id() and Thread.native_id
* Add Python 3.8 tkinter methods
* Add CLOCK_UPTIME_RAW
* Add SupportsIndex
* Add typing.get_origin() and get_args()
* Add unicodedata.is_normalized
* Add unittest.mock.AsyncMock

Currently this is just an alias for Any like Mock and MagicMock. All of
these classes should probably be sub-classing Any and add their own
methods. See also #3224.

* Add unittest cleanup methods
* Add IsolatedAsyncioTestCase
* Add ElementTree.canonicalize() and C14NWriterTarget
* cProfile.Profile can be used as a context manager
* Add asyncio task name handling
* mmap.flush() now always returns None
* Add posonlyargcount to CodeType
2019-10-14 09:53:48 +02:00
Sebastian Rittau 6507875f28 Annotate Python 3.8 removals (#3359)
* macpath
* time.clock()
* Some cgi functions
* XMLParser(html) and doctype()
* unicode_internal
* Two sqlite3 classes hidden
* fileinput bufsize arg
* Treeview.selection no longer takes arguments
2019-10-14 09:51:39 +02:00
Sebastian Rittau 950f391704 Remove unnecessary __all__ annotations (#3357) 2019-10-13 16:22:03 -07:00
Sebastian Rittau de26a3d109 Remove raise statements from function bodies (#3355)
While it may eventually be useful to mark the exceptions that can be
raised from a function or method, the semantics are currently undefined
and unclear.
2019-10-13 21:51:43 +02:00
Sebastian Rittau 62bbdf856c Add several Python 3.8 annotations (#3347) 2019-10-12 19:36:56 +02:00
Sebastian Rittau 583784d94c Add missing exception to smtplib (#3348)
Improve a few other types
2019-10-12 19:15:44 +02:00
Sebastian Rittau 61d5f76a1d find_loader() can return None (#3341) 2019-10-11 10:48:48 -07: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 8a7d61741d Python3.8 additions and changes (#3337)
* Add as_integer_ratio() to a few types

* Add dirs_exist_ok to copytree()

* int, float, complex accept __index__ args

Also fix complex.__init__ argument names

* Add __reversed__ to dict et al.

* Python 3.8 date(time) arithmetic fixes

* Add CodeType.replace()
2019-10-10 20:51:27 -07:00
Sebastian Rittau 07c8675ba5 Remove unused # type: ignore comments (#3325) 2019-10-09 10:27:18 -07:00
Sebastian Rittau d82d3396e7 Minor flake8 improvements (#3324)
* Update flake8-bugbear
* Remove unnecessary comment
* Add a comment about an upcoming fix
2019-10-08 17:42:36 +02:00