Skip to content
This repository was archived by the owner on Apr 14, 2022. It is now read-only.
This repository was archived by the owner on Apr 14, 2022. It is now read-only.

Implement code action for missing imports #19

Closed

Description

microsoft/vscode-python#21

Identify undeclared variables, find what module might have them, offer to insert import statement.

Activity

  1. removed this from the Oct 2018.2 milestone on Oct 10, 2018
  2. lauevrar77 commented on Oct 11, 2018

    @lauevrar77

    Is there any hints when this feature will be merged ?

  3. MikhailArkhipov commented on Oct 11, 2018

    @MikhailArkhipov
    Author

    lauevrar77 - if you install Zenhub extension to Chrome you will be able to see our scrum board and the prioritized backlog.

  4. MikhailArkhipov commented on Oct 11, 2018

    @MikhailArkhipov
    Author

    #242 comes first

  5. lauevrar77 commented on Oct 11, 2018

    @lauevrar77

    It seems legit, I must admit :). So no rough deadline at this time ?

  6. 37 remaining items

  7. oesah commented on Feb 5, 2020

    @oesah

    This is really the only missing feature from VSCode Python. I love how it works with Typescript, if we can get this feature working properly, PyCharm will have a hard time staying alive I believe.

  8. sbassah commented on Feb 17, 2020

    @sbassah

    Is there any update on when this feature will be released. It will really make using VS Code for Python development great.

  9. jakebailey commented on Feb 17, 2020

    @jakebailey
    Member

    This issue is closed, the code action (light bulb / diagnostic quick fix) for adding imports was implemented in October and has been released for a few months now. If you have an issue with the existing feature or comments on new features, please create a new issue as previously noted.

  10. hanezu commented on Feb 18, 2020

    @hanezu

    For those who wonder how to trigger auto-importing as I did, here are the steps.

    1. Enable Microsoft Python Language Server by removing the check of Python: Jedi Enabled in your settings.
    2. Reload the VSCode window.
    3. Hover your mouse over the variable that you want to import, and click Quick fix...

    For the last step, if it shows No quick fixes available or Checking for quick fixes, you may need to wait for a while until the extension has finished code analysis. It is also possible to set a shortcut that triggers a quick fix.

  11. peterdeme commented on May 26, 2020

    @peterdeme

    Jedi is disabled by default, I don't think that's the problem for most people.
    What I believe is the main source of the confusion is that you need to explicitly enable linting in order to get this working.
    image

    Even though it is written in the official docs page, it's not immediately obvious honestly.

  12. julien-c commented on May 26, 2020

    @julien-c

    Are you sure Jedi is disabled by default now? This was not the case even a couple of weeks ago.

  13. elicore commented on Jun 20, 2020

    @elicore

    This feature doesn't work. I'm using 1.47.0-insider and the only way I get missing imports intellisense is if I use the Importmagic extension.

  14. tiangolo commented on Jun 20, 2020

    @tiangolo

    This wasn't obvious to me up until recently, but the official Python extension works great in combination with Pyright: https://github.com/microsoft/pyright

    Pyright provides a bunch of other useful features, like suggesting automatic imports.

    It also handles better some edge cases like types for pathlib.Path and others.

    It's not a replacement for the Python extension but works very well on top.

  15. elicore commented on Jun 20, 2020

    @elicore

    This wasn't obvious to me up until recently, but the official Python extension works great in combination with Pyright: https://github.com/microsoft/pyright

    Pyright provides a bunch of other useful features, like suggesting automatic imports.

    It also handles better some edge cases like types for pathlib.Path and others.

    It's not a replacement for the Python extension but works very well on top.

    Thanks! I've been using VSCode for so long and haven't even heard of it. It works great!
    It should definitely be a part of the Python extension. The functionality it provides is sorely missing when moving from more advanced IDEs like PyCharm.

  16. jakebailey commented on Jun 30, 2020

    @jakebailey
    Member

    For those of you interested in what Pyright provides in VS Code, I would recommend looking at what we just posted today, a new LS based on Pyright that integrates fully with the Python extension.

    https://devblogs.microsoft.com/python/announcing-pylance-fast-feature-rich-language-support-for-python-in-visual-studio-code/

    Thanks for your patience!

  17. grisaitis commented on Jul 1, 2020

    @grisaitis

    Exciting! Congrats to the team. Looking forward to trying this out.

    Looking forward to poetry virtualenvs being auto detected (at some point) ;)

  18. ssbarnea commented on Aug 17, 2020

    @ssbarnea

    I am not sure why so many people are so happy about PyLance as they missed to read between the lines: PyLance is not open-source. I kinda find very hard not to think about the Embrace, extend, and extinguish approach.

    Today we add closed-sourced components, tomorrow mandatory free SaaS services and the day after tomorrow we start charging users for using them.

  19. autoferrit commented on Aug 21, 2020

    @autoferrit

    Sorin Sbarnea (@ssbarnea) I totally agree. The reason I use pylance, is because I have fight all the time with the existing tools to get autocomplete to work reliably. sometimes, it only works with words in the file. other, it knows nothing, other times, imports seem to be nothing related to what I want. I have been through so many articles it was just exhausting.
    I decided to keep pylance when I installed it, said to use it as the completion engine, and it just worked, and it worked really nice (granted still nowhere near what pycharm gives, but for being free, its great). I will keep trying the LS version now and then to see if I can get it working again, but until then, I just want things to work so I can write code. That being said, I do REALLY look forward to the LS being more robust.

  20. aringot commented on Apr 19, 2021

    @aringot

    Sorin Sbarnea (@ssbarnea) any alternative to recommend? (and thanks for the link!)

  21. codethief commented on Apr 26, 2021

    @codethief

    I'm very disappointed that Pylance is closed-source and that the Microsoft Python Language Server will be no longer be supported in the future but having now wasted hours on getting import quick fixes working, it looks I have no other choice than to resort to Pylance for the time being. Here are the settings that I put in my workspace's settings.json to enable it:

        "python.linting.enabled": true,
        "python.jediEnabled": false,
        "python.linting.pylintEnabled": false,
        "python.linting.mypyEnabled": false,
        "python.languageServer": "Pylance",
    

    (Make sure pylint is disabled or otherwise import quick fixes might not work, probably because pylint conflicts with Pylance. As for the mypy setting, I didn't actually try mypy but simply wanted to prevent conflicts with Pyright which comes integrated in Pylance.)

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

Metadata

Metadata

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions