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

Got false error about object is not callable. #269

Closed
cebor opened this issue Aug 21, 2020 · 2 comments
Closed

Got false error about object is not callable. #269

cebor opened this issue Aug 21, 2020 · 2 comments
Labels
bug Something isn't working fixed in next version (main) A fix has been implemented and will appear in an upcoming version

Comments

@cebor
Copy link

cebor commented Aug 21, 2020

Environment data

  • Language Server version: 2020.8.2
  • OS and version: macOS 10.15
  • Python version (& distribution if applicable, e.g. Anaconda): python 3.8 (venv)

Expected behaviour

No error is been shown.

Actual behaviour

Shows following false error: "PostProcessor(t)" has type "PostProcessor" and is not callable

Code to reproduce issue:

from testa.tooling.post_processing import PostProcessor

class Main(testa.StdMain):
    def run(self):
        with PostProcessor(t) as p:
            p.run()

post_processing/__init__.py

from .PostProcessor_Special import * # maybe this '*' import causes the issue, direct import works

PostProcessor=PostProcessor_Special

post_processing/PostProcessor_Special.py

class PostProcessor_Special:
    def __init__(self, t, issue=None):
        self.org_t = t
        self.issue = issue

With language server set to jedi, all works fine.

@erictraut
Copy link
Contributor

erictraut commented Aug 21, 2020

Thanks for the bug report. This will be fixed in the next version of Pylance.

In case you're interested in the details...

When you use a statement of the form from .A import B within an __init__.py file, the Python interpreter implicitly creates a symbol A and assigns it to refer to the submodule "A". If you use the form from .A import A or from .A import B as A, the same thing occurs, but the value of symbol A is immediately overwritten with the value that is imported from submodule A. Pylance was handling that case correctly, but it wasn't handling the case where a wildcard import was used (from .A import * where one of the imported symbols was named "A"). That's the edge case you hit in your code.

@erictraut erictraut added the fixed in next version (main) A fix has been implemented and will appear in an upcoming version label Aug 21, 2020
@github-actions github-actions bot removed the triage label Aug 21, 2020
@erictraut erictraut added the bug Something isn't working label Aug 21, 2020
@jakebailey
Copy link
Member

This issue has been fixed in version 2020.8.3, which we've just released. You can find the changelog here: https://github.com/microsoft/pylance-release/blob/master/CHANGELOG.md#202083-28-august-2020

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working fixed in next version (main) A fix has been implemented and will appear in an upcoming version
Projects
None yet
Development

No branches or pull requests

3 participants