Skip to content

Commit

Permalink
Use literal
Browse files Browse the repository at this point in the history
  • Loading branch information
charliermarsh committed Nov 13, 2023
1 parent 4032428 commit 4afdbbc
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ use crate::fix;
/// blocks.
///
/// In [preview], this rule also checks for unnecessary ellipsis (`...`)
/// expressions.
/// literals.
///
/// ## Why is this bad?
/// In Python, the `pass` statement and ellipsis (`...`) expression serve as
/// In Python, the `pass` statement and ellipsis (`...`) literal serve as
/// placeholders, allowing for syntactically correct empty code blocks. The
/// primary purpose of these nodes is to avoid syntax errors in situations
/// where a statement or expression is syntactically required, but no code
Expand All @@ -39,6 +39,19 @@ use crate::fix;
/// """Placeholder docstring."""
/// ```
///
/// In [preview]:
/// ```python
/// def func():
/// """Placeholder docstring."""
/// ...
/// ```
///
/// Use instead:
/// ```python
/// def func():
/// """Placeholder docstring."""
/// ```
///
/// ## References
/// - [Python documentation: The `pass` statement](https://docs.python.org/3/reference/simple_stmts.html#the-pass-statement)
///
Expand All @@ -54,7 +67,7 @@ impl AlwaysFixableViolation for UnnecessaryPlaceholder {
let Self { kind } = self;
match kind {
Placeholder::Pass => format!("Unnecessary `pass` statement"),
Placeholder::Ellipsis => format!("Unnecessary `...` expression"),
Placeholder::Ellipsis => format!("Unnecessary `...` literal"),
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ PIE790.py:150:5: PIE790 [*] Unnecessary `pass` statement
152 151 |
153 152 | def foo():

PIE790.py:155:5: PIE790 [*] Unnecessary `...` expression
PIE790.py:155:5: PIE790 [*] Unnecessary `...` literal
|
153 | def foo():
154 | print("foo")
Expand All @@ -485,7 +485,7 @@ PIE790.py:155:5: PIE790 [*] Unnecessary `...` expression
157 156 |
158 157 | def foo():

PIE790.py:161:5: PIE790 [*] Unnecessary `...` expression
PIE790.py:161:5: PIE790 [*] Unnecessary `...` literal
|
159 | """A docstring."""
160 | print("foo")
Expand All @@ -503,7 +503,7 @@ PIE790.py:161:5: PIE790 [*] Unnecessary `...` expression
163 162 |
164 163 | for i in range(10):

PIE790.py:165:5: PIE790 [*] Unnecessary `...` expression
PIE790.py:165:5: PIE790 [*] Unnecessary `...` literal
|
164 | for i in range(10):
165 | ...
Expand All @@ -521,7 +521,7 @@ PIE790.py:165:5: PIE790 [*] Unnecessary `...` expression
168 167 | for i in range(10):
169 168 | ...

PIE790.py:166:5: PIE790 [*] Unnecessary `...` expression
PIE790.py:166:5: PIE790 [*] Unnecessary `...` literal
|
164 | for i in range(10):
165 | ...
Expand All @@ -541,7 +541,7 @@ PIE790.py:166:5: PIE790 [*] Unnecessary `...` expression
168 167 | for i in range(10):
169 168 | ...

PIE790.py:169:5: PIE790 [*] Unnecessary `...` expression
PIE790.py:169:5: PIE790 [*] Unnecessary `...` literal
|
168 | for i in range(10):
169 | ...
Expand All @@ -560,7 +560,7 @@ PIE790.py:169:5: PIE790 [*] Unnecessary `...` expression
171 170 | ...
172 171 |

PIE790.py:171:5: PIE790 [*] Unnecessary `...` expression
PIE790.py:171:5: PIE790 [*] Unnecessary `...` literal
|
169 | ...
170 |
Expand All @@ -580,7 +580,7 @@ PIE790.py:171:5: PIE790 [*] Unnecessary `...` expression
173 172 | for i in range(10):
174 173 | ... # comment

PIE790.py:174:5: PIE790 [*] Unnecessary `...` expression
PIE790.py:174:5: PIE790 [*] Unnecessary `...` literal
|
173 | for i in range(10):
174 | ... # comment
Expand All @@ -599,7 +599,7 @@ PIE790.py:174:5: PIE790 [*] Unnecessary `...` expression
176 176 |
177 177 | for i in range(10):

PIE790.py:175:5: PIE790 [*] Unnecessary `...` expression
PIE790.py:175:5: PIE790 [*] Unnecessary `...` literal
|
173 | for i in range(10):
174 | ... # comment
Expand All @@ -619,7 +619,7 @@ PIE790.py:175:5: PIE790 [*] Unnecessary `...` expression
177 176 | for i in range(10):
178 177 | ...

PIE790.py:178:5: PIE790 [*] Unnecessary `...` expression
PIE790.py:178:5: PIE790 [*] Unnecessary `...` literal
|
177 | for i in range(10):
178 | ...
Expand Down

0 comments on commit 4afdbbc

Please sign in to comment.