astral-sh / ruff

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

bad-version-info-comparison (PYI006) doesn't run in `.py` files #13836

Open Avasam opened 1 week ago

Avasam commented 1 week ago

This rule could've caught an issue in pywin32 (https://github.com/mhammond/pywin32/pull/2416). I think it's a valid rule to enforce on runtime files to prevent incorrect expectations.

MRE:

if sys.version_info > (3, 10):  # PYI006 only shows here in .pyi files
    print("Do something on Python 3.11")

Command: ruff check --select=PYI Version: ruff 0.7.0

AlexWaygood commented 1 week ago

This makes sense to me.