Commit Graph

87 Commits

Author SHA1 Message Date
Stephen Morton fd558f8acf importlib.abc.Loader moved to importlib._abc.Loader in 3.10 (#11142) 2023-12-11 14:48:58 +01:00
Stephen Morton 695d67cd7b Add deprecation classes in importlib.metadata (#11118) 2023-12-10 21:06:22 +01:00
Stephen Morton d373050dbb Fix importlib.abc.Finder base class, method availability (#11134) 2023-12-10 12:01:44 +01:00
Paul Ganssle 336c062489 Remove write modes from importlib.resources.abc.Traversable (#11124) 2023-12-09 20:38:40 -08:00
Alex Waygood 9bbfa3362a Add importlib.machinery.NamespaceLoader (#11074) 2023-11-28 20:02:24 +00:00
Alex Waygood 01432805d9 Fix typos in docs and comments (#11064) 2023-11-23 14:55:58 +00:00
Alex Waygood 10febc4fe0 stdlib: remove unused type: ignore comments (#11061) 2023-11-23 14:00:07 +01:00
Jelle Zijlstra 3229b36644 stdlib: More pos-only parameters to Protocols (#10987) 2023-11-06 23:45:12 +01:00
Jelle Zijlstra 5030b7419b stdlib: Use pos-only parameters for many Protocols (#10985) 2023-11-06 18:09:04 +01:00
Alex Waygood 56288ad2d0 Add stubs for importlib.(resources.)simple (#10931) 2023-10-28 07:29:57 -07:00
Sebastian Rittau 1c184fea33 Simplify Traversable signature (#10934)
Simplify Traversable.open() signature. This is necessary so that implentors can
reasonanbly implement this method. For example `zipfile.Path.open()` (which
is considered a `Traversable`) only supports this subset.

Make `Traversable.__truediv__` and `joinpath` arguments pos-only. The
arguments are named differently in both `pathlib.Path` and `zipfile.Path`.
2023-10-27 00:50:11 +02:00
Alex Waygood 908993a807 Add stubs for importlib.(resources.)readers (#10928)
Co-authored-by: Sebastian Rittau <srittau@rittau.biz>
2023-10-26 14:18:55 +01:00
Marc Mueller 0bc34fc49c Fix importlib.util.source_hash return annotation (#10686) 2023-09-08 16:07:02 -07:00
Nikita Sobolev 53144ca572 Update importlib.metadata to 3.12 (#10665) 2023-09-08 12:42:56 +01:00
Nikita Sobolev d868dad76b Update importlib.metadata to 3.12 (#10654) 2023-09-03 09:47:19 +01:00
Nikita Sobolev 454438e4db Update importlib.resources to 3.12 (#10649) 2023-09-02 00:03:08 -07:00
Alex Waygood 75da5de5c2 Many importlib removals in py312 (#10644) 2023-09-01 13:43:36 +02:00
Shantanu 75c71f324e importlib.metadata: add PathDistribution._path (#10528) 2023-08-01 19:43:51 -07:00
Alex Waygood 03b4bb9cce Stdlib: add many missing __hash__ and __eq__ methods (#10464) 2023-07-17 14:21:02 +02:00
Alex Waygood dd2818a41d Stdlib: add container default values (#9909) 2023-03-21 09:12:34 +01:00
Oleg Höfling c661ac3ad6 importlib.abc: align input data types in InspectLoader.source_to_code builtin.compile inputs (#9852)
Signed-off-by: oleg.hoefling <oleg.hoefling@gmail.com>
2023-03-08 13:43:05 +00:00
Alex Waygood 75ecd7e229 importlib.resources is a package on 3.11+ (#9822) 2023-03-08 08:36:18 +00:00
Alex Waygood 6ba28ae547 Remove unused type: ignore comments (#9801) 2023-02-23 12:59:50 -08:00
Alex Waygood 9ed39d8796 Use typing_extensions.Self in the stdlib (#9694) 2023-02-09 09:12:13 +00:00
Alex Waygood 53747b264e Stdlib: add 'obvious' default values (#9688) 2023-02-07 13:00:40 +01:00
Akuli 37a180ef7b Use octal for mode defaults (#9670) 2023-02-03 19:12:53 +00:00
Alex Waygood 33a62ae42d Add more defaults to the stdlib (#9606)
Continuing work towards #8988.

The first five commits were created using stubdefaulter on various Python versions; the following commits were all created manually by me to fix various problems. The main things this adds that weren't present in #9501 are:

- Defaults in Windows-only modules and Windows-only branches (because I'm running a Windows machine)
- Defaults in non-py311 branches
- Defaults for float parameters
- Defaults for overloads
2023-01-29 01:51:23 +00:00
Jelle Zijlstra ddfaca3200 stdlib: add argument default values (#9501) 2023-01-18 09:37:34 +01:00
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