Skip to content

Fix bug with unclear function signature #8668

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
6 changes: 2 additions & 4 deletions pylint/checkers/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1362,12 +1362,10 @@ def safe_infer(
return None
if (
isinstance(inferred, nodes.FunctionDef)
and inferred.args.args is not None
and isinstance(value, nodes.FunctionDef)
and value.args.args is not None
and len(inferred.args.args) != len(value.args.args)
and inferred.args.format_args() != value.args.format_args()
):
return None # Different number of arguments indicates ambiguity
return None # Different arguments indicates ambiguity
except astroid.InferenceError:
return None # There is some kind of ambiguity
except StopIteration:
Expand Down
20 changes: 20 additions & 0 deletions tests/functional/u/unexpected_keyword_arg.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,3 +116,23 @@ def test_no_return():


test_no_return(internal_arg=2) # [unexpected-keyword-arg]


def ambiguous_func1(arg1):
print(arg1)


def ambiguous_func2(other_arg1):
print(other_arg1)


func1 = ambiguous_func1 if unknown else ambiguous_func2
func1(other_arg1=1)


def ambiguous_func3(arg1=None):
print(arg1)


func2 = ambiguous_func1 if unknown else ambiguous_func3
func2()