Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

from loguru._handler import StrRecord ImportError: cannot import name 'StrRecord' from 'loguru._handler' (/python3.7/site-packages/loguru/_handler.py) #1103

Open
saba-nazir opened this issue Mar 16, 2024 · 1 comment
Labels
question Further information is requested

Comments

@saba-nazir
Copy link

saba-nazir commented Mar 16, 2024

I am trying to use an older version of loguru i.e. loguru==0.5.3 but getting the following error.

from loguru._handler import StrRecord
ImportError: cannot import name 'StrRecord' from 'loguru._handler' (/DCASE/dcase-2020-baseline-master/dcase_env/lib/python3.7/site-packages/loguru/_handler.py)

Please help.

@Delgan
Copy link
Owner

Delgan commented Mar 30, 2024

Hello.

The StrRecord class is an internal type that should not be imported.

If your intention was to use type hints, you should instead use the Message type to annotate your functions. This type is not defined at run-time, it only exists for type checkers, so make sure to follow the steps explained in the documentation: Type hints.

from __future__ import annotations

import loguru

def my_sink(message: loguru.Message):
    ...

@Delgan Delgan added the question Further information is requested label Mar 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants