Skip to content

Commit

Permalink
Refine SimplePath to allow for os.PathLike on input and SimplePath on…
Browse files Browse the repository at this point in the history
… output.
  • Loading branch information
jaraco committed Dec 16, 2023
1 parent 200cf45 commit b99c9d6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
2 changes: 0 additions & 2 deletions docs/conf.py
Expand Up @@ -71,6 +71,4 @@
('py:class', '_T'),
# Other workarounds
('py:class', 'importlib_metadata.DeprecatedNonAbstract'),
# Workaround needed for #480
('py:obj', 'importlib_metadata._meta._T'),
]
11 changes: 7 additions & 4 deletions importlib_metadata/_meta.py
@@ -1,3 +1,6 @@
from __future__ import annotations

import os
from typing import Protocol
from typing import Any, Dict, Iterator, List, Optional, TypeVar, Union, overload

Expand Down Expand Up @@ -44,19 +47,19 @@ def json(self) -> Dict[str, Union[str, List[str]]]:
"""


class SimplePath(Protocol[_T]):
class SimplePath(Protocol):
"""
A minimal subset of pathlib.Path required by Distribution.
"""

def joinpath(self, other: Union[str, _T]) -> _T:
def joinpath(self, other: Union[str, os.PathLike[str]]) -> SimplePath:
... # pragma: no cover

def __truediv__(self, other: Union[str, _T]) -> _T:
def __truediv__(self, other: Union[str, os.PathLike[str]]) -> SimplePath:
... # pragma: no cover

@property
def parent(self) -> _T:
def parent(self) -> SimplePath:
... # pragma: no cover

def read_text(self, encoding=None) -> str:
Expand Down

0 comments on commit b99c9d6

Please sign in to comment.