mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-03 18:28:24 +00:00
Add documentation for eradicate, flake8-import-conventions, and flake8-no-pep420 (#2652)
This commit is contained in:
parent
8261d0656e
commit
4c35feaa18
15 changed files with 195 additions and 84 deletions
16
docs/rules/commented-out-code.md
Normal file
16
docs/rules/commented-out-code.md
Normal file
|
@ -0,0 +1,16 @@
|
|||
# commented-out-code (ERA001)
|
||||
|
||||
Derived from the **eradicate** linter.
|
||||
|
||||
Autofix is always available.
|
||||
|
||||
### What it does
|
||||
Checks for commented-out Python code.
|
||||
|
||||
### Why is this bad?
|
||||
Commented-out code is dead code, and is often included inadvertently.
|
||||
It should be removed.
|
||||
|
||||
### Example
|
||||
```python
|
||||
```
|
21
docs/rules/implicit-namespace-package.md
Normal file
21
docs/rules/implicit-namespace-package.md
Normal file
|
@ -0,0 +1,21 @@
|
|||
# implicit-namespace-package (INP001)
|
||||
|
||||
Derived from the **flake8-no-pep420** linter.
|
||||
|
||||
### What it does
|
||||
Checks for packages that are missing an `__init__.py` file.
|
||||
|
||||
### Why is this bad?
|
||||
Python packages are directories that contain a file named `__init__.py`.
|
||||
The existence of this file indicates that the directory is a Python
|
||||
package, and so it can be imported the same way a module can be
|
||||
imported.
|
||||
|
||||
Directories that lack an `__init__.py` file can still be imported, but
|
||||
they're indicative of a special kind of package, known as a namespace
|
||||
package (see: [PEP 420](https://www.python.org/dev/peps/pep-0420/)).
|
||||
|
||||
Namespace packages are a relatively new feature of Python, and they're
|
||||
not widely used. So a package that lacks an `__init__.py` file is
|
||||
typically meant to be a regular package, and the absence of the
|
||||
`__init__.py` file is probably an oversight.
|
25
docs/rules/unconventional-import-alias.md
Normal file
25
docs/rules/unconventional-import-alias.md
Normal file
|
@ -0,0 +1,25 @@
|
|||
# unconventional-import-alias (ICN001)
|
||||
|
||||
Derived from the **flake8-import-conventions** linter.
|
||||
|
||||
### What it does
|
||||
Checks for imports that are typically imported using a common convention,
|
||||
like `import pandas as pd`, and enforces that convention.
|
||||
|
||||
### Why is this bad?
|
||||
Consistency is good. Use a common convention for imports to make your code
|
||||
more readable and idiomatic.
|
||||
|
||||
For example, `import pandas as pd` is a common
|
||||
convention for importing the `pandas` library, and users typically expect
|
||||
Pandas to be aliased as `pd`.
|
||||
|
||||
### Example
|
||||
```python
|
||||
import pandas
|
||||
```
|
||||
|
||||
Use instead:
|
||||
```python
|
||||
import pandas as pd
|
||||
```
|
Loading…
Add table
Add a link
Reference in a new issue