Skip to content

Commit

Permalink
Merge assignment-from-no-return into assignment-from-none
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobtylerwalls committed Jul 2, 2023
1 parent 32effc5 commit a0e38e0
Show file tree
Hide file tree
Showing 11 changed files with 25 additions and 40 deletions.
5 changes: 0 additions & 5 deletions doc/data/messages/a/assignment-from-no-return/bad.py

This file was deleted.

5 changes: 0 additions & 5 deletions doc/data/messages/a/assignment-from-no-return/good.py

This file was deleted.

3 changes: 0 additions & 3 deletions doc/user_guide/checkers/features.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1193,9 +1193,6 @@ Typecheck checker Messages
Used when a function call would result in assigning multiple values to a
function parameter, one value from a positional argument and one from a
keyword argument.
:assignment-from-no-return (E1111): *Assigning result of a function call, where the function has no return*
Used when an assignment is done on a function call but the inferred function
doesn't return anything.
:assignment-from-none (E1128): *Assigning result of a function call, where the function returns None*
Used when an assignment is done on a function call but the inferred function
returns nothing but None.
Expand Down
1 change: 0 additions & 1 deletion doc/user_guide/messages/messages_overview.rst
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ All messages in the error category:
error/abstract-class-instantiated
error/access-member-before-definition
error/assigning-non-slot
error/assignment-from-no-return
error/assignment-from-none
error/await-outside-async
error/bad-configuration-section
Expand Down
4 changes: 4 additions & 0 deletions doc/whatsnew/fragments/8810.other
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Merged ``assignment-from-no-return`` message into ``assignment-from-none``.
The historical name will still work.

Closes #8810
33 changes: 14 additions & 19 deletions pylint/checkers/typecheck.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,12 +263,6 @@ def _missing_member_hint(
"Used when an object being called has been inferred to a non "
"callable object.",
),
"E1111": (
"Assigning result of a function call, where the function has no return",
"assignment-from-no-return",
"Used when an assignment is done on a function call but the "
"inferred function doesn't return anything.",
),
"E1120": (
"No value for argument %s in %s call",
"no-value-for-parameter",
Expand Down Expand Up @@ -318,7 +312,12 @@ def _missing_member_hint(
"assignment-from-none",
"Used when an assignment is done on a function call but the "
"inferred function returns nothing but None.",
{"old_names": [("W1111", "old-assignment-from-none")]},
{
"old_names": [
("W1111", "old-assignment-from-none"),
("E1111", "assignment-from-no-return"),
]
},
),
"E1129": (
"Context manager '%s' doesn't implement __enter__ and __exit__.",
Expand Down Expand Up @@ -1239,7 +1238,6 @@ def _get_nomember_msgid_hint(
return msg, hint # type: ignore[return-value]

@only_required_for_messages(
"assignment-from-no-return",
"assignment-from-none",
"non-str-assignment-to-dunder-name",
)
Expand Down Expand Up @@ -1287,18 +1285,15 @@ def _check_assignment_from_function_call(self, node: nodes.Assign) -> None:
return_nodes = list(
function_node.nodes_of_class(nodes.Return, skip_klass=nodes.FunctionDef)
)
if not return_nodes:
self.add_message("assignment-from-no-return", node=node)
for ret_node in return_nodes:
if not (
isinstance(ret_node.value, nodes.Const)
and ret_node.value.value is None
or ret_node.value is None
):
break
else:
for ret_node in return_nodes:
if not (
isinstance(ret_node.value, nodes.Const)
and ret_node.value.value is None
or ret_node.value is None
):
break
else:
self.add_message("assignment-from-none", node=node)
self.add_message("assignment-from-none", node=node)

@staticmethod
def _is_ignored_function(
Expand Down
4 changes: 2 additions & 2 deletions tests/functional/a/assignment/assignment_from_no_return.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ def some_other_decorated_method(self):
pass

def some_other_method(self):
value = self.some_method() # [assignment-from-no-return]
value = self.some_method() # [assignment-from-none]
other_value = self.some_other_decorated_method()
return value + other_value


VALUE = some_func() # [assignment-from-no-return]
VALUE = some_func() # [assignment-from-none]


class Parent:
Expand Down
4 changes: 2 additions & 2 deletions tests/functional/a/assignment/assignment_from_no_return.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
assignment-from-no-return:26:8:26:34:Class.some_other_method:Assigning result of a function call, where the function has no return:UNDEFINED
assignment-from-no-return:31:0:31:19::Assigning result of a function call, where the function has no return:UNDEFINED
assignment-from-none:26:8:26:34:Class.some_other_method:Assigning result of a function call, where the function returns None:UNDEFINED
assignment-from-none:31:0:31:19::Assigning result of a function call, where the function returns None:UNDEFINED
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def func_no_return():
"""function without return"""
print('dougloup')

A = func_no_return() # [assignment-from-no-return]
A = func_no_return() # [assignment-from-none]


def func_return_none():
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
assignment-from-no-return:17:0:17:20::Assigning result of a function call, where the function has no return:UNDEFINED
assignment-from-none:17:0:17:20::Assigning result of a function call, where the function returns None:UNDEFINED
assignment-from-none:25:0:25:22::Assigning result of a function call, where the function returns None:UNDEFINED
assignment-from-none:32:0:32:31::Assigning result of a function call, where the function returns None:UNDEFINED
assignment-from-none:35:0:35:14::Assigning result of a function call, where the function returns None:INFERENCE
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# pylint: disable=missing-docstring,import-error,unused-import,assignment-from-no-return
# pylint: disable=missing-docstring,import-error,unused-import,assignment-from-none
# pylint: disable=invalid-name, too-few-public-methods
from UNINFERABLE import uninferable_func

Expand Down

0 comments on commit a0e38e0

Please sign in to comment.