From 98196a7fe04d74d7af46e1b052f8124a3fe91dd3 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Fri, 22 Dec 2023 09:28:26 -0500 Subject: [PATCH] Fixed type annotations to allow strings. --- importlib_metadata/__init__.py | 8 ++++---- newsfragments/+e563b690.bugfix.rst | 1 + 2 files changed, 5 insertions(+), 4 deletions(-) create mode 100644 newsfragments/+e563b690.bugfix.rst diff --git a/importlib_metadata/__init__.py b/importlib_metadata/__init__.py index 02c799d1..0ce535a1 100644 --- a/importlib_metadata/__init__.py +++ b/importlib_metadata/__init__.py @@ -388,7 +388,7 @@ def read_text(self, filename) -> Optional[str]: """ @abc.abstractmethod - def locate_file(self, path: os.PathLike[str]) -> SimplePath: + def locate_file(self, path: str | os.PathLike[str]) -> SimplePath: """ Given a path to a file in this distribution, return a SimplePath to it. @@ -433,7 +433,7 @@ def discover( ) @staticmethod - def at(path: os.PathLike[str]) -> "Distribution": + def at(path: str | os.PathLike[str]) -> "Distribution": """Return a Distribution for the indicated metadata path. :param path: a string or path-like object @@ -841,7 +841,7 @@ def __init__(self, path: SimplePath) -> None: """ self._path = path - def read_text(self, filename: os.PathLike[str]) -> Optional[str]: + def read_text(self, filename: str | os.PathLike[str]) -> Optional[str]: with suppress( FileNotFoundError, IsADirectoryError, @@ -855,7 +855,7 @@ def read_text(self, filename: os.PathLike[str]) -> Optional[str]: read_text.__doc__ = Distribution.read_text.__doc__ - def locate_file(self, path: os.PathLike[str]) -> SimplePath: + def locate_file(self, path: str | os.PathLike[str]) -> SimplePath: return self._path.parent / path @property diff --git a/newsfragments/+e563b690.bugfix.rst b/newsfragments/+e563b690.bugfix.rst new file mode 100644 index 00000000..7a1bcc66 --- /dev/null +++ b/newsfragments/+e563b690.bugfix.rst @@ -0,0 +1 @@ +Fixed type annotations to allow strings. \ No newline at end of file