Skip to content

Add the ability to copy the python import path to the clipboard #16997

Closed

Description

Discussed in #16926

Originally posted by jarshwah August 10, 2021
I want to be able to right click a file and copy the import path to that file
so that I may paste it into a terminal/repl to gain access to those functions without having to type a long import path

https://marketplace.visualstudio.com/items?itemName=yardensachs.copy-python-path is an existing extension that does this, but I think it should be baked into the official plugin.

For context, a project I work on can have modules and packages nested quite deeply (10 or so levels deep). I often have to type out an extremely long import string during exploratory sessions, and would love to be able to copy a path from a file I'm looking at directly into the terminal.

Activity

  1. added
    feature-requestRequest for new features or functionality
    and removed
    triage-neededNeeds assignment to the proper sub-team
    on Aug 16, 2021
  2. jarshwah commented on Aug 17, 2021

    @jarshwah

    Apologies I had meant to respond to the discussion and then it dropped off my tab list/radar.

    To answer your question around algorithm, I had the following (perhaps incorrect) assumptions in mind:

    1. The language server knows what the root of the project is in most cases (pyproject, vscode config, etc) so init files don't need to be inspected to find the root
    2. Given the language server knows the root, traverse from current file to root, and that is more than likely your import path
    3. If it can't be resolved that way, repeat for all known roots (pythonpath, etc)

    I have very little understanding of the language server implementation and capabilities, and haven't spent nearly as much time thinking about these strategies as someone more familiar. I would not be surprised if I was way off the mark.

  3. brettcannon commented on Sep 1, 2021

    @brettcannon
    MemberAuthor

    Thanks for the feature request! We are going to give the community 60 days from when this issue was created to provide 5 👍 upvotes on the opening comment to gauge general interest in this idea. If there's enough upvotes then we will consider this feature request in our future planning. If there's unfortunately not enough upvotes then we will close this issue.

  4. brettcannon commented on Nov 1, 2021

    @brettcannon
    MemberAuthor

    Thank you for submitting your feature request and everyone who considered it! Unfortunately this issue did not receive enough votes over the allotted time, and so we are closing the issue.

  5. locked as resolved and limited conversation to collaborators on Dec 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-intellisenseLSP-related functionality: auto-complete, docstrings, navigation, refactoring, etc.feature-requestRequest for new features or functionalityneeds community feedbackAwaiting community feedback

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions