mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-04 02:39:12 +00:00
flake8-pyi PYI006 bad version info comparison (#3291)
Implement PYI006 "bad version info comparison" ## What it does Ensures that you only `<` and `>=` for version info comparisons with `sys.version_info` in `.pyi` files. All other comparisons such as `<`, `<=` and `==` are banned. ## Why is this bad? ```python >>> import sys >>> print(sys.version_info) sys.version_info(major=3, minor=8, micro=10, releaselevel='final', serial=0) >>> print(sys.version_info > (3, 8)) True >>> print(sys.version_info == (3, 8)) False >>> print(sys.version_info <= (3, 8)) False >>> print(sys.version_info in (3, 8)) False ``` Co-authored-by: Charlie Marsh <charlie.r.marsh@gmail.com>
This commit is contained in:
parent
a032b66c2e
commit
2168404fc2
12 changed files with 216 additions and 2 deletions
|
@ -3,11 +3,15 @@ import argparse
|
|||
import re
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
from pathlib import Path
|
||||
from typing import NamedTuple
|
||||
|
||||
import yaml
|
||||
|
||||
if sys.version_info < (3, 9):
|
||||
raise RuntimeError("You need at least python 3.9 to run this script")
|
||||
|
||||
|
||||
class Section(NamedTuple):
|
||||
"""A section to include in the MkDocs documentation."""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue