astral-sh / ruff

An extremely fast Python linter and code formatter, written in Rust.
https://docs.astral.sh/ruff
MIT License
31.38k stars 1.05k forks source link

PLE1205 false-positive with Loguru #13390

Open dorschw opened 1 week ago

dorschw commented 1 week ago

In loguru, the formatting isn't %-based, but {}-based, see here. When configuring it as the logger object and writing

logger.info("{}", var)

a false-positive PLE1205 is raised.

MackHalliday commented 1 week ago

I am having this same issue - It's so annoying. Please lmk if you find a workaround.

MichaReiser commented 1 week ago

The PLE1205 for detecting logger's is very basic at the moment. All it does is match on the variable name (this does not apply for logging calls). This is because Ruff has no type inference capabilities (we're working on it) that allow reasoning about how values flow through the program. This means there's no immediate fix here.

I recommend you disable PLE1205 in your project if you're consistently using (ignore = ["PLE1205"]) or ignore it on a per file level: per-file-ignores = { "file.py": ["PLE1205"]}

MackHalliday commented 1 week ago

Thank you for the response :D