Skip to content

Commit

Permalink
Flesh out the few remaining incomplete annotations (#316)
Browse files Browse the repository at this point in the history
  • Loading branch information
layday committed Sep 3, 2020
1 parent 084dffd commit d93c19f
Showing 1 changed file with 23 additions and 10 deletions.
33 changes: 23 additions & 10 deletions loguru/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ class RecordException(NamedTuple):
class Record(TypedDict):
elapsed: timedelta
exception: Optional[RecordException]
extra: dict
extra: Dict[Any, Any]
file: RecordFile
function: str
level: RecordLevel
Expand Down Expand Up @@ -204,7 +204,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, TextIO, Writable, Callable[[Message], None], Handler]
sink: Union[str, PathLike[str], TextIO, Writable, Callable[[Message], None], Handler]
level: Union[str, int]
format: Union[str, FormatFunction]
filter: Optional[Union[str, FilterFunction, FilterDict]]
Expand Down Expand Up @@ -258,7 +258,7 @@ class Logger:
@overload
def add(
self,
sink: Union[str, PathLike],
sink: Union[str, PathLike[str]],
*,
level: Union[str, int] = ...,
format: Union[str, FormatFunction] = ...,
Expand Down Expand Up @@ -329,19 +329,32 @@ class Logger:
*,
handlers: Sequence[Dict[str, Any]] = ...,
levels: Optional[Sequence[LevelConfig]] = ...,
extra: Optional[dict] = ...,
extra: Optional[Dict[Any, Any]] = ...,
patcher: Optional[PatcherFunction] = ...,
activation: Optional[Sequence[ActivationConfig]] = ...
) -> List[int]: ...
# @overload should be used to differentiate bytes and str once python/mypy#7781 is fixed
@staticmethod
# @staticmethod cannot be used with @overload in mypy (python/mypy#7781).
# However Logger is not exposed and logger is an instance of Logger
# so for type checkers it is all the same whether it is defined here
# as a static method or an instance method.
@overload
def parse(
file: Union[str, PathLike, TextIO, BinaryIO],
pattern: Union[str, bytes, Pattern[str], Pattern[bytes]],
self,
file: Union[str, PathLike[str], TextIO],
pattern: Union[str, Pattern[str]],
*,
cast: Union[Dict[str, Callable[[str], Any]], Callable[[Dict[str, str]], None]] = ...,
chunk: int = ...
) -> Generator[Dict[str, Any], None, None]: ...
@overload
def parse(
self,
file: BinaryIO,
pattern: Union[bytes, Pattern[bytes]],
*,
cast: Union[dict, Callable[[dict], None]] = ...,
cast: Union[Dict[str, Callable[[bytes], Any]], Callable[[Dict[str, bytes]], None]] = ...,
chunk: int = ...
) -> Generator[dict, None, None]: ...
) -> Generator[Dict[str, Any], None, None]: ...
@overload
def trace(__self, __message: str, *args: Any, **kwargs: Any) -> None: ...
@overload
Expand Down

0 comments on commit d93c19f

Please sign in to comment.