mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
Issue 10899: Remove function type annotations from the stdlib
This commit is contained in:
parent
cbb80896ae
commit
d958ea70bc
2 changed files with 24 additions and 18 deletions
|
@ -346,8 +346,8 @@ class _LoaderBasics:
|
||||||
class SourceLoader(_LoaderBasics):
|
class SourceLoader(_LoaderBasics):
|
||||||
|
|
||||||
def path_mtime(self, path):
|
def path_mtime(self, path):
|
||||||
"""Optional method that returns the modification time for the specified
|
"""Optional method that returns the modification time (an int) for the
|
||||||
path.
|
specified path, where path is a str.
|
||||||
|
|
||||||
Implementing this method allows the loader to read bytecode files.
|
Implementing this method allows the loader to read bytecode files.
|
||||||
|
|
||||||
|
@ -355,7 +355,7 @@ class SourceLoader(_LoaderBasics):
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
||||||
def set_data(self, path, data):
|
def set_data(self, path, data):
|
||||||
"""Optional method which writes data to a file path.
|
"""Optional method which writes data (bytes) to a file path (a str).
|
||||||
|
|
||||||
Implementing this method allows for the writing of bytecode files.
|
Implementing this method allows for the writing of bytecode files.
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,8 @@ class Loader(metaclass=abc.ABCMeta):
|
||||||
|
|
||||||
@abc.abstractmethod
|
@abc.abstractmethod
|
||||||
def load_module(self, fullname):
|
def load_module(self, fullname):
|
||||||
"""Abstract method which when implemented should load a module."""
|
"""Abstract method which when implemented should load a module.
|
||||||
|
The fullname is a str."""
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
||||||
|
|
||||||
|
@ -29,7 +30,10 @@ class Finder(metaclass=abc.ABCMeta):
|
||||||
|
|
||||||
@abc.abstractmethod
|
@abc.abstractmethod
|
||||||
def find_module(self, fullname, path=None):
|
def find_module(self, fullname, path=None):
|
||||||
"""Abstract method which when implemented should find a module."""
|
"""Abstract method which when implemented should find a module.
|
||||||
|
The fullname is a str and the optional path is a str or None.
|
||||||
|
Returns a Loader object.
|
||||||
|
"""
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
||||||
Finder.register(machinery.BuiltinImporter)
|
Finder.register(machinery.BuiltinImporter)
|
||||||
|
@ -49,7 +53,7 @@ class ResourceLoader(Loader):
|
||||||
@abc.abstractmethod
|
@abc.abstractmethod
|
||||||
def get_data(self, path):
|
def get_data(self, path):
|
||||||
"""Abstract method which when implemented should return the bytes for
|
"""Abstract method which when implemented should return the bytes for
|
||||||
the specified path."""
|
the specified path. The path must be a str."""
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
||||||
|
|
||||||
|
@ -65,19 +69,19 @@ class InspectLoader(Loader):
|
||||||
@abc.abstractmethod
|
@abc.abstractmethod
|
||||||
def is_package(self, fullname):
|
def is_package(self, fullname):
|
||||||
"""Abstract method which when implemented should return whether the
|
"""Abstract method which when implemented should return whether the
|
||||||
module is a package."""
|
module is a package. The fullname is a str. Returns a bool."""
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
||||||
@abc.abstractmethod
|
@abc.abstractmethod
|
||||||
def get_code(self, fullname):
|
def get_code(self, fullname):
|
||||||
"""Abstract method which when implemented should return the code object
|
"""Abstract method which when implemented should return the code object
|
||||||
for the module"""
|
for the module. The fullname is a str. Returns a types.CodeType."""
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
||||||
@abc.abstractmethod
|
@abc.abstractmethod
|
||||||
def get_source(self, fullname):
|
def get_source(self, fullname):
|
||||||
"""Abstract method which should return the source code for the
|
"""Abstract method which should return the source code for the
|
||||||
module."""
|
module. The fullname is a str. Returns a str."""
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
||||||
InspectLoader.register(machinery.BuiltinImporter)
|
InspectLoader.register(machinery.BuiltinImporter)
|
||||||
|
@ -118,12 +122,14 @@ class SourceLoader(_bootstrap.SourceLoader, ResourceLoader, ExecutionLoader):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def path_mtime(self, path):
|
def path_mtime(self, path):
|
||||||
"""Return the modification time for the path."""
|
"""Return the (int) modification time for the path (str)."""
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
||||||
def set_data(self, path, data):
|
def set_data(self, path, data):
|
||||||
"""Write the bytes to the path (if possible).
|
"""Write the bytes to the path (if possible).
|
||||||
|
|
||||||
|
Accepts a str path and data as bytes.
|
||||||
|
|
||||||
Any needed intermediary directories are to be created. If for some
|
Any needed intermediary directories are to be created. If for some
|
||||||
reason the file cannot be written because of permissions, fail
|
reason the file cannot be written because of permissions, fail
|
||||||
silently.
|
silently.
|
||||||
|
@ -171,8 +177,8 @@ class PyLoader(SourceLoader):
|
||||||
|
|
||||||
@abc.abstractmethod
|
@abc.abstractmethod
|
||||||
def source_path(self, fullname):
|
def source_path(self, fullname):
|
||||||
"""Abstract method which when implemented should return the path to the
|
"""Abstract method. Accepts a str module name and returns the path to
|
||||||
source code for the module."""
|
the source code for the module."""
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
||||||
def get_filename(self, fullname):
|
def get_filename(self, fullname):
|
||||||
|
@ -280,19 +286,19 @@ class PyPycLoader(PyLoader):
|
||||||
|
|
||||||
@abc.abstractmethod
|
@abc.abstractmethod
|
||||||
def source_mtime(self, fullname):
|
def source_mtime(self, fullname):
|
||||||
"""Abstract method which when implemented should return the
|
"""Abstract method. Accepts a str filename and returns an int
|
||||||
modification time for the source of the module."""
|
modification time for the source of the module."""
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
||||||
@abc.abstractmethod
|
@abc.abstractmethod
|
||||||
def bytecode_path(self, fullname):
|
def bytecode_path(self, fullname):
|
||||||
"""Abstract method which when implemented should return the path to the
|
"""Abstract method. Accepts a str filename and returns the str pathname
|
||||||
bytecode for the module."""
|
to the bytecode for the module."""
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
||||||
@abc.abstractmethod
|
@abc.abstractmethod
|
||||||
def write_bytecode(self, fullname, bytecode):
|
def write_bytecode(self, fullname, bytecode):
|
||||||
"""Abstract method which when implemented should attempt to write the
|
"""Abstract method. Accepts a str filename and bytes object
|
||||||
bytecode for the module, returning a boolean representing whether the
|
representing the bytecode for the module. Returns a boolean
|
||||||
bytecode was written or not."""
|
representing whether the bytecode was written or not."""
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue