Skip to content

mypy plugin for loguru

License

Notifications You must be signed in to change notification settings

kornicameister/loguru-mypy

Folders and files

NameName
Last commit message
Last commit date
Jan 9, 2024
Jan 27, 2021
Feb 3, 2024
Jan 26, 2021
Jun 13, 2020
Jan 4, 2022
Jun 1, 2020
Apr 11, 2021
Nov 11, 2020
Jun 13, 2020
Jun 13, 2020
Nov 11, 2020
Nov 17, 2020

Repository files navigation

loguru-mypy

A fancy plugin to boost up your logging with loguru

GitHub Workflow Status (branch) Open Source Helpers PyPI PyPI - Downloads time tracker Checked with mypy

mypy compatibility

logoru-mypy should be compatible with mypy>=0.770. Currently there is no limit as far as the compatibility can go. If you are interested to see how far loguru_mypy goes you can visit CI/CD action and check its matrix.

Installation

Simply execute:

pip install loguru-mypy

And later on modify your mypy.ini configuration file with

[mypy]
plugins = loguru_mypy

That is all, your code is now ready to be linted.

What is included?

loguru-mypy is obviously a mypy plugin that allows to avoid some of those little runtime trickeries :). Here is a short attempt to list some of those:

Lazy loggers

logger.opt(lazy=True) in facts returns a logger that we call lazy. Lazy loggers accept only typing.Callable[[], t.Any] in place of positional or named arguments. Passing a callable that accepts even a single argument thus results in runtime error. loguru-mypy detects that fact and lets you know before your runtime reaches that portion of a code.