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

Code lens "recent change" shows on every Python import statement that imports a Class or Function SymbolKind #371

Closed
phillipdwright opened this issue May 15, 2018 · 13 comments
Labels
blocked: language-server Caused by or dependent on a language server issue or feature blocked: vscode Caused by or dependent on a VS Code issue or feature blocked Blocked or caused by an upstream issue or feature

Comments

@phillipdwright
Copy link

  • GitLens Version: 8.2.4
  • VSCode Version: 1.23.0
  • OS Version: Windows 10 Version 1803

Steps to Reproduce:

  1. Include Python import statements of the form from X import Y, where Y is a class or function. Eg.,
from unittest import TestCase
from unittest.mock import patch, Mock
from unittest import mock


class SampleTestCase(TestCase):
    def test_something(self):
        mock_patch = Mock(patch)
        self.assertTrue(isinstance(mock_patch, mock.Mock))
  1. Observe that Code lens "recent change" annotations are listed above every import statement that imports a class or function.

62a7eaf removed these annotations for imports of the form import X or from X import Y, where Y is a SymbolKind.Module, but they remain when Y is any other SymbolKind. I know there are settings for disabling "recent change" Code lens annotations (gitlens.codeLens.recentChange.enabled) and for disabling Code lens annotations altogether for different SymbolKinds, but this removes annotations that would be helpful elsewhere in the file.

With added settings

  "gitlens.debug": true,
  "gitlens.codeLens.scopesByLanguage": [
    {
      "language": "python",
      "scopes": [
        "document",
        "containers",
        "blocks"
      ]
    }
  ]

the example above shows as follows:
image

Adding "symbolScopes": ["!Module", "!Function", "!Class"] to my settings would also remove helpful Code lens annotations on the class and function definitions in the file.

Would it be possible to have Python import statements be treated differently for purposes of Code lens and only have annotations show up for SymbolKind.File on those lines?

@phillipdwright
Copy link
Author

Awesome product, by the way! I love it.

@eamodio
Copy link
Member

eamodio commented May 16, 2018

Unfortunately right now I don't think there is much I can do to address this. Although once microsoft/vscode#34968 lands I might be in a better position to be able to address this issue depending on the data provided by the language service and how abstract it can be.

Thanks! 😄

@eamodio eamodio added the blocked: vscode Caused by or dependent on a VS Code issue or feature label May 16, 2018
@ryotat
Copy link

ryotat commented Jun 19, 2018

I also had this issue but updating to VS Code (1.24.1) and Gitlens (8.4.0) seem to have fixed the issue. Thanks!

@eamodio
Copy link
Member

eamodio commented Jun 19, 2018

I'm not sure why this changed -- maybe the python language service changed at the same time. @phillipdwright are you seeing this fixed as well?

@eamodio
Copy link
Member

eamodio commented Jun 19, 2018

Err. Nevermind, this was fixed as part of #331

@eamodio eamodio closed this as completed Jun 19, 2018
@fgs-pwright
Copy link

fgs-pwright commented Jun 19, 2018

I don't believe this is resolved. #331 fixes this for imports of the form import X or from X import Y, where Y is a SymbolKind.Module. But the "recent change" annotations remain when Y is any other SymbolKind. In particular, I still see this issue for imports of the form from X import Y, where Y is a SymbolKind.Class or a SymbolKind.Function.

As a workaround, I have "gitlens.codeLens.recentChange.enabled": false in my User Settings, but I know I'm missing out on a helpful feature.

I have updated to VS Code 1.24.1 and GitLens 8.4.0.

@eamodio
Copy link
Member

eamodio commented Jun 19, 2018

The only real option there is to use gitlens.codeLens.scopesByLanguage to pick and choose how you want each SymbolKind to behave.

Maybe once microsoft/vscode#34968 lands and the language services provide more information, I can detect that those symbols are within an import and then suppress them

@eamodio eamodio reopened this Jun 19, 2018
@eamodio eamodio added the blocked: language-server Caused by or dependent on a language server issue or feature label Jul 9, 2018
@DJMcNab
Copy link

DJMcNab commented Sep 30, 2018

microsoft/vscode#34968 has landed, but it doesn't seem to give what we would need (unless I'm misunderstanding something).

I came to this issue because of a similar issue with @matklad's rust-analyzer, where there is recent changes for every simple mod statement, which doesn't seem right:

image

@eamodio
Copy link
Member

eamodio commented Sep 30, 2018

microsoft/vscode#34968 didn't expose any more information to GitLens, but microsoft/vscode#57984 fixed that (which will be released when the vscode 1.28 ships).

I have also made some changes in the next release of GitLens, to stop adding the authorship codelens unless the symbol spans more than 1 line -- which should help with this issue as well.

@DJMcNab
Copy link

DJMcNab commented Sep 30, 2018

Yeah - that change to stop one line recent changes is a good thing - that looks like it should fix it. Sorry to have bothered you!

@eamodio
Copy link
Member

eamodio commented Sep 30, 2018

No bother at all -- your post prompted me to add the single line change! 😄

@eamodio
Copy link
Member

eamodio commented Nov 11, 2019

I'm going to close this, as I believe this has been addressed now.

@eamodio eamodio closed this as completed Nov 11, 2019
@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 27, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
blocked: language-server Caused by or dependent on a language server issue or feature blocked: vscode Caused by or dependent on a VS Code issue or feature blocked Blocked or caused by an upstream issue or feature
Projects
None yet
Development

No branches or pull requests

5 participants