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

Pylance appends to star import for auto-imports not defined in __all__ #1679

Closed
NCPlayz opened this issue Aug 16, 2021 · 5 comments
Closed
Assignees
Labels
bug Something isn't working fixed in next version (main) A fix has been implemented and will appear in an upcoming version

Comments

@NCPlayz
Copy link

NCPlayz commented Aug 16, 2021

Environment data

  • Language Server version: 2021.8.1
  • OS and version: win32 x64
  • Python version (and distribution if applicable, e.g. Anaconda): 3.9.4 64-bit
  • python.analysis.indexing: undefined
  • python.analysis.typeCheckingMode: strict

Expected behaviour

A new import line is added for the specific symbol not defined in __all__:

from test import *
from test import B

Actual behaviour

The symbol not defined in __all__ is simply appended to the end of the star import:

from test import *B,

Logs

Python Language Server Log

Typing "A" (see GIF):

Background analysis message: setFileOpened
Background analysis message: markFilesDirty
[FG] completion at test2.py:2:1 ...
[FG]   parsing: test2.py (0ms)
[FG]   binding: test2.py (0ms)
[FG] completion at test2.py:2:1 [found 89 items] (2ms)
Background analysis message: analyze
[BG(1)] analyzing: test2.py ...
[BG(1)]   parsing: test2.py (1ms)
[BG(1)]   binding: test2.py (0ms)
[BG(1)]   checking: test2.py (1ms)
[BG(1)] analyzing: test2.py (2ms)
Background analysis message: getDiagnosticsForRange
Background analysis message: resumeAnalysis
Background analysis message: getDiagnosticsForRange
Background analysis message: getSemanticTokens delta
[BG(1)] getSemanticTokens delta previousResultId:1629072695818 at test2.py (0ms)
Background analysis message: markFilesDirty
Background analysis message: analyze
Background analysis message: setFileOpened
Background analysis message: markFilesDirty
Background analysis message: analyze
[BG(1)] analyzing: test2.py ...
[BG(1)]   parsing: test2.py (0ms)
[BG(1)]   binding: test2.py (0ms)
[BG(1)]   checking: test2.py (0ms)
[BG(1)] analyzing: test2.py (0ms)
Background analysis message: resumeAnalysis
Background analysis message: getSemanticTokens delta
[BG(1)] getSemanticTokens delta previousResultId:1629072700448 at test2.py (2ms)
[FG] parsing: test2.py (0ms)
[FG] binding: test2.py (0ms)
Background analysis message: markFilesDirty
Background analysis message: analyze

Typing "B" and pressing enter for suggestion:

Background analysis message: setFileOpened
Background analysis message: markFilesDirty
[FG] completion at test2.py:2:1 ...
[FG]   parsing: test2.py (0ms)
[FG]   binding: test2.py (0ms)
[FG] completion at test2.py:2:1 [found 29 items] (1ms)
Background analysis message: getDiagnosticsForRange
Background analysis message: getDiagnosticsForRange
Background analysis message: getSemanticTokens delta
[BG(1)] getSemanticTokens delta previousResultId:1629072704015 at test2.py ...
[BG(1)]   parsing: test2.py (0ms)
[BG(1)]   binding: test2.py (1ms)
[BG(1)] getSemanticTokens delta previousResultId:1629072704015 at test2.py (3ms)
Background analysis message: analyze
[BG(1)] analyzing: test2.py ...
[BG(1)]   checking: test2.py (0ms)
[BG(1)] analyzing: test2.py (0ms)
Background analysis message: resumeAnalysis
Background analysis message: getDiagnosticsForRange
Background analysis message: getDiagnosticsForRange
Background analysis message: markFilesDirty
Background analysis message: analyze
Background analysis message: setFileOpened
Background analysis message: markFilesDirty
Background analysis message: setFileOpened
Background analysis message: markFilesDirty
Background analysis message: analyze
[BG(1)] analyzing: test2.py ...
[BG(1)]   parsing: test2.py (1ms)
[BG(1)]   binding: test2.py (0ms)
[BG(1)]   checking: test2.py (2ms)
[BG(1)] analyzing: test2.py (3ms)
Background analysis message: resumeAnalysis
Background analysis message: getSemanticTokens delta
[BG(1)] getSemanticTokens delta previousResultId:1629072758386 at test2.py (0ms)
[FG] parsing: test2.py (0ms)
[FG] binding: test2.py (0ms)
Background analysis message: getDiagnosticsForRange
Background analysis message: getDiagnosticsForRange
Background analysis message: setFileOpened
Background analysis message: markFilesDirty
Background analysis message: analyze
[BG(1)] analyzing: test2.py ...
[BG(1)]   parsing: test2.py (0ms)
[BG(1)]   binding: test2.py (0ms)
[BG(1)]   checking: test2.py (2ms)
[BG(1)] analyzing: test2.py (2ms)
Background analysis message: resumeAnalysis
Background analysis message: getSemanticTokens delta
[BG(1)] getSemanticTokens delta previousResultId:1629072760438 at test2.py (1ms)
[FG] parsing: test2.py (0ms)
[FG] binding: test2.py (0ms)
Background analysis message: markFilesDirty
Background analysis message: getDiagnosticsForRange
Background analysis message: getDiagnosticsForRange
Background analysis message: analyze

Code Snippet / Additional information

test.py

__all__ = ("A",)


class A:
    ...


class B:
    ...

HkhNVpobf6

@jakebailey jakebailey added the bug Something isn't working label Aug 16, 2021
@github-actions github-actions bot removed the triage label Aug 16, 2021
@NCPlayz

This comment has been minimized.

@AlonsoMackenlly

This comment has been minimized.

@AlonsoMackenlly

This comment has been minimized.

@jakebailey

This comment has been minimized.

@jakebailey jakebailey added auto import needs investigation Could be an issue - needs investigation labels Aug 31, 2021
@jakebailey jakebailey added fixed in next version (main) A fix has been implemented and will appear in an upcoming version and removed needs investigation Could be an issue - needs investigation labels Sep 23, 2021
@jakebailey
Copy link
Member

This issue has been fixed in version 2021.9.4, which we've just released. You can find the changelog here: https://github.com/microsoft/pylance-release/blob/main/CHANGELOG.md#202194-29-september-2021

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

5 participants