blank-line-after-terminal-control-block¶
Require separation after control blocks whose body exits early.
Message¶
Missing blank line after terminal control-flow block.
Settings¶
| Setting | Description | Type | Default |
|---|---|---|---|
| allow_compact_guard_ladders | Allow compact guard-ladder terminal branches without an extra blank line. | bool | True |
Valid examples¶
def normalize(value: str | None) -> str:
if value is None:
return ""
cleaned = value.strip()
return cleaned
Show more
def shell_args(shell_name: str, interactive: bool) -> list[str]:
if shell_name == "zsh":
return ["-lic"]
if interactive:
return ["-ic"]
return ["-lc"]
def consume(name: str) -> str:
parts: list[str] = []
index = 0
while index < len(name):
ch = name[index]
if ch in {"'", '"'}:
end = _consume_quoted_segment(name, index)
parts.append(name[index:end])
index = end
continue
parts.append(ch)
index += 1
return "".join(parts)
def collect(values: list[int]) -> list[int]:
result: list[int] = []
for value in values:
if value < 0:
continue
result.append(value)
return result
def render(parser: object, capsys: object) -> object:
try:
parser.run()
except SystemExit:
pass
out = capsys.readouterr()
return out
Invalid examples¶
def normalize(value: str | None) -> str:
if value is None:
return ""
cleaned = value.strip()
return cleaned
Suggested fix
def normalize(value: str | None) -> str:
if value is None:
return ""
cleaned = value.strip()
return cleaned
Show more
def collect(values: list[int]) -> list[int]:
result: list[int] = []
for value in values:
if value < 0:
continue
result.append(value)
return result
Suggested fix
def collect(values: list[int]) -> list[int]:
result: list[int] = []
for value in values:
if value < 0:
continue
result.append(value)
return result
def parse(text: str) -> object:
try:
return json.loads(text)
except ValueError:
pass
parsed = tomllib.loads(text)
return parsed
Suggested fix
def parse(text: str) -> object:
try:
return json.loads(text)
except ValueError:
pass
parsed = tomllib.loads(text)
return parsed