Pylance-release: Got false error about object is not callable.

Created on 21 Aug 2020  路  2Comments  路  Source: microsoft/pylance-release

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.

    bug fixed in next version

    All 2 comments

    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.

    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

    Was this page helpful?
    0 / 5 - 0 ratings

    Related issues

    BrunoBlanes picture BrunoBlanes  路  4Comments

    yankyhoffman picture yankyhoffman  路  5Comments

    notatallshaw picture notatallshaw  路  4Comments

    peach-lasagna picture peach-lasagna  路  3Comments

    albireox picture albireox  路  5Comments