Skip to content
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

Regression for #1186 #1200

Closed
cdce8p opened this issue Oct 5, 2021 · 2 comments · Fixed by #1204
Closed

Regression for #1186 #1200

cdce8p opened this issue Oct 5, 2021 · 2 comments · Fixed by #1204
Assignees
Milestone

Comments

@cdce8p
Copy link
Member

cdce8p commented Oct 5, 2021

#1186 added logic for parsing package names. This seems to have caused a regression visible as too-many-function-args error in the example below.

File structure

b
├── __init__.py
├── a.py
└── level1
    ├── __init__.py
    └── b.py
# b/a.py

# pylint: disable=missing-docstring

from .level1.b import func

def do_something(var, some_other_var):  # error
    func(var, some_other_var)
# b/level1/__init__.py

def func(var):
    pass
# b/level1/b.py

def func(var, some_other_var):
    pass

Runing pylint: pylint -sn b/a.py

************* Module b.a
b/a.py:8:4: E1121: Too many positional arguments for function call (too-many-function-args)

The error seems to happen as func is wrongly inferred as coming from b/level1/__init__.py, thus having one argument less than passed. The inference happens here: typecheck.py -> visit_call.

--
@DanielNoord As you authored #1186, would you mind taking a look at this?

@cdce8p cdce8p added this to the 2.8.1 milestone Oct 5, 2021
@DanielNoord
Copy link
Collaborator

I can take a look although I can't promise a timeframe. I am quite busy this week.

@DanielNoord DanielNoord self-assigned this Oct 5, 2021
@cdce8p
Copy link
Member Author

cdce8p commented Oct 5, 2021

Tested a few more things. Reverting the change to the return would fix the issue.
https://github.com/PyCQA/astroid/pull/1186/files#diff-4be1f47d39f9b6a7ff09c297908537522c8b33a348c0754d429a47dfa3308385L747-R755

-          return f"{package_name}.{modname}"
+          return f"{package_name}.{modname.split('.')[0]}"

Not sure that was even necessary as all the test cases seem to pass even without it. If it is, maybe there needs to be a conditional added?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants