[`flake8-tidy-imports`] add documentation for `banned-api` (#2819)

This commit is contained in:
Simon Brugman 2023-02-12 19:09:39 +01:00 committed by GitHub
parent fc465cc2af
commit 02897a141b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 39 additions and 1 deletions

View File

@ -1280,7 +1280,7 @@ For more, see [flake8-tidy-imports](https://pypi.org/project/flake8-tidy-imports
| Code | Name | Message | Fix |
| ---- | ---- | ------- | --- |
| TID251 | banned-api | `{name}` is banned: {message} | |
| TID251 | [banned-api](https://github.com/charliermarsh/ruff/blob/main/docs/rules/banned-api.md) | `{name}` is banned: {message} | |
| TID252 | [relative-imports](https://github.com/charliermarsh/ruff/blob/main/docs/rules/relative-imports.md) | Relative imports from parent modules are banned | 🛠 |
### flake8-type-checking (TCH)

View File

@ -20,6 +20,23 @@ pub struct ApiBan {
}
define_violation!(
/// ## What it does
/// Checks for banned imports.
///
/// ## Why is this bad?
/// Projects may want to ensure that specific modules or module members are
/// not be imported or accessed.
///
/// Security or other company policies may be a reason to impose
/// restrictions on importing external Python libraries. In some cases,
/// projects may adopt conventions around the use of certain modules or
/// module members that are not enforceable by the language itself.
///
/// This rule enforces certain import conventions project-wide in an
/// automatic way.
///
/// ## Options
/// * `flake8-tidy-imports.banned-api`
pub struct BannedApi {
pub name: String,
pub message: String,

21
docs/rules/banned-api.md Normal file
View File

@ -0,0 +1,21 @@
# banned-api (TID251)
Derived from the **flake8-tidy-imports** linter.
## What it does
Checks for banned imports.
## Why is this bad?
Projects may want to ensure that specific modules or module members are
not be imported or accessed.
Security or other company policies may be a reason to impose
restrictions on importing external Python libraries. In some cases,
projects may adopt conventions around the use of certain modules or
module members that are not enforceable by the language itself.
This rule enforces certain import conventions project-wide in an
automatic way.
## Options
* `flake8-tidy-imports.banned-api`