Commit Graph

59 Commits

Author SHA1 Message Date
Alex Waygood 4f381af4c5 Upgrade mypy to 0.990 (#9123) 2022-11-07 11:20:47 -08:00
Jelle Zijlstra 43631078f0 importlib: improve bytes handling (#9070) 2022-11-03 12:00:24 +01:00
layday 40223373db Update importlib.resources types (#8658)
* Replace `Str[OrBytes]Path` with `str`

A filesystem path is not valid as an abstract resource.

`TraversableResources` cannot only accept strings if `ResourceReader`
accepts both bytes and strings.  `importlib.resources` does not work
with bytes in any case and `ResourceReader` is typed as taking
a `typing.Text` object in `importlib.resources`' source code.

* Update `joinpath` signature from Python 3.11
2022-09-27 20:31:33 +01:00
Alex Waygood 48e76e8a56 Bump mypy to 0.981 (#8796) 2022-09-26 17:14:33 -07:00
Nikita Sobolev 0259068ad6 Remove duplicate definitions in sub-classes (#8594) 2022-08-26 17:10:55 +02:00
Nikita Sobolev 1bd1625c36 importlib: SimplePath: __div__ -> __truediv__ on 3.10 (#8451)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2022-08-02 07:15:46 +01:00
Alex Waygood 553700e355 Move some protocol definitions closer to their usage sites (#8436) 2022-07-29 06:26:27 -07:00
Sebastian Rittau faae950ade Use error codes for type ignores (#8280)
Disable reportSelfClsParameterName for pytype as this is out of typeshed's
control

Closes: #7497
2022-07-12 20:15:49 +02:00
Alex Waygood 6348a58b8b Import Match and Pattern from re, not typing (#8277) 2022-07-12 15:32:48 +02:00
Alex Waygood edc0ecd857 Remove Python 3.6 branches from typeshed (#8269) 2022-07-11 10:55:17 +02:00
Alex Waygood e7a5b7a762 Fix various __all__-related errors and omissions (#8031) 2022-06-07 23:29:55 +01:00
Alex Waygood e88a182573 Simplify __all__ definitions in modules beginning with 'a' to 'l' (#8026) 2022-06-07 15:40:48 +02:00
Alex Waygood acc0167dc1 Fix several new-in-3.11 stubtest errors (#7973) 2022-06-02 18:07:38 -07:00
Alex Waygood e9526faf40 Various py311 removals (#7836) 2022-05-16 17:28:13 -07:00
Alex Waygood 97a74bc1aa Import from collections.abc wherever possible (#7635) 2022-04-18 12:50:37 +02:00
Alex Waygood 740193a8fc Use TypeAlias where possible for type aliases (#7630) 2022-04-15 18:01:00 -07:00
Alex Waygood 340c6c97ed Add mypy error codes to type: ignores, remove unused ignores (#7504)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2022-03-19 13:10:00 +00:00
Alex Waygood 3ab250eec8 Use PEP 604 syntax wherever possible (#7493) 2022-03-16 16:01:33 +01:00
Alex Waygood f4ae363b56 stdlib: correct many pos-or-kw arg names in dunder methods (#7451) 2022-03-07 16:40:03 +01:00
Shantanu 9796b9ed69 Improve open overloads when mode is a literal union (#7428)
As pointed out by @gvanrossum in https://github.com/python/typing/issues/1096

Improves type inference in cases when we know that mode is
OpenBinaryMode, but don't know anything more specific:
```
def my_open(name: str, write: bool):
    mode: Literal['rb', 'wb'] = 'wb' if write else 'rb'
    with open(name, mode) as f:
        reveal_type(f)  # previously typing.IO[Any], now typing.BinaryIO
```

You may be tempted into thinking this is some limitation of type
checkers. mypy does in fact have logic for detecting if we match
multiple overloads and union-ing up the return types of matched
overloads. The problem is the last overload interferes with this logic.
That is, if you remove the fallback overload (prior to this PR), you'd get
"Union[io.BufferedReader, io.BufferedWriter]" in the above example.

Co-authored-by: hauntsaninja <>
2022-03-06 15:45:34 -08:00
Alex Waygood a0b41959ec stdlib: fix many attributes which are read-only at runtime but read-write in the stub (#7395) 2022-02-27 16:23:09 -08:00
Itai Steinherz f4b43daba0 Update importlib.metadata typings for 3.10 (#7331)
Co-authored-by: Sebastian Rittau <srittau@rittau.biz>
2022-02-24 19:15:13 -08:00
Alex Waygood 3e579b8b29 Improve importlib.metadata (#7326) 2022-02-20 14:06:27 -08:00
Alex Waygood 8f2f857ffc Add __all__ for modules beginning with 'h' and 'i' (#7327) 2022-02-20 14:01:45 -08:00
Alex Waygood fbc279e3f5 stdlib: Add many missing dunder overrides (#7231) 2022-02-16 06:25:47 -08:00
Shantanu b88a6f19cd Upgrade black version (#7089) 2022-01-30 16:27:06 -08:00
D. Spindel 136592666b FileFinder takes a class, not an instance (#7085) (#7086)
The FileFinder takes a tuple of (class, arguments) to instantiate for
each time, rather than an existing instance.

Fixes #7085
2022-01-30 08:44:01 -08:00
Alex Waygood 7d33ff330a Clean up several version-dependent modules (#6885) 2022-01-10 05:57:08 -08:00
Sebastian Rittau e77a66aced Update pyright (#6840) 2022-01-07 18:58:15 +02:00
Alex Waygood 8d5d2520ac Use PEP 585 syntax wherever possible (#6717) 2021-12-28 11:31:43 +01:00
Alex Waygood a54e21992c Remove ParamSpec-related # type: ignores (#6703) 2021-12-26 15:27:57 +01:00
Alex Waygood ae725c3f10 Add test to ensure certain names are not imported from typing_extensions (#6619) 2021-12-17 14:50:25 -08:00
Alex Waygood 84fd495b65 Update importlib to reflect recent changes (#6557) 2021-12-10 14:32:55 +01:00
Akuli f29f0a5394 importlib: stubtest fixes for py310 (#6443) 2021-11-29 11:05:54 -08:00
Akuli a5bc1e037f Add mypy error codes to '# type: ignore' comments (#6379) 2021-11-26 07:07:56 +01:00
Alex Waygood dc5f6410a8 DefaultDict -> defaultdict, typing.ContextManager -> contextlib.AbstractContextManager (#6351) 2021-11-21 07:07:35 -08:00
Alex Waygood 1274445941 Resolve builtins/importlib inconsistencies (#6310) 2021-11-16 15:19:21 +01:00
Alex Waygood aa7e277adb Harmonise return type of builtins.__import__ and importlib.import_module (#6302)
builtins.__import__ now returns ModuleType instead of Any. In addition, add __getattr__() to ModuleType to ease using imported modules.
2021-11-15 16:21:46 +01:00
ROHAN SALWAN e38248e818 Fix type of importlib.machinery.ModuleSpec.loader (#6194) 2021-10-25 12:59:49 +03:00
Akuli 994b69ef8f Use lowercase tuple where possible (#6170) 2021-10-14 17:18:19 -07:00
hardikpnsp ee31999caf Add missing methods to ExtensionFileLoader (#6120)
Closes: #4769
2021-10-08 23:14:32 +02:00
Estelle Poulin 15cec1da8e Change Traversable to be inline with pathlib.Path (#5818)
`pathlib.Path` objects are now valid `importlib.abc.Traversable`s.
2021-09-21 21:36:10 +03:00
Anton Grübel 29c63e0d9c add ParamSpec to importlib.util (#5944) 2021-08-21 08:24:25 -07:00
Akuli ce11072dbe Big diff: use lower-case list and dict (#5888) 2021-08-08 09:26:35 -07:00
Akuli ee487304d7 Big diff: Use new "|" union syntax (#5872) 2021-08-08 11:05:21 +02:00
Josh 2b497f7227 importlib.util.resolve_name package argument accepts None (#5730) 2021-07-05 09:21:40 +02:00
Pavel Karateev f4c5ae01c4 Add importlib.metadata.packages_distributions() (#5565) 2021-06-01 20:07:18 +02:00
Sebastian Rittau f0bf6eebbd AnyStr cleanup (#5487)
* Replace all uses of StrPath, BytesPath, and AnyPath in Python 2 stubs.
* Add StrOrBytesPath as preferred alias for AnyPath.
* Replace all remaining AnyPath instances with StrOrBytesPath.
* Mark AnyPath as obsolete.

Part of #5470
2021-05-17 20:45:48 +02:00
Sebastian Rittau e5abd08f93 Replace PathLike unions with aliases from _typeshed (#5467)
Standardize on 'from os import PathLike'
2021-05-16 21:38:00 +02:00
Akuli e66b7fa660 delete _importlib_modulespec (#5350)
* delete _importlib_modulespec

* use typing_extensions.runtime_checkable
2021-05-06 17:13:35 +03:00