Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
818582fe8a | ||
|
|
90574c1088 | ||
|
|
3061a35e7c | ||
|
|
87681697ae | ||
|
|
e9ec2a7b36 | ||
|
|
b0bb75dc1c | ||
|
|
ebca5c2df8 |
@@ -1,6 +1,6 @@
|
||||
repos:
|
||||
- repo: https://github.com/charliermarsh/ruff-pre-commit
|
||||
rev: v0.0.201
|
||||
rev: v0.0.202
|
||||
hooks:
|
||||
- id: ruff
|
||||
|
||||
|
||||
@@ -66,11 +66,13 @@ understand how other, similar rules are implemented.
|
||||
To add a test fixture, create a file under `resources/test/fixtures`, named to match the `CheckCode`
|
||||
you defined earlier (e.g., `E402.py`). This file should contain a variety of violations and
|
||||
non-violations designed to evaluate and demonstrate the behavior of your lint rule. Run Ruff locally
|
||||
with (e.g.) `cargo run resources/test/fixtures/E402.py --no-cache`. Once you're satisfied with the
|
||||
with (e.g.) `cargo run resources/test/fixtures/E402.py --no-cache --select E402`. Once you're satisfied with the
|
||||
output, codify the behavior as a snapshot test by adding a new `testcase` macro to the `mod tests`
|
||||
section of `src/linter.rs`, like so:
|
||||
|
||||
```rust
|
||||
use test_case::test_case;
|
||||
|
||||
#[test_case(CheckCode::A001, Path::new("A001.py"); "A001")]
|
||||
...
|
||||
```
|
||||
|
||||
8
Cargo.lock
generated
8
Cargo.lock
generated
@@ -750,7 +750,7 @@ checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80"
|
||||
|
||||
[[package]]
|
||||
name = "flake8-to-ruff"
|
||||
version = "0.0.201-dev.0"
|
||||
version = "0.0.202-dev.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"clap 4.0.32",
|
||||
@@ -1878,7 +1878,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ruff"
|
||||
version = "0.0.201"
|
||||
version = "0.0.202"
|
||||
dependencies = [
|
||||
"annotate-snippets 0.9.1",
|
||||
"anyhow",
|
||||
@@ -1946,7 +1946,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ruff_dev"
|
||||
version = "0.0.201"
|
||||
version = "0.0.202"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"clap 4.0.32",
|
||||
@@ -1967,7 +1967,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ruff_macros"
|
||||
version = "0.0.201"
|
||||
version = "0.0.202"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
|
||||
@@ -6,7 +6,7 @@ members = [
|
||||
|
||||
[package]
|
||||
name = "ruff"
|
||||
version = "0.0.201"
|
||||
version = "0.0.202"
|
||||
authors = ["Charlie Marsh <charlie.r.marsh@gmail.com>"]
|
||||
edition = "2021"
|
||||
rust-version = "1.65.0"
|
||||
@@ -51,7 +51,7 @@ path-absolutize = { version = "3.0.14", features = ["once_cell_cache", "use_unix
|
||||
quick-junit = { version = "0.3.2" }
|
||||
regex = { version = "1.6.0" }
|
||||
ropey = { version = "1.5.0", features = ["cr_lines", "simd"], default-features = false }
|
||||
ruff_macros = { version = "0.0.201", path = "ruff_macros" }
|
||||
ruff_macros = { version = "0.0.202", path = "ruff_macros" }
|
||||
rustc-hash = { version = "1.1.0" }
|
||||
rustpython-ast = { features = ["unparse"], git = "https://github.com/RustPython/RustPython.git", rev = "68d26955b3e24198a150315e7959719b03709dee" }
|
||||
rustpython-common = { git = "https://github.com/RustPython/RustPython.git", rev = "68d26955b3e24198a150315e7959719b03709dee" }
|
||||
|
||||
10
README.md
10
README.md
@@ -169,7 +169,7 @@ Ruff also works with [pre-commit](https://pre-commit.com):
|
||||
```yaml
|
||||
- repo: https://github.com/charliermarsh/ruff-pre-commit
|
||||
# Ruff version.
|
||||
rev: 'v0.0.201'
|
||||
rev: 'v0.0.202'
|
||||
hooks:
|
||||
- id: ruff
|
||||
# Respect `exclude` and `extend-exclude` settings.
|
||||
@@ -330,11 +330,11 @@ Options:
|
||||
-n, --no-cache
|
||||
Disable cache reads
|
||||
--select <SELECT>
|
||||
List of error codes to enable
|
||||
Comma-separated list of error codes to enable (or ALL, to enable all checks)
|
||||
--extend-select <EXTEND_SELECT>
|
||||
Like --select, but adds additional error codes on top of the selected ones
|
||||
--ignore <IGNORE>
|
||||
List of error codes to ignore
|
||||
Comma-separated list of error codes to disable
|
||||
--extend-ignore <EXTEND_IGNORE>
|
||||
Like --ignore, but adds additional error codes on top of the ignored ones
|
||||
--exclude <EXCLUDE>
|
||||
@@ -362,7 +362,7 @@ Options:
|
||||
--show-settings
|
||||
See the settings Ruff will use to check a given Python file
|
||||
--add-noqa
|
||||
Enable automatic additions of noqa directives to failing lines
|
||||
Enable automatic additions of `noqa` directives to failing lines
|
||||
--dummy-variable-rgx <DUMMY_VARIABLE_RGX>
|
||||
Regular expression matching the name of dummy variables
|
||||
--target-version <TARGET_VERSION>
|
||||
@@ -370,7 +370,7 @@ Options:
|
||||
--line-length <LINE_LENGTH>
|
||||
Set the line-length for length-associated checks and automatic formatting
|
||||
--max-complexity <MAX_COMPLEXITY>
|
||||
Max McCabe complexity allowed for a function
|
||||
Maximum McCabe complexity allowed for a given function
|
||||
--stdin-filename <STDIN_FILENAME>
|
||||
The name of the file when passing it through stdin
|
||||
--explain <EXPLAIN>
|
||||
|
||||
4
flake8_to_ruff/Cargo.lock
generated
4
flake8_to_ruff/Cargo.lock
generated
@@ -771,7 +771,7 @@ checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80"
|
||||
|
||||
[[package]]
|
||||
name = "flake8_to_ruff"
|
||||
version = "0.0.201"
|
||||
version = "0.0.202"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"clap",
|
||||
@@ -1975,7 +1975,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ruff"
|
||||
version = "0.0.201"
|
||||
version = "0.0.202"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"bincode",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "flake8-to-ruff"
|
||||
version = "0.0.201-dev.0"
|
||||
version = "0.0.202-dev.0"
|
||||
edition = "2021"
|
||||
|
||||
[lib]
|
||||
|
||||
@@ -98,7 +98,11 @@ export default function Editor() {
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<main className={"h-full w-full flex flex-auto"}>
|
||||
<main
|
||||
className={
|
||||
"h-full w-full flex flex-auto bg-ayu-background dark:bg-ayu-background-dark"
|
||||
}
|
||||
>
|
||||
<Header
|
||||
edit={edit}
|
||||
tab={tab}
|
||||
|
||||
@@ -44,8 +44,6 @@ export default function Header({
|
||||
"border-b",
|
||||
"border-gray-200",
|
||||
"dark:border-gray-800",
|
||||
"bg-ayu-background",
|
||||
"dark:bg-ayu-background-dark",
|
||||
)}
|
||||
>
|
||||
<div className="flex space-x-5">
|
||||
|
||||
@@ -1095,9 +1095,6 @@
|
||||
},
|
||||
"Flake8TidyImportsOptions": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"banned-api"
|
||||
],
|
||||
"properties": {
|
||||
"ban-relative-imports": {
|
||||
"description": "Whether to ban all relative imports (`\"all\"`), or only those imports that extend into the parent module or beyond (`\"parents\"`).",
|
||||
@@ -1112,7 +1109,10 @@
|
||||
},
|
||||
"banned-api": {
|
||||
"description": "Specific modules or module members that may not be imported or accessed. Note that this check is only meant to flag accidental uses, and can be circumvented via `eval` or `importlib`.",
|
||||
"type": "object",
|
||||
"type": [
|
||||
"object",
|
||||
"null"
|
||||
],
|
||||
"additionalProperties": {
|
||||
"$ref": "#/definitions/BannedApi"
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "ruff_dev"
|
||||
version = "0.0.201"
|
||||
version = "0.0.202"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "ruff_macros"
|
||||
version = "0.0.201"
|
||||
version = "0.0.202"
|
||||
edition = "2021"
|
||||
|
||||
[lib]
|
||||
|
||||
@@ -397,10 +397,9 @@ where
|
||||
..
|
||||
} => {
|
||||
if self.settings.enabled.contains(&CheckCode::E743) {
|
||||
if let Some(check) = pycodestyle::checks::ambiguous_function_name(
|
||||
name,
|
||||
Range::from_located(stmt),
|
||||
) {
|
||||
if let Some(check) = pycodestyle::checks::ambiguous_function_name(name, || {
|
||||
helpers::identifier_range(stmt, self.locator)
|
||||
}) {
|
||||
self.add_check(check);
|
||||
}
|
||||
}
|
||||
@@ -585,9 +584,9 @@ where
|
||||
}
|
||||
|
||||
if self.settings.enabled.contains(&CheckCode::E742) {
|
||||
if let Some(check) =
|
||||
pycodestyle::checks::ambiguous_class_name(name, Range::from_located(stmt))
|
||||
{
|
||||
if let Some(check) = pycodestyle::checks::ambiguous_class_name(name, || {
|
||||
helpers::identifier_range(stmt, self.locator)
|
||||
}) {
|
||||
self.add_check(check);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,14 +57,15 @@ pub struct Cli {
|
||||
/// Disable cache reads.
|
||||
#[arg(short, long)]
|
||||
pub no_cache: bool,
|
||||
/// List of error codes to enable.
|
||||
/// Comma-separated list of error codes to enable (or ALL, to enable all
|
||||
/// checks).
|
||||
#[arg(long, value_delimiter = ',')]
|
||||
pub select: Option<Vec<CheckCodePrefix>>,
|
||||
/// Like --select, but adds additional error codes on top of the selected
|
||||
/// ones.
|
||||
#[arg(long, value_delimiter = ',')]
|
||||
pub extend_select: Option<Vec<CheckCodePrefix>>,
|
||||
/// List of error codes to ignore.
|
||||
/// Comma-separated list of error codes to disable.
|
||||
#[arg(long, value_delimiter = ',')]
|
||||
pub ignore: Option<Vec<CheckCodePrefix>>,
|
||||
/// Like --ignore, but adds additional error codes on top of the ignored
|
||||
@@ -120,7 +121,7 @@ pub struct Cli {
|
||||
/// See the settings Ruff will use to check a given Python file.
|
||||
#[arg(long)]
|
||||
pub show_settings: bool,
|
||||
/// Enable automatic additions of noqa directives to failing lines.
|
||||
/// Enable automatic additions of `noqa` directives to failing lines.
|
||||
#[arg(long)]
|
||||
pub add_noqa: bool,
|
||||
/// Regular expression matching the name of dummy variables.
|
||||
@@ -133,7 +134,7 @@ pub struct Cli {
|
||||
/// formatting.
|
||||
#[arg(long)]
|
||||
pub line_length: Option<usize>,
|
||||
/// Max McCabe complexity allowed for a function.
|
||||
/// Maximum McCabe complexity allowed for a given function.
|
||||
#[arg(long)]
|
||||
pub max_complexity: Option<usize>,
|
||||
/// Round-trip auto-formatting.
|
||||
|
||||
@@ -3,7 +3,7 @@ use rustpython_ast::{Constant, Expr, ExprKind, Stmt, StmtKind};
|
||||
|
||||
use crate::ast::types::Range;
|
||||
use crate::ast::visitor::Visitor;
|
||||
use crate::ast::{cast, visitor};
|
||||
use crate::ast::{cast, helpers, visitor};
|
||||
use crate::checkers::ast::Checker;
|
||||
use crate::checks::{CheckCode, CheckKind};
|
||||
use crate::docstrings::definition::{Definition, DefinitionKind};
|
||||
@@ -167,7 +167,7 @@ pub fn definition(checker: &mut Checker, definition: &Definition, visibility: &V
|
||||
if checker.settings.enabled.contains(&CheckCode::ANN201) {
|
||||
checker.add_check(Check::new(
|
||||
CheckKind::MissingReturnTypePublicFunction(name.to_string()),
|
||||
Range::from_located(stmt),
|
||||
helpers::identifier_range(stmt, checker.locator),
|
||||
));
|
||||
}
|
||||
}
|
||||
@@ -175,7 +175,7 @@ pub fn definition(checker: &mut Checker, definition: &Definition, visibility: &V
|
||||
if checker.settings.enabled.contains(&CheckCode::ANN202) {
|
||||
checker.add_check(Check::new(
|
||||
CheckKind::MissingReturnTypePrivateFunction(name.to_string()),
|
||||
Range::from_located(stmt),
|
||||
helpers::identifier_range(stmt, checker.locator),
|
||||
));
|
||||
}
|
||||
}
|
||||
@@ -309,14 +309,14 @@ pub fn definition(checker: &mut Checker, definition: &Definition, visibility: &V
|
||||
if checker.settings.enabled.contains(&CheckCode::ANN206) {
|
||||
checker.add_check(Check::new(
|
||||
CheckKind::MissingReturnTypeClassMethod(name.to_string()),
|
||||
Range::from_located(stmt),
|
||||
helpers::identifier_range(stmt, checker.locator),
|
||||
));
|
||||
}
|
||||
} else if visibility::is_staticmethod(checker, cast::decorator_list(stmt)) {
|
||||
if checker.settings.enabled.contains(&CheckCode::ANN205) {
|
||||
checker.add_check(Check::new(
|
||||
CheckKind::MissingReturnTypeStaticMethod(name.to_string()),
|
||||
Range::from_located(stmt),
|
||||
helpers::identifier_range(stmt, checker.locator),
|
||||
));
|
||||
}
|
||||
} else if visibility::is_init(stmt) {
|
||||
@@ -328,7 +328,7 @@ pub fn definition(checker: &mut Checker, definition: &Definition, visibility: &V
|
||||
{
|
||||
let mut check = Check::new(
|
||||
CheckKind::MissingReturnTypeSpecialMethod(name.to_string()),
|
||||
Range::from_located(stmt),
|
||||
helpers::identifier_range(stmt, checker.locator),
|
||||
);
|
||||
if checker.patch(check.kind.code()) {
|
||||
match fixes::add_return_none_annotation(checker.locator, stmt) {
|
||||
@@ -343,7 +343,7 @@ pub fn definition(checker: &mut Checker, definition: &Definition, visibility: &V
|
||||
if checker.settings.enabled.contains(&CheckCode::ANN204) {
|
||||
checker.add_check(Check::new(
|
||||
CheckKind::MissingReturnTypeSpecialMethod(name.to_string()),
|
||||
Range::from_located(stmt),
|
||||
helpers::identifier_range(stmt, checker.locator),
|
||||
));
|
||||
}
|
||||
} else {
|
||||
@@ -352,7 +352,7 @@ pub fn definition(checker: &mut Checker, definition: &Definition, visibility: &V
|
||||
if checker.settings.enabled.contains(&CheckCode::ANN201) {
|
||||
checker.add_check(Check::new(
|
||||
CheckKind::MissingReturnTypePublicFunction(name.to_string()),
|
||||
Range::from_located(stmt),
|
||||
helpers::identifier_range(stmt, checker.locator),
|
||||
));
|
||||
}
|
||||
}
|
||||
@@ -360,7 +360,7 @@ pub fn definition(checker: &mut Checker, definition: &Definition, visibility: &V
|
||||
if checker.settings.enabled.contains(&CheckCode::ANN202) {
|
||||
checker.add_check(Check::new(
|
||||
CheckKind::MissingReturnTypePrivateFunction(name.to_string()),
|
||||
Range::from_located(stmt),
|
||||
helpers::identifier_range(stmt, checker.locator),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,9 +6,9 @@ expression: checks
|
||||
MissingReturnTypePublicFunction: bar
|
||||
location:
|
||||
row: 29
|
||||
column: 4
|
||||
column: 8
|
||||
end_location:
|
||||
row: 30
|
||||
column: 16
|
||||
row: 29
|
||||
column: 11
|
||||
fix: ~
|
||||
|
||||
|
||||
@@ -6,10 +6,10 @@ expression: checks
|
||||
MissingReturnTypePublicFunction: foo
|
||||
location:
|
||||
row: 4
|
||||
column: 0
|
||||
column: 4
|
||||
end_location:
|
||||
row: 5
|
||||
column: 8
|
||||
row: 4
|
||||
column: 7
|
||||
fix: ~
|
||||
- kind:
|
||||
MissingTypeFunctionArgument: a
|
||||
@@ -33,10 +33,10 @@ expression: checks
|
||||
MissingReturnTypePublicFunction: foo
|
||||
location:
|
||||
row: 9
|
||||
column: 0
|
||||
column: 4
|
||||
end_location:
|
||||
row: 10
|
||||
column: 8
|
||||
row: 9
|
||||
column: 7
|
||||
fix: ~
|
||||
- kind:
|
||||
MissingTypeFunctionArgument: b
|
||||
@@ -60,19 +60,19 @@ expression: checks
|
||||
MissingReturnTypePublicFunction: foo
|
||||
location:
|
||||
row: 19
|
||||
column: 0
|
||||
column: 4
|
||||
end_location:
|
||||
row: 20
|
||||
column: 8
|
||||
row: 19
|
||||
column: 7
|
||||
fix: ~
|
||||
- kind:
|
||||
MissingReturnTypePublicFunction: foo
|
||||
location:
|
||||
row: 24
|
||||
column: 0
|
||||
column: 4
|
||||
end_location:
|
||||
row: 25
|
||||
column: 8
|
||||
row: 24
|
||||
column: 7
|
||||
fix: ~
|
||||
- kind:
|
||||
DynamicallyTypedExpression: a
|
||||
|
||||
@@ -6,10 +6,10 @@ expression: checks
|
||||
MissingReturnTypeSpecialMethod: __init__
|
||||
location:
|
||||
row: 5
|
||||
column: 4
|
||||
column: 8
|
||||
end_location:
|
||||
row: 6
|
||||
column: 11
|
||||
row: 5
|
||||
column: 16
|
||||
fix:
|
||||
content: " -> None"
|
||||
location:
|
||||
@@ -22,10 +22,10 @@ expression: checks
|
||||
MissingReturnTypeSpecialMethod: __init__
|
||||
location:
|
||||
row: 11
|
||||
column: 4
|
||||
column: 8
|
||||
end_location:
|
||||
row: 12
|
||||
column: 11
|
||||
row: 11
|
||||
column: 16
|
||||
fix:
|
||||
content: " -> None"
|
||||
location:
|
||||
@@ -38,9 +38,9 @@ expression: checks
|
||||
MissingReturnTypePrivateFunction: __init__
|
||||
location:
|
||||
row: 40
|
||||
column: 0
|
||||
column: 4
|
||||
end_location:
|
||||
row: 41
|
||||
column: 7
|
||||
row: 40
|
||||
column: 12
|
||||
fix: ~
|
||||
|
||||
|
||||
@@ -6,18 +6,18 @@ expression: checks
|
||||
MissingReturnTypePublicFunction: foo
|
||||
location:
|
||||
row: 45
|
||||
column: 0
|
||||
column: 4
|
||||
end_location:
|
||||
row: 46
|
||||
column: 15
|
||||
row: 45
|
||||
column: 7
|
||||
fix: ~
|
||||
- kind:
|
||||
MissingReturnTypePublicFunction: foo
|
||||
location:
|
||||
row: 50
|
||||
column: 0
|
||||
column: 4
|
||||
end_location:
|
||||
row: 55
|
||||
column: 14
|
||||
row: 50
|
||||
column: 7
|
||||
fix: ~
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use rustpython_ast::{ExprKind, Stmt, StmtKind};
|
||||
|
||||
use crate::ast::types::Range;
|
||||
use crate::ast::helpers;
|
||||
use crate::checkers::ast::Checker;
|
||||
use crate::checks::{Check, CheckKind};
|
||||
|
||||
@@ -17,6 +17,6 @@ pub fn f_string_docstring(checker: &mut Checker, body: &[Stmt]) {
|
||||
};
|
||||
checker.add_check(Check::new(
|
||||
CheckKind::FStringDocstring,
|
||||
Range::from_located(stmt),
|
||||
helpers::identifier_range(stmt, checker.locator),
|
||||
));
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ pub struct Options {
|
||||
/// Specific modules or module members that may not be imported or accessed.
|
||||
/// Note that this check is only meant to flag accidental uses,
|
||||
/// and can be circumvented via `eval` or `importlib`.
|
||||
pub banned_api: FxHashMap<String, BannedApi>,
|
||||
pub banned_api: Option<FxHashMap<String, BannedApi>>,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
@@ -78,7 +78,7 @@ impl From<Options> for Settings {
|
||||
fn from(options: Options) -> Self {
|
||||
Self {
|
||||
ban_relative_imports: options.ban_relative_imports.unwrap_or(Strictness::Parents),
|
||||
banned_api: options.banned_api,
|
||||
banned_api: options.banned_api.unwrap_or_default(),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -87,7 +87,7 @@ impl From<Settings> for Options {
|
||||
fn from(settings: Settings) -> Self {
|
||||
Self {
|
||||
ban_relative_imports: Some(settings.ban_relative_imports),
|
||||
banned_api: settings.banned_api,
|
||||
banned_api: Some(settings.banned_api),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -118,11 +118,14 @@ pub fn ambiguous_variable_name<T>(name: &str, located: &Located<T>) -> Option<Ch
|
||||
}
|
||||
|
||||
/// E742
|
||||
pub fn ambiguous_class_name(name: &str, location: Range) -> Option<Check> {
|
||||
pub fn ambiguous_class_name<F>(name: &str, locate: F) -> Option<Check>
|
||||
where
|
||||
F: FnOnce() -> Range,
|
||||
{
|
||||
if is_ambiguous_name(name) {
|
||||
Some(Check::new(
|
||||
CheckKind::AmbiguousClassName(name.to_string()),
|
||||
location,
|
||||
locate(),
|
||||
))
|
||||
} else {
|
||||
None
|
||||
@@ -130,11 +133,14 @@ pub fn ambiguous_class_name(name: &str, location: Range) -> Option<Check> {
|
||||
}
|
||||
|
||||
/// E743
|
||||
pub fn ambiguous_function_name(name: &str, location: Range) -> Option<Check> {
|
||||
pub fn ambiguous_function_name<F>(name: &str, locate: F) -> Option<Check>
|
||||
where
|
||||
F: FnOnce() -> Range,
|
||||
{
|
||||
if is_ambiguous_name(name) {
|
||||
Some(Check::new(
|
||||
CheckKind::AmbiguousFunctionName(name.to_string()),
|
||||
location,
|
||||
locate(),
|
||||
))
|
||||
} else {
|
||||
None
|
||||
|
||||
@@ -6,27 +6,27 @@ expression: checks
|
||||
AmbiguousClassName: l
|
||||
location:
|
||||
row: 1
|
||||
column: 0
|
||||
column: 6
|
||||
end_location:
|
||||
row: 2
|
||||
column: 8
|
||||
row: 1
|
||||
column: 7
|
||||
fix: ~
|
||||
- kind:
|
||||
AmbiguousClassName: I
|
||||
location:
|
||||
row: 5
|
||||
column: 0
|
||||
column: 6
|
||||
end_location:
|
||||
row: 6
|
||||
column: 8
|
||||
row: 5
|
||||
column: 7
|
||||
fix: ~
|
||||
- kind:
|
||||
AmbiguousClassName: O
|
||||
location:
|
||||
row: 9
|
||||
column: 0
|
||||
column: 6
|
||||
end_location:
|
||||
row: 10
|
||||
column: 8
|
||||
row: 9
|
||||
column: 7
|
||||
fix: ~
|
||||
|
||||
|
||||
@@ -6,27 +6,27 @@ expression: checks
|
||||
AmbiguousFunctionName: l
|
||||
location:
|
||||
row: 1
|
||||
column: 0
|
||||
column: 4
|
||||
end_location:
|
||||
row: 2
|
||||
column: 8
|
||||
row: 1
|
||||
column: 5
|
||||
fix: ~
|
||||
- kind:
|
||||
AmbiguousFunctionName: I
|
||||
location:
|
||||
row: 5
|
||||
column: 0
|
||||
column: 4
|
||||
end_location:
|
||||
row: 6
|
||||
column: 8
|
||||
row: 5
|
||||
column: 5
|
||||
fix: ~
|
||||
- kind:
|
||||
AmbiguousFunctionName: O
|
||||
location:
|
||||
row: 10
|
||||
column: 4
|
||||
column: 8
|
||||
end_location:
|
||||
row: 11
|
||||
column: 12
|
||||
row: 10
|
||||
column: 9
|
||||
fix: ~
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ use regex::Regex;
|
||||
use rustc_hash::FxHashSet;
|
||||
use rustpython_ast::{Location, StmtKind};
|
||||
|
||||
use crate::ast::helpers::identifier_range;
|
||||
use crate::ast::types::Range;
|
||||
use crate::ast::whitespace::LinesWithTrailingNewline;
|
||||
use crate::ast::{cast, whitespace};
|
||||
@@ -57,7 +58,7 @@ pub fn not_missing(
|
||||
if checker.settings.enabled.contains(&CheckCode::D101) {
|
||||
checker.add_check(Check::new(
|
||||
CheckKind::PublicClass,
|
||||
Range::from_located(stmt),
|
||||
identifier_range(stmt, checker.locator),
|
||||
));
|
||||
}
|
||||
false
|
||||
@@ -66,7 +67,7 @@ pub fn not_missing(
|
||||
if checker.settings.enabled.contains(&CheckCode::D106) {
|
||||
checker.add_check(Check::new(
|
||||
CheckKind::PublicNestedClass,
|
||||
Range::from_located(stmt),
|
||||
identifier_range(stmt, checker.locator),
|
||||
));
|
||||
}
|
||||
false
|
||||
@@ -78,7 +79,7 @@ pub fn not_missing(
|
||||
if checker.settings.enabled.contains(&CheckCode::D103) {
|
||||
checker.add_check(Check::new(
|
||||
CheckKind::PublicFunction,
|
||||
Range::from_located(stmt),
|
||||
identifier_range(stmt, checker.locator),
|
||||
));
|
||||
}
|
||||
false
|
||||
@@ -93,20 +94,23 @@ pub fn not_missing(
|
||||
if checker.settings.enabled.contains(&CheckCode::D105) {
|
||||
checker.add_check(Check::new(
|
||||
CheckKind::MagicMethod,
|
||||
Range::from_located(stmt),
|
||||
identifier_range(stmt, checker.locator),
|
||||
));
|
||||
}
|
||||
true
|
||||
} else if is_init(stmt) {
|
||||
if checker.settings.enabled.contains(&CheckCode::D107) {
|
||||
checker.add_check(Check::new(CheckKind::PublicInit, Range::from_located(stmt)));
|
||||
checker.add_check(Check::new(
|
||||
CheckKind::PublicInit,
|
||||
identifier_range(stmt, checker.locator),
|
||||
));
|
||||
}
|
||||
true
|
||||
} else {
|
||||
if checker.settings.enabled.contains(&CheckCode::D102) {
|
||||
checker.add_check(Check::new(
|
||||
CheckKind::PublicMethod,
|
||||
Range::from_located(stmt),
|
||||
identifier_range(stmt, checker.locator),
|
||||
));
|
||||
}
|
||||
true
|
||||
@@ -835,7 +839,7 @@ pub fn if_needed(checker: &mut Checker, docstring: &Docstring) {
|
||||
}
|
||||
checker.add_check(Check::new(
|
||||
CheckKind::SkipDocstring,
|
||||
Range::from_located(stmt),
|
||||
identifier_range(stmt, checker.locator),
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
@@ -5,9 +5,9 @@ expression: checks
|
||||
- kind: PublicClass
|
||||
location:
|
||||
row: 15
|
||||
column: 0
|
||||
column: 6
|
||||
end_location:
|
||||
row: 69
|
||||
row: 15
|
||||
column: 12
|
||||
fix: ~
|
||||
|
||||
|
||||
@@ -5,25 +5,25 @@ expression: checks
|
||||
- kind: PublicMethod
|
||||
location:
|
||||
row: 23
|
||||
column: 4
|
||||
column: 8
|
||||
end_location:
|
||||
row: 24
|
||||
column: 12
|
||||
row: 23
|
||||
column: 14
|
||||
fix: ~
|
||||
- kind: PublicMethod
|
||||
location:
|
||||
row: 56
|
||||
column: 4
|
||||
column: 8
|
||||
end_location:
|
||||
row: 57
|
||||
column: 12
|
||||
row: 56
|
||||
column: 15
|
||||
fix: ~
|
||||
- kind: PublicMethod
|
||||
location:
|
||||
row: 68
|
||||
column: 4
|
||||
column: 8
|
||||
end_location:
|
||||
row: 69
|
||||
column: 12
|
||||
row: 68
|
||||
column: 16
|
||||
fix: ~
|
||||
|
||||
|
||||
@@ -5,9 +5,9 @@ expression: checks
|
||||
- kind: PublicFunction
|
||||
location:
|
||||
row: 400
|
||||
column: 0
|
||||
column: 4
|
||||
end_location:
|
||||
row: 400
|
||||
column: 27
|
||||
column: 17
|
||||
fix: ~
|
||||
|
||||
|
||||
@@ -5,9 +5,9 @@ expression: checks
|
||||
- kind: MagicMethod
|
||||
location:
|
||||
row: 64
|
||||
column: 4
|
||||
column: 8
|
||||
end_location:
|
||||
row: 65
|
||||
column: 12
|
||||
row: 64
|
||||
column: 15
|
||||
fix: ~
|
||||
|
||||
|
||||
@@ -5,17 +5,17 @@ expression: checks
|
||||
- kind: PublicInit
|
||||
location:
|
||||
row: 60
|
||||
column: 4
|
||||
column: 8
|
||||
end_location:
|
||||
row: 61
|
||||
column: 12
|
||||
row: 60
|
||||
column: 16
|
||||
fix: ~
|
||||
- kind: PublicInit
|
||||
location:
|
||||
row: 534
|
||||
column: 4
|
||||
column: 8
|
||||
end_location:
|
||||
row: 535
|
||||
column: 12
|
||||
row: 534
|
||||
column: 16
|
||||
fix: ~
|
||||
|
||||
|
||||
@@ -5,25 +5,25 @@ expression: checks
|
||||
- kind: SkipDocstring
|
||||
location:
|
||||
row: 34
|
||||
column: 4
|
||||
column: 8
|
||||
end_location:
|
||||
row: 36
|
||||
column: 11
|
||||
row: 34
|
||||
column: 25
|
||||
fix: ~
|
||||
- kind: SkipDocstring
|
||||
location:
|
||||
row: 90
|
||||
column: 4
|
||||
column: 8
|
||||
end_location:
|
||||
row: 92
|
||||
column: 11
|
||||
row: 90
|
||||
column: 30
|
||||
fix: ~
|
||||
- kind: SkipDocstring
|
||||
location:
|
||||
row: 110
|
||||
column: 0
|
||||
column: 4
|
||||
end_location:
|
||||
row: 112
|
||||
column: 7
|
||||
row: 110
|
||||
column: 19
|
||||
fix: ~
|
||||
|
||||
|
||||
@@ -515,7 +515,7 @@ other-attribute = 1
|
||||
}),
|
||||
flake8_tidy_imports: Some(flake8_tidy_imports::settings::Options {
|
||||
ban_relative_imports: Some(Strictness::Parents),
|
||||
banned_api: FxHashMap::from_iter([
|
||||
banned_api: Some(FxHashMap::from_iter([
|
||||
(
|
||||
"cgi".to_string(),
|
||||
BannedApi {
|
||||
@@ -528,7 +528,7 @@ other-attribute = 1
|
||||
msg: "Use typing_extensions.TypedDict instead.".to_string()
|
||||
}
|
||||
)
|
||||
])
|
||||
]))
|
||||
}),
|
||||
flake8_import_conventions: Some(flake8_import_conventions::settings::Options {
|
||||
aliases: Some(FxHashMap::from_iter([(
|
||||
|
||||
Reference in New Issue
Block a user