Skip to content

Commit

Permalink
Fix missing "context" parameter in stub file
Browse files Browse the repository at this point in the history
  • Loading branch information
Delgan committed Apr 25, 2023
1 parent 9faba68 commit 20cbb9e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
4 changes: 4 additions & 0 deletions loguru/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ import sys
from asyncio import AbstractEventLoop
from datetime import datetime, time, timedelta
from logging import Handler
from multiprocessing.context import BaseContext
from types import TracebackType
from typing import (
Any,
Expand Down Expand Up @@ -246,6 +247,7 @@ class Logger:
backtrace: bool = ...,
diagnose: bool = ...,
enqueue: bool = ...,
context: Optional[Union[str, BaseContext]] = ...,
catch: bool = ...
) -> int: ...
@overload
Expand All @@ -261,6 +263,7 @@ class Logger:
backtrace: bool = ...,
diagnose: bool = ...,
enqueue: bool = ...,
context: Optional[Union[str, BaseContext]] = ...,
catch: bool = ...,
loop: Optional[AbstractEventLoop] = ...
) -> int: ...
Expand All @@ -277,6 +280,7 @@ class Logger:
backtrace: bool = ...,
diagnose: bool = ...,
enqueue: bool = ...,
context: Optional[Union[str, BaseContext]] = ...,
catch: bool = ...,
rotation: Optional[Union[str, int, time, timedelta, RotationFunction]] = ...,
retention: Optional[Union[str, int, timedelta, RetentionFunction]] = ...,
Expand Down
17 changes: 13 additions & 4 deletions tests/typesafety/test_logger.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
- message: object()
main: |
from loguru import logger
logger.info({{ message }})
logger.info({{message}})
- case: add_sink
parametrized:
Expand All @@ -51,24 +51,33 @@
from loguru import logger
from logging import StreamHandler
from pathlib import Path
id = logger.add({{ sink }})
id = logger.add({{sink}})
reveal_type(id)
out: |
main:6: note: Revealed type is "builtins.int"
- case: basic_sink_options
parametrized:
- format: "'{message}'"
filter: "'module'"
context: "'fork'"
- format: "lambda r: '{message}\\n'"
filter: 'lambda r: True'
context: get_context('fork')
main: |
import sys
from multiprocessing import get_context
from loguru import logger
logger.add(
sys.stdout,
format="{message}",
filter=lambda r: True,
format={{format}},
filter={{filter}},
colorize=False,
serialize=True,
backtrace=True,
diagnose=False,
enqueue=True,
context={{context}},
catch=False,
)
Expand Down

0 comments on commit 20cbb9e

Please sign in to comment.