11import sys
22import types
3- from _typeshed import OpenBinaryMode , OpenBinaryModeReading , OpenBinaryModeUpdating , OpenBinaryModeWriting , OpenTextMode
3+ from _typeshed import (
4+ OpenBinaryMode ,
5+ OpenBinaryModeReading ,
6+ OpenBinaryModeUpdating ,
7+ OpenBinaryModeWriting ,
8+ OpenTextMode ,
9+ ReadableBuffer ,
10+ )
411from abc import ABCMeta , abstractmethod
512from collections .abc import Iterator , Mapping , Sequence
613from importlib .machinery import ModuleSpec
714from io import BufferedRandom , BufferedReader , BufferedWriter , FileIO , TextIOWrapper
815from typing import IO , Any , BinaryIO , NoReturn , Protocol , overload , runtime_checkable
9- from typing_extensions import Literal , TypeAlias
16+ from typing_extensions import Literal
1017
1118if sys .version_info >= (3 , 11 ):
1219 __all__ = [
@@ -24,8 +31,6 @@ if sys.version_info >= (3, 11):
2431 "TraversableResources" ,
2532 ]
2633
27- _Path : TypeAlias = bytes | str
28-
2934class Finder (metaclass = ABCMeta ): ...
3035
3136class Loader (metaclass = ABCMeta ):
@@ -38,7 +43,7 @@ class Loader(metaclass=ABCMeta):
3843
3944class ResourceLoader (Loader ):
4045 @abstractmethod
41- def get_data (self , path : _Path ) -> bytes : ...
46+ def get_data (self , path : str ) -> bytes : ...
4247
4348class InspectLoader (Loader ):
4449 def is_package (self , fullname : str ) -> bool : ...
@@ -47,40 +52,40 @@ class InspectLoader(Loader):
4752 def get_source (self , fullname : str ) -> str | None : ...
4853 def exec_module (self , module : types .ModuleType ) -> None : ...
4954 @staticmethod
50- def source_to_code (data : bytes | str , path : str = ...) -> types .CodeType : ...
55+ def source_to_code (data : ReadableBuffer | str , path : str = ...) -> types .CodeType : ...
5156
5257class ExecutionLoader (InspectLoader ):
5358 @abstractmethod
54- def get_filename (self , fullname : str ) -> _Path : ...
59+ def get_filename (self , fullname : str ) -> str : ...
5560
5661class SourceLoader (ResourceLoader , ExecutionLoader , metaclass = ABCMeta ):
57- def path_mtime (self , path : _Path ) -> float : ...
58- def set_data (self , path : _Path , data : bytes ) -> None : ...
62+ def path_mtime (self , path : str ) -> float : ...
63+ def set_data (self , path : str , data : bytes ) -> None : ...
5964 def get_source (self , fullname : str ) -> str | None : ...
60- def path_stats (self , path : _Path ) -> Mapping [str , Any ]: ...
65+ def path_stats (self , path : str ) -> Mapping [str , Any ]: ...
6166
6267# Please keep in sync with sys._MetaPathFinder
6368class MetaPathFinder (Finder ):
64- def find_module (self , fullname : str , path : Sequence [_Path ] | None ) -> Loader | None : ...
69+ def find_module (self , fullname : str , path : Sequence [str ] | None ) -> Loader | None : ...
6570 def invalidate_caches (self ) -> None : ...
6671 # Not defined on the actual class, but expected to exist.
6772 def find_spec (
68- self , fullname : str , path : Sequence [_Path ] | None , target : types .ModuleType | None = ...
73+ self , fullname : str , path : Sequence [str ] | None , target : types .ModuleType | None = ...
6974 ) -> ModuleSpec | None : ...
7075
7176class PathEntryFinder (Finder ):
7277 def find_module (self , fullname : str ) -> Loader | None : ...
73- def find_loader (self , fullname : str ) -> tuple [Loader | None , Sequence [_Path ]]: ...
78+ def find_loader (self , fullname : str ) -> tuple [Loader | None , Sequence [str ]]: ...
7479 def invalidate_caches (self ) -> None : ...
7580 # Not defined on the actual class, but expected to exist.
7681 def find_spec (self , fullname : str , target : types .ModuleType | None = ...) -> ModuleSpec | None : ...
7782
7883class FileLoader (ResourceLoader , ExecutionLoader , metaclass = ABCMeta ):
7984 name : str
80- path : _Path
81- def __init__ (self , fullname : str , path : _Path ) -> None : ...
82- def get_data (self , path : _Path ) -> bytes : ...
83- def get_filename (self , name : str | None = ...) -> _Path : ...
85+ path : str
86+ def __init__ (self , fullname : str , path : str ) -> None : ...
87+ def get_data (self , path : str ) -> bytes : ...
88+ def get_filename (self , name : str | None = ...) -> str : ...
8489 def load_module (self , name : str | None = ...) -> types .ModuleType : ...
8590
8691class ResourceReader (metaclass = ABCMeta ):
0 commit comments