Skip to content

Commit

Permalink
Fix type hints stub broken for Python 3.5
Browse files Browse the repository at this point in the history
  • Loading branch information
Delgan committed Jun 13, 2022
1 parent db7680a commit 3333e23
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions loguru/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,10 @@ else:
if sys.version_info >= (3, 6):
from os import PathLike
from typing import ContextManager

PathLikeStr = PathLike[str]
else:
from pathlib import PurePath as PathLike
from pathlib import PurePath as PathLikeStr

from typing_extensions import ContextManager

Expand All @@ -138,7 +140,7 @@ class _GeneratorContextManager(ContextManager[_T], Generic[_T]):
def __call__(self, func: _F) -> _F: ...
def __exit__(
self,
typ: Optional[type[BaseException]],
typ: Optional[Type[BaseException]],
value: Optional[BaseException],
traceback: Optional[TracebackType],
) -> Optional[bool]: ...
Expand Down Expand Up @@ -210,7 +212,7 @@ CompressionFunction = Callable[[str], None]

# Actually unusable because TypedDict can't allow extra keys: python/mypy#4617
class _HandlerConfig(TypedDict, total=False):
sink: Union[str, PathLike[str], TextIO, Writable, Callable[[Message], None], Handler]
sink: Union[str, PathLikeStr, TextIO, Writable, Callable[[Message], None], Handler]
level: Union[str, int]
format: Union[str, FormatFunction]
filter: Optional[Union[str, FilterFunction, FilterDict]]
Expand Down Expand Up @@ -264,7 +266,7 @@ class Logger:
@overload
def add(
self,
sink: Union[str, PathLike[str]],
sink: Union[str, PathLikeStr],
*,
level: Union[str, int] = ...,
format: Union[str, FormatFunction] = ...,
Expand Down Expand Up @@ -347,7 +349,7 @@ class Logger:
@overload
def parse(
self,
file: Union[str, PathLike[str], TextIO],
file: Union[str, PathLikeStr, TextIO],
pattern: Union[str, Pattern[str]],
*,
cast: Union[Dict[str, Callable[[str], Any]], Callable[[Dict[str, str]], None]] = ...,
Expand Down

0 comments on commit 3333e23

Please sign in to comment.