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

Feature request: auto-import as a code action #4263

Closed
abo-abo opened this issue Dec 1, 2022 · 13 comments
Closed

Feature request: auto-import as a code action #4263

abo-abo opened this issue Dec 1, 2022 · 13 comments
Labels
enhancement request New feature or request

Comments

@abo-abo
Copy link

abo-abo commented Dec 1, 2022

Is your feature request related to a problem? Please describe.
I like the auto-import from completion suggestions. But sometimes I like to copy-paste a ready function call. In that case it's awkward to re-trigger the completion just to get the auto-import.

Describe the solution you'd like
Add a code action to import the variable at point.

Additional context
Add any other context or screenshots about the feature request here.

@abo-abo abo-abo added the enhancement request New feature or request label Dec 1, 2022
@erictraut
Copy link
Collaborator

This is a language service feature that is included in pylance, Microsoft's premium Python language server for VS Code. We don't have plans to port it to pyright. If you want this functionality, please switch to pylance.

@AkibAzmain
Copy link

AkibAzmain commented Dec 2, 2022

@erictraut What? What if someone does a PR? Will you reject it?

@wizhi
Copy link

wizhi commented Dec 2, 2022

Microsoft's premium Python language server for VS Code.

Well, that's a mouthful.

I'd direct anyone interested in an actual open language server for Python towards python-lsp/python-lsp-server. The requested feature is seemingly supported.

@AkibAzmain
Copy link

I don't have any problem with any Microsoft software, as long as the software is free as in freedom. But they offend repeatedly, so fear touching any Microsoft software, even when its free (as in freedom).

@AkibAzmain
Copy link

AkibAzmain commented Dec 2, 2022

I think its better not to discuss these things here. Microsoft is probably going to lock this issue eventually.

@erictraut
Copy link
Collaborator

erictraut commented Dec 2, 2022

Pyright is a type checker and is focused on type checking. It includes some basic language server features, but we don't have plans to add or accept new language server features in pyright. We continually add new type checking features to pyright.

Microsoft employs a dedicated team of engineers who work on pylance, and they are continually adding new language server features to it. It has hundreds of features and capabilities that build on pyright's core type checking functionality.

There are other language servers that also build on pyright's type checking capabilities. If you're currently using pyright with an editor other than VS Code, then you're probably already making use of one of these LSP plug-ins. Some of these add additional language server features on top of pyright. For example, coc-pyright adds the auto-import feature that is requested here. If you have language server feature requests, I recommend directing those to the maintainers of the language server that you are using.

@AkibAzmain
Copy link

Microsoft employs a dedicated team of engineers who work on pylance

Pylance is gratis (zero price), then how does Microsoft make enough revenue to employ the team?

@DetachHead
Copy link

i've just released basedpyright 1.3.0 with code actions for import suggestions

@jkgenser
Copy link

Microsoft employs a dedicated team of engineers who work on pylance

Pylance is gratis (zero price), then how does Microsoft make enough revenue to employ the team?

It's to direct people to vscode. once in vscode, microsoft will monetize it's userbase via telemetry and offering paid plugins like github copilot.

@rbhanot4739
Copy link

@DetachHead I am using Basedpyright with Neovim and it works great, however I see the auto-import suggestions as code actions only work for built-in standard library modules and not for third party installed packages. Do we need to add the path to site-packages folder for project to extraPaths parameter with either lsp config or through pyrightconfig.json ?

@DetachHead
Copy link

probably the same issue as DetachHead/basedpyright#545, pyright doesn't know about the module if you haven't opened it yet. the reason it works for standard library modules is because of a recent change we made to make it always automatically load all the standard library modules (DetachHead/basedpyright#655).

not sure how pylance handles this, i've been meaning to look into this further but haven't had the time

@rbhanot4739
Copy link

I tried by setting extraPath to site-packages folder but even that didn't work.

@DetachHead
Copy link

see if setting basedpyright.analysis.diagnosticMode to "workspace" makes a difference. if not, maybe comment on DetachHead/basedpyright#545 and we can continue this discussion there instead

TabulateJarl8 added a commit to TabulateJarl8/dotfiles that referenced this issue Nov 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement request New feature or request
Projects
None yet
Development

No branches or pull requests

7 participants