Something error in loguru stub file
See original GitHub issueloguru.Logger
is imported as _Logger
, Logger
class cannot accessed from loguru
top level module actually.
This will cause static type checking failed or ImportError
like "loguru.Logger" is incompatible with "loguru._logger.Logger"
Issue Analytics
- State:
- Created 2 years ago
- Comments:11 (4 by maintainers)
Top Results From Across the Web
loguru Documentation - Read the Docs
Have you ever seen your program crashing unexpectedly without seeing anything in the log file? Did you ever notice that.
Read more >Logger - loguru documentation - Read the Docs
The Logger is the core object of loguru , every logging configuration and usage ... Anything with a .write() method is considered as...
Read more >Python Logging: A Stroll Through the Source Code
In this step-by-step tutorial, you'll learn about how the Python logging package is designed from an OOP perspective. You'll walk line by line...
Read more >How can I patch / mock logging.getlogger() - Stack Overflow
You can use patch.object() on the actual logging object. that lets you verify that you're using the correct logger too: logger = logging....
Read more >pymongo.errors.ServerSelectionTimeoutError with atlas even ...
Hello, I have been using pymongo with atlas for a while now, and suddenly around two hours ago, I must have done something...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Add
safe_getattr
whenAttributeError
toget_type_hints
could be fine. I will make a pull request to sphinx and close this later.About
Sphinx autodoc
:autodoc
do not check the annotation in module level function: https://github.com/sphinx-doc/sphinx/blob/f59026865a8c658acbc6d5690c146f4be0851854/sphinx/ext/autodoc/__init__.py#L1313-L1318but checks the annotation for module level data using
typing.get_type_hints
: https://github.com/sphinx-doc/sphinx/blob/f59026865a8c658acbc6d5690c146f4be0851854/sphinx/ext/autodoc/__init__.py#L1981-L2005and i find a monkey patch:
Solution
both
static type checking
andsphinx autodoc
report 0 errors!Explain:
NameError
caused by evalForwardRef
"loguru.Logger"
not work and raiseAttributeError
instead ofNameError
when evaltyping.TYPE_CHECKING
to keep the static type checking working