mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-03 10:22:24 +00:00
Add flake8-pyi with one rule (#2682)
Add basic scaffold for [flake8-pyi](https://github.com/PyCQA/flake8-pyi) and the first rule, Y001 rel: https://github.com/charliermarsh/ruff/issues/848
This commit is contained in:
parent
233be0e074
commit
67e58a024a
13 changed files with 268 additions and 4 deletions
25
docs/rules/prefix-type-params.md
Normal file
25
docs/rules/prefix-type-params.md
Normal file
|
@ -0,0 +1,25 @@
|
|||
# prefix-type-params (PYI001)
|
||||
|
||||
Derived from the **flake8-pyi** linter.
|
||||
|
||||
### What it does
|
||||
Checks that type `TypeVar`, `ParamSpec`, and `TypeVarTuple` definitions in
|
||||
stubs are prefixed with `_`.
|
||||
|
||||
### Why is this bad?
|
||||
By prefixing type parameters with `_`, we can avoid accidentally exposing
|
||||
names internal to the stub.
|
||||
|
||||
### Example
|
||||
```python
|
||||
from typing import TypeVar
|
||||
|
||||
T = TypeVar("T")
|
||||
```
|
||||
|
||||
Use instead:
|
||||
```python
|
||||
from typing import TypeVar
|
||||
|
||||
_T = TypeVar("_T")
|
||||
```
|
Loading…
Add table
Add a link
Reference in a new issue