astral-sh / ruff

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

False-positive for `N811` for full-caps, but non-constant imports #11862

Open L4rryFisherman opened 4 months ago

L4rryFisherman commented 4 months ago

The line:

from uuid import UUID as UUIDType

flags as N811, whereas UUID is a class and not a constant.

Command used:

> ruff check
file.py:1:18: N811 Constant `UUID` imported as non-constant `UUIDType`

Ruff version: 0.4.8

zawsq commented 4 months ago

Ruff doesn't check type, it only check if it's caps. Just mark it with noqa

mmarras commented 1 month ago

same false positive here:

from django.db.models import Q as Query

imho N811 should not be applied to single character "names", as naming conventions for single character names are ambigous anyways and in this particular case no one can say by just looking at the name if it is a constant or a class. Q here is a class, yet the above is flaged with N811, taking Q for a constant.

Maybe it would also be good to use no single character names for variables or classes, but that's another topic.