-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add rule WPS111 from wemake-python-styleguide
- Loading branch information
Showing
39 changed files
with
725 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
crates/ruff_linter/resources/test/fixtures/wemake_python_styleguide/WPS111.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
from matplotlib import pyplot as p # bad | ||
from matplotlib import pyplot as plt # good | ||
|
||
import numpy as n # bad | ||
import numpy as np # good | ||
|
||
x = 1 # bad | ||
x_coordinate = 1 # good | ||
|
||
y = 2 # bad | ||
abscissa = 2 # good | ||
|
||
z: int = 1 # bad | ||
z_coordinate: int = 1 # good | ||
|
||
c: str | bytes = "drop foo bar" # bad | ||
command: str | bytes = "drop foo bar" # good | ||
|
||
_ = "unused" # good | ||
|
||
|
||
def f(a: int, b): # bad | ||
pass | ||
|
||
|
||
def some_function(arg1: int, arg2): # good | ||
pass | ||
|
||
|
||
class C: # bad | ||
a: int # bad | ||
b = 2 # bad | ||
|
||
def __init__(self, i: str, j): # bad | ||
self.i = i # bad | ||
self.j = j # bad | ||
|
||
|
||
class SomeClass: # good | ||
attr1: int # good | ||
attr2 = 2 # good | ||
|
||
def __init__(self, attr3: str, attr4): # good | ||
self.attr3 = attr3 # good | ||
self.attr4 = attr4 # good | ||
|
||
|
||
match command.split(): | ||
case ["quit" as c]: # bad | ||
pass | ||
case ["go", d]: # bad | ||
pass | ||
case ["drop", *o]: # bad | ||
pass | ||
|
||
|
||
match command.split(): | ||
case ["quit" as cmd]: # good | ||
pass | ||
case ["go", direction]: # good | ||
pass | ||
case ["drop", *objects]: # good | ||
pass |
Empty file.
Empty file.
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
use ruff_python_ast::{Pattern, PatternMatchAs, PatternMatchMapping, PatternMatchStar}; | ||
|
||
use crate::checkers::ast::Checker; | ||
use crate::codes::Rule; | ||
use crate::rules::wemake_python_styleguide; | ||
|
||
/// Run lint rules over a [`Pattern`] syntax node. | ||
pub(crate) fn pattern(pattern: &Pattern, checker: &mut Checker) { | ||
if let Pattern::MatchAs(PatternMatchAs { | ||
name: Some(name), .. | ||
}) | ||
| Pattern::MatchStar(PatternMatchStar { | ||
name: Some(name), | ||
range: _, | ||
}) | ||
| Pattern::MatchMapping(PatternMatchMapping { | ||
rest: Some(name), .. | ||
}) = pattern | ||
{ | ||
if checker.enabled(Rule::TooShortName) { | ||
wemake_python_styleguide::rules::too_short_name(checker, name); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -57,3 +57,4 @@ pub mod pyupgrade; | |
pub mod refurb; | ||
pub mod ruff; | ||
pub mod tryceratops; | ||
pub mod wemake_python_styleguide; |
1 change: 1 addition & 0 deletions
1
crates/ruff_linter/src/rules/wemake_python_styleguide/helpers/mod.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
pub(super) mod naming; |
Oops, something went wrong.