Skip to content

Commit

Permalink
Remove ruff config excludes (#968)
Browse files Browse the repository at this point in the history
  • Loading branch information
hillairet committed Sep 3, 2023
1 parent f339282 commit 901dc33
Show file tree
Hide file tree
Showing 17 changed files with 67 additions and 64 deletions.
40 changes: 20 additions & 20 deletions loguru/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -320,8 +320,8 @@ class Logger:
depth: int = ...,
ansi: bool = ...
) -> Logger: ...
def bind(__self, **kwargs: Any) -> Logger: ...
def contextualize(__self, **kwargs: Any) -> Contextualizer: ...
def bind(__self, **kwargs: Any) -> Logger: ... # noqa: N805
def contextualize(__self, **kwargs: Any) -> Contextualizer: ... # noqa: N805
def patch(self, patcher: PatcherFunction) -> Logger: ...
@overload
def level(self, name: str) -> Level: ...
Expand Down Expand Up @@ -371,43 +371,43 @@ class Logger:
chunk: int = ...
) -> Generator[Dict[str, Any], None, None]: ...
@overload
def trace(__self, __message: str, *args: Any, **kwargs: Any) -> None: ...
def trace(__self, __message: str, *args: Any, **kwargs: Any) -> None: ... # noqa: N805
@overload
def trace(__self, __message: Any) -> None: ...
def trace(__self, __message: Any) -> None: ... # noqa: N805
@overload
def debug(__self, __message: str, *args: Any, **kwargs: Any) -> None: ...
def debug(__self, __message: str, *args: Any, **kwargs: Any) -> None: ... # noqa: N805
@overload
def debug(__self, __message: Any) -> None: ...
def debug(__self, __message: Any) -> None: ... # noqa: N805
@overload
def info(__self, __message: str, *args: Any, **kwargs: Any) -> None: ...
def info(__self, __message: str, *args: Any, **kwargs: Any) -> None: ... # noqa: N805
@overload
def info(__self, __message: Any) -> None: ...
def info(__self, __message: Any) -> None: ... # noqa: N805
@overload
def success(__self, __message: str, *args: Any, **kwargs: Any) -> None: ...
def success(__self, __message: str, *args: Any, **kwargs: Any) -> None: ... # noqa: N805
@overload
def success(__self, __message: Any) -> None: ...
def success(__self, __message: Any) -> None: ... # noqa: N805
@overload
def warning(__self, __message: str, *args: Any, **kwargs: Any) -> None: ...
def warning(__self, __message: str, *args: Any, **kwargs: Any) -> None: ... # noqa: N805
@overload
def warning(__self, __message: Any) -> None: ...
def warning(__self, __message: Any) -> None: ... # noqa: N805
@overload
def error(__self, __message: str, *args: Any, **kwargs: Any) -> None: ...
def error(__self, __message: str, *args: Any, **kwargs: Any) -> None: ... # noqa: N805
@overload
def error(__self, __message: Any) -> None: ...
def error(__self, __message: Any) -> None: ... # noqa: N805
@overload
def critical(__self, __message: str, *args: Any, **kwargs: Any) -> None: ...
def critical(__self, __message: str, *args: Any, **kwargs: Any) -> None: ... # noqa: N805
@overload
def critical(__self, __message: Any) -> None: ...
def critical(__self, __message: Any) -> None: ... # noqa: N805
@overload
def exception(__self, __message: str, *args: Any, **kwargs: Any) -> None: ...
def exception(__self, __message: str, *args: Any, **kwargs: Any) -> None: ... # noqa: N805
@overload
def exception(__self, __message: Any) -> None: ...
def exception(__self, __message: Any) -> None: ... # noqa: N805
@overload
def log(
__self, __level: Union[int, str], __message: str, *args: Any, **kwargs: Any
__self, __level: Union[int, str], __message: str, *args: Any, **kwargs: Any # noqa: N805
) -> None: ...
@overload
def log(__self, __level: Union[int, str], __message: Any) -> None: ...
def log(__self, __level: Union[int, str], __message: Any) -> None: ... # noqa: N805
def start(self, *args: Any, **kwargs: Any) -> int: ...
def stop(self, *args: Any, **kwargs: Any) -> None: ...

Expand Down
11 changes: 8 additions & 3 deletions loguru/_logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -894,7 +894,7 @@ def add(
raise ValueError(
"The filter dict contains a module '%s' associated to a level name "
"which does not exist: '%s'" % (module, level_)
)
) from None
elif isinstance(level_, int):
levelno_ = level_
else:
Expand Down Expand Up @@ -1378,6 +1378,7 @@ def opt(
warnings.warn(
"The 'ansi' parameter is deprecated, please use 'colors' instead",
DeprecationWarning,
stacklevel=2,
)

args = self._options[-2:]
Expand Down Expand Up @@ -2079,7 +2080,9 @@ def start(self, *args, **kwargs):
confusing name.
"""
warnings.warn(
"The 'start()' method is deprecated, please use 'add()' instead", DeprecationWarning
"The 'start()' method is deprecated, please use 'add()' instead",
DeprecationWarning,
stacklevel=2,
)
return self.add(*args, **kwargs)

Expand All @@ -2093,6 +2096,8 @@ def stop(self, *args, **kwargs):
confusing name.
"""
warnings.warn(
"The 'stop()' method is deprecated, please use 'remove()' instead", DeprecationWarning
"The 'stop()' method is deprecated, please use 'remove()' instead",
DeprecationWarning,
stacklevel=2,
)
return self.remove(*args, **kwargs)
4 changes: 1 addition & 3 deletions ruff.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# Enforce pyflakes(F), pycodestyle(E, W), isort (I), bugbears (B), and pep8-naming (N) rules
select = ["F", "E", "W", "I", "B", "N"]
# Ignore these errors for now that are picked up by ruff but were not by flake8
ignore = ["B904", "B033", "B028", "B018"]
line-length = 100
exclude = ["tests/exceptions/source", "loguru/__init__.pyi"]
exclude = ["tests/exceptions/source"]
[pycodestyle]
max-doc-length = 100
1 change: 1 addition & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ def check_env_variables():
"A Loguru environment variable has been detected "
"and may interfere with the tests: '%s'" % var,
RuntimeWarning,
stacklevel=1,
)


Expand Down
4 changes: 2 additions & 2 deletions tests/test_add_option_backtrace.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
def test_backtrace(writer):
logger.add(writer, format="{message}", backtrace=True)
try:
1 / 0
1 / 0 # noqa: B018
except Exception:
logger.exception("")
result_with = writer.read().strip()
Expand All @@ -16,7 +16,7 @@ def test_backtrace(writer):

logger.add(writer, format="{message}", backtrace=False)
try:
1 / 0
1 / 0 # noqa: B018
except Exception:
logger.exception("")
result_without = writer.read().strip()
Expand Down
4 changes: 2 additions & 2 deletions tests/test_add_option_diagnose.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
def test_diagnose(writer):
logger.add(writer, format="{message}", diagnose=True)
try:
1 / 0
1 / 0 # noqa: B018
except Exception:
logger.exception("")
result_with = writer.read().strip()
Expand All @@ -16,7 +16,7 @@ def test_diagnose(writer):

logger.add(writer, format="{message}", diagnose=False)
try:
1 / 0
1 / 0 # noqa: B018
except Exception:
logger.exception("")
result_without = writer.read().strip()
Expand Down
2 changes: 1 addition & 1 deletion tests/test_add_option_enqueue.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def sink(message):
logger.add(sink, format="{message}", enqueue=True)

try:
1 / 0
1 / 0 # noqa: B018
except ZeroDivisionError:
logger.exception("Error")

Expand Down
4 changes: 2 additions & 2 deletions tests/test_add_option_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def formatter(record):
def test_function_format_without_exception(writer):
logger.add(writer, format=lambda _: "{message}\n")
try:
1 / 0
1 / 0 # noqa: B018
except ZeroDivisionError:
logger.exception("Error!")
assert writer.read() == "Error!\n"
Expand All @@ -48,7 +48,7 @@ def test_function_format_without_exception(writer):
def test_function_format_with_exception(writer):
logger.add(writer, format=lambda _: "{message}\n{exception}")
try:
1 / 0
1 / 0 # noqa: B018
except ZeroDivisionError:
logger.exception("Error!")
lines = writer.read().splitlines()
Expand Down
4 changes: 2 additions & 2 deletions tests/test_add_option_serialize.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def test_serialize_exception():
logger.add(sink, format="{message}", serialize=True, catch=False)

try:
1 / 0
1 / 0 # noqa: B018
except ZeroDivisionError:
logger.exception("Error")

Expand Down Expand Up @@ -114,7 +114,7 @@ def test_serialize_with_catch_decorator():

@logger.catch
def foo():
1 / 0
1 / 0 # noqa: B018

foo()

Expand Down
2 changes: 1 addition & 1 deletion tests/test_contextualize.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ def test_context_reset_despite_error(writer):
try:
with logger.contextualize(foobar=456):
logger.info("Division")
1 / 0
1 / 0 # noqa: B018
except ZeroDivisionError:
logger.info("Error")

Expand Down
34 changes: 17 additions & 17 deletions tests/test_exceptions_catch.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def test_has_sys_real_prefix(writer, monkeypatch):
logger.add(writer, backtrace=False, diagnose=True, colorize=False, format="")

try:
1 / 0
1 / 0 # noqa: B018
except ZeroDivisionError:
logger.exception("")

Expand All @@ -113,7 +113,7 @@ def test_no_sys_real_prefix(writer, monkeypatch):
logger.add(writer, backtrace=False, diagnose=True, colorize=False, format="")

try:
1 / 0
1 / 0 # noqa: B018
except ZeroDivisionError:
logger.exception("")

Expand All @@ -125,7 +125,7 @@ def test_has_site_getsitepackages(writer, monkeypatch):
logger.add(writer, backtrace=False, diagnose=True, colorize=False, format="")

try:
1 / 0
1 / 0 # noqa: B018
except ZeroDivisionError:
logger.exception("")

Expand All @@ -137,7 +137,7 @@ def test_no_site_getsitepackages(writer, monkeypatch):
logger.add(writer, backtrace=False, diagnose=True, colorize=False, format="")

try:
1 / 0
1 / 0 # noqa: B018
except ZeroDivisionError:
logger.exception("")

Expand All @@ -149,7 +149,7 @@ def test_user_site_is_path(writer, monkeypatch):
logger.add(writer, backtrace=False, diagnose=True, colorize=False, format="")

try:
1 / 0
1 / 0 # noqa: B018
except ZeroDivisionError:
logger.exception("")

Expand All @@ -161,7 +161,7 @@ def test_user_site_is_none(writer, monkeypatch):
logger.add(writer, backtrace=False, diagnose=True, colorize=False, format="")

try:
1 / 0
1 / 0 # noqa: B018
except ZeroDivisionError:
logger.exception("")

Expand All @@ -173,7 +173,7 @@ def test_sysconfig_get_path_return_path(writer, monkeypatch):
logger.add(writer, backtrace=False, diagnose=True, colorize=False, format="")

try:
1 / 0
1 / 0 # noqa: B018
except ZeroDivisionError:
logger.exception("")

Expand All @@ -185,7 +185,7 @@ def test_sysconfig_get_path_return_none(writer, monkeypatch):
logger.add(writer, backtrace=False, diagnose=True, colorize=False, format="")

try:
1 / 0
1 / 0 # noqa: B018
except ZeroDivisionError:
logger.exception("")

Expand Down Expand Up @@ -227,7 +227,7 @@ def writer(msg):
logger.add(writer, catch=False)

try:
1 / 0
1 / 0 # noqa: B018
except ZeroDivisionError:
logger.exception("Exception")
reference = sys.exc_info()
Expand Down Expand Up @@ -256,7 +256,7 @@ def test_exception_not_raising(writer, exception):

@logger.catch(exception)
def a():
1 / 0
1 / 0 # noqa: B018

a()
assert writer.read().endswith("ZeroDivisionError: division by zero\n")
Expand All @@ -268,7 +268,7 @@ def test_exception_raising(writer, exception):

@logger.catch(exception=exception)
def a():
1 / 0
1 / 0 # noqa: B018

with pytest.raises(ZeroDivisionError):
a()
Expand All @@ -285,7 +285,7 @@ def test_exclude_exception_raising(writer, exclude, exception):

@logger.catch(exception, exclude=exclude)
def a():
1 / 0
1 / 0 # noqa: B018

with pytest.raises(ZeroDivisionError):
a()
Expand All @@ -300,7 +300,7 @@ def test_exclude_exception_not_raising(writer, exclude, exception):

@logger.catch(exception, exclude=exclude)
def a():
1 / 0
1 / 0 # noqa: B018

a()
assert writer.read().endswith("ZeroDivisionError: division by zero\n")
Expand All @@ -311,7 +311,7 @@ def test_reraise(writer):

@logger.catch(reraise=True)
def a():
1 / 0
1 / 0 # noqa: B018

with pytest.raises(ZeroDivisionError):
a()
Expand All @@ -331,7 +331,7 @@ def onerror(error):

@logger.catch(onerror=onerror)
def a():
1 / 0
1 / 0 # noqa: B018

a()

Expand All @@ -351,7 +351,7 @@ def onerror(_):

with pytest.raises(ZeroDivisionError):
with logger.catch(onerror=onerror, reraise=True):
1 / 0
1 / 0 # noqa: B018

assert called

Expand Down Expand Up @@ -408,7 +408,7 @@ def foo():
def test_default_with_function():
@logger.catch(default=42)
def foo():
1 / 0
1 / 0 # noqa: B018

assert foo() == 42

Expand Down
1 change: 0 additions & 1 deletion tests/test_filesink_retention.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ def test_managed_files(tmp_path):
"test.log.1",
"test.log.1.gz",
"test.log.rar",
"test.log",
"test.2019-11-12_03-22-07_018985.log",
"test.2019-11-12_03-22-07_018985.log.tar.gz",
"test.2019-11-12_03-22-07_018985.2.log",
Expand Down
2 changes: 1 addition & 1 deletion tests/test_interception.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def test_exception(writer):
logger.add(writer, format="{message}")

try:
1 / 0
1 / 0 # noqa: B018
except Exception:
logging_logger.exception("Oops...")

Expand Down

0 comments on commit 901dc33

Please sign in to comment.