Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .github/workflows/checks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ on:
branches:
- main
- "maintenance/**"
pull_request: ~
pull_request:
branches:
- main
- "maintenance/**"

env:
CACHE_VERSION: 1
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ on:
- "maintenance/**"
paths-ignore:
- doc/data/messages/**
pull_request: ~
pull_request:
branches:
- main
- "maintenance/**"

env:
CACHE_VERSION: 1
Expand Down
3 changes: 3 additions & 0 deletions doc/whatsnew/fragments/7860.false_positive
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
``multiple-statements`` no longer triggers for function stubs using inlined ``...``.

Closes #7860
16 changes: 5 additions & 11 deletions pylint/checkers/format.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,7 @@
from astroid import nodes

from pylint.checkers import BaseRawFileChecker, BaseTokenChecker
from pylint.checkers.utils import (
is_overload_stub,
is_protocol_class,
node_frame_class,
only_required_for_messages,
)
from pylint.checkers.utils import only_required_for_messages
from pylint.constants import WarningScope
from pylint.interfaces import HIGH
from pylint.typing import MessageDefinitionTuple
Expand Down Expand Up @@ -567,15 +562,14 @@ def _check_multi_statement_line(self, node: nodes.NodeNG, line: int) -> None:
):
return

# Function overloads that use ``Ellipsis`` are exempted.
# Functions stubs with ``Ellipsis`` as body are exempted.
if (
isinstance(node, nodes.Expr)
isinstance(node.parent, nodes.FunctionDef)
and isinstance(node, nodes.Expr)
and isinstance(node.value, nodes.Const)
and node.value.value is Ellipsis
):
frame = node.frame(future=True)
if is_overload_stub(frame) or is_protocol_class(node_frame_class(frame)):
return
return

self.add_message("multiple-statements", node=node)
self._visited_lines[line] = 2
Expand Down
2 changes: 1 addition & 1 deletion tests/functional/m/multiple_statements.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ class MyError(Exception): a='a'; b='b' # [multiple-statements]
@overload
def concat2(arg1: str) -> str: ...

def concat2(arg1: str) -> str: ... # [multiple-statements]
def concat2(arg1: str) -> str: ...
1 change: 0 additions & 1 deletion tests/functional/m/multiple_statements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,3 @@ multiple-statements:9:9:9:13::More than one statement on a single line:UNDEFINED
multiple-statements:13:26:13:30:MyError:More than one statement on a single line:UNDEFINED
multiple-statements:15:26:15:31:MyError:More than one statement on a single line:UNDEFINED
multiple-statements:17:26:17:31:MyError:More than one statement on a single line:UNDEFINED
multiple-statements:30:31:30:34:concat2:More than one statement on a single line:UNDEFINED
2 changes: 1 addition & 1 deletion tests/functional/m/multiple_statements_single_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ class MyError(Exception): a='a'; b='b' # [multiple-statements]
@overload
def concat2(arg1: str) -> str: ...

def concat2(arg1: str) -> str: ... # [multiple-statements]
def concat2(arg1: str) -> str: ...
1 change: 0 additions & 1 deletion tests/functional/m/multiple_statements_single_line.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
multiple-statements:9:9:9:13::More than one statement on a single line:UNDEFINED
multiple-statements:17:26:17:31:MyError:More than one statement on a single line:UNDEFINED
multiple-statements:30:31:30:34:concat2:More than one statement on a single line:UNDEFINED