mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-28 04:45:01 +00:00

Add two [flake8-pyi](https://github.com/PyCQA/flake8-pyi) rules (Y007, Y008). ref: #848 The specifications are described in [PEP 484 - Version and platform checking](https://peps.python.org/pep-0484/#version-and-platform-checking) The original implementation in flake8-pyi is shown below. - Implemention:66f28a4407/pyi.py (L1429-L1443)
- Tests:66f28a4407/tests/sysplatform.pyi
733 B
733 B
unrecognized-platform-name (PYI008)
Derived from the flake8-pyi linter.
What it does
Check for unrecognized platform names in sys.platform
checks.
Note: this rule is only enabled in .pyi
stub files.
Why is this bad?
If a sys.platform
check compares to a platform name outside of a
small set of known platforms (e.g. "linux", "win32", etc.), it's likely
a typo or a platform name that is not recognized by type checkers.
The list of known platforms is: "linux", "win32", "cygwin", "darwin".
Example
if sys.platform == "linus":
...
Use instead:
if sys.platform == "linux":
...