Skip to content

Commit

Permalink
Fix Mypy errors when ran with "--strict" mode
Browse files Browse the repository at this point in the history
  • Loading branch information
Delgan committed Jul 1, 2022
1 parent 2239669 commit f1c8d48
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
6 changes: 3 additions & 3 deletions loguru/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ class _GeneratorContextManager(ContextManager[_T], Generic[_T]):

Catcher = NewType("Catcher", _GeneratorContextManager[None])
Contextualizer = NewType("Contextualizer", _GeneratorContextManager[None])
AwaitableCompleter = Awaitable
AwaitableCompleter = Awaitable[None]

class Level(NamedTuple):
name: str
Expand Down Expand Up @@ -404,7 +404,7 @@ class Logger:
) -> None: ...
@overload
def log(__self, __level: Union[int, str], __message: Any) -> None: ...
def start(self, *args: Any, **kwargs: Any): ...
def stop(self, *args: Any, **kwargs: Any): ...
def start(self, *args: Any, **kwargs: Any) -> int: ...
def stop(self, *args: Any, **kwargs: Any) -> None: ...

logger: Logger
7 changes: 4 additions & 3 deletions tests/typesafety/test_logger.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,10 @@
- case: async_sink_options
main: |
import loguru
from loguru import logger
import asyncio
async def sink(m):
async def sink(m: loguru.Message) -> None:
pass
logger.add(
sink,
Expand All @@ -108,11 +109,11 @@
main: |
from loguru import logger
awaitable = logger.complete()
async def func():
async def func() -> None:
await awaitable
reveal_type(awaitable)
out: |
main:5: note: Revealed type is "typing.Awaitable[Any]"
main:5: note: Revealed type is "typing.Awaitable[None]"
- case: catch_as_decorator_with_parentheses
main: |
Expand Down
1 change: 1 addition & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,5 @@ testpaths =
tests

[mypy]
strict = true
mypy_path = $MYPY_CONFIG_FILE_DIR/loguru

0 comments on commit f1c8d48

Please sign in to comment.