Skip to content

Commit db9246b

Browse files
emmatypingJelleZijlstra
authored andcommitted
Fix importlib.resources for mypy (#2130)
1 parent 55be42f commit db9246b

File tree

2 files changed

+25
-22
lines changed

2 files changed

+25
-22
lines changed

stdlib/3.7/importlib/resources.pyi

Lines changed: 0 additions & 22 deletions
This file was deleted.

stdlib/3/importlib/resources.pyi

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import sys
2+
# This is a >=3.7 module, so we conditionally include its source.
3+
if sys.version_info >= (3, 7):
4+
import os
5+
6+
from pathlib import Path
7+
from types import ModuleType
8+
from typing import ContextManager, Iterator, Union, BinaryIO, TextIO
9+
10+
Package = Union[str, ModuleType]
11+
Resource = Union[str, os.PathLike]
12+
13+
def open_binary(package: Package, resource: Resource) -> BinaryIO: ...
14+
def open_text(package: Package,
15+
resource: Resource,
16+
encoding: str = ...,
17+
errors: str = ...) -> TextIO: ...
18+
def read_binary(package: Package, resource: Resource) -> bytes: ...
19+
def read_text(package: Package,
20+
resource: Resource,
21+
encoding: str = ...,
22+
errors: str = ...) -> str: ...
23+
def path(package: Package, resource: Resource) -> ContextManager[Path]: ...
24+
def is_resource(package: Package, name: str) -> bool: ...
25+
def contents(package: Package) -> Iterator[str]: ...

0 commit comments

Comments
 (0)