-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Closed
Labels
acceptedReady for implementationReady for implementationruleImplementing or modifying a lint ruleImplementing or modifying a lint rule
Description
Hi, Python newbie here. test_return() warns about unnecessary assignment before return, so I was wondering, what about the same, but for yield?
$ cat a.py
import math
def test_return() -> int:
"""Test `return`."""
for size in range(1, 10):
content = math.sqrt(size)
return content
def test_yield() -> int:
"""Test `yield`."""
for size in range(1, 10):
content = math.sqrt(size)
yield content
$ ruff check . --select ALL --isolated
warning: `one-blank-line-before-class` (D203) and `no-blank-line-before-class` (D211) are incompatible. Ignoring `one-blank-line-before-class`.
warning: `multi-line-summary-first-line` (D212) and `multi-line-summary-second-line` (D213) are incompatible. Ignoring `multi-line-summary-second-line`.
a.py:1:1: D100 Missing docstring in public module
a.py:6:5: RET503 [*] Missing explicit `return` at the end of function able to return non-`None` value
a.py:8:16: RET504 [*] Unnecessary assignment to `content` before `return` statement
Found 3 errors.
[*] 2 potentially fixable with the --fix option.
$ # Debian sid
$ ruff --version
ruff 0.0.291
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
acceptedReady for implementationReady for implementationruleImplementing or modifying a lint ruleImplementing or modifying a lint rule