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

Go to Definition(F12) of the pytest fixture does not work in a workspace project. #5114

Closed
yakkle opened this issue Nov 14, 2023 · 12 comments
Closed
Assignees
Labels
bug Something isn't working

Comments

@yakkle
Copy link

yakkle commented Nov 14, 2023

The pylance 2023.09.30 version works, but later versions do not.
Works when a single project, but not when changed to a workspace project.

Environment data

  • Language Server version: 2023.11.10
  • OS and version: MacOS Monterey 12.6(21G115) M1
  • Python version (& distribution if applicable, e.g. Anaconda): 3.11.6

Code Snippet

import pytest

@pytest.fixture
def foo() -> str:
    return "foo"


@pytest.fixture
def bar(foo):
    print(foo)
    return "bar"

Repro Steps

  1. Open python project
  2. Create conftest.py with above sample code.
  3. File -> Add Folder to Workspace...
  4. cmd + click or F12 on parameter foo in fixture bar

Expected behavior

Go to definition of fixture foo

#3727

Actual behavior

Go to print(foo) in fixture bar

@github-actions github-actions bot added the needs repro Issue has not been reproduced yet label Nov 14, 2023
@debonte debonte added bug Something isn't working and removed needs repro Issue has not been reproduced yet labels Nov 30, 2023
@qmmp123
Copy link

qmmp123 commented Dec 19, 2023

+1

@debonte
Copy link
Contributor

debonte commented Dec 19, 2023

This appears to be fixed in our latest prerelease build (2023.12.100). Can you give it a try?

@debonte debonte added the waiting for user response Requires more information from user label Dec 19, 2023
@qmmp123
Copy link

qmmp123 commented Dec 19, 2023

Still doesn't work. May be I can provide some logs or anything else?

Pylance - 2023.12.100

VsCode
Version: 1.85.1
Commit: 0ee08df0cf4527e40edc9aa28f4b5bd38bbff2b2
Date: 2023-12-13T09:47:11.635Z
Electron: 25.9.7
ElectronBuildId: 25551756
Chromium: 114.0.5735.289
Node.js: 18.15.0
V8: 11.4.183.29-electron.0
OS: Linux x64 6.4.7-arch1-2

@debonte
Copy link
Contributor

debonte commented Dec 20, 2023

@qmmp123, can you provide source code that reproduces what you're seeing?

Also please confirm that you have python.analysis.enablePytestSupport set to true. And that the file you code is in is either named conftest.py, test_*.py, or *_test.py.

@debonte
Copy link
Contributor

debonte commented Dec 20, 2023

Thanks. I'm able to repro it now. I'll investigate.

@debonte debonte removed the waiting for user response Requires more information from user label Dec 20, 2023
@debonte
Copy link
Contributor

debonte commented Dec 20, 2023

Sorry, I was wrong. I can't reproduce what you're seeing. It's pretty odd that hover says the type of the parameter is Unknown while the inlay hint says that it's LibvirtVMResource though.

@yakkle, can you try 2023.12.100 and see if your issue is fixed? I'm pretty sure that what @qmmp123 is seeing is unrelated.

@qmmp123, without a repro we can't fix this. Could you give me temporary access to your repo? If not, could you reduce your repro case to something simple and shareable?

@qmmp123
Copy link

qmmp123 commented Dec 20, 2023

I will try to do it

@debonte debonte added the waiting for user response Requires more information from user label Dec 21, 2023
@qmmp123
Copy link

qmmp123 commented Dec 21, 2023

I've reproduced it. That problem caused by code-workspace file. Try it https://github.com/qmmp123/sandbox .

UPD:
Seems like if you have several objects in folders pylance will be broken

@debonte
Copy link
Contributor

debonte commented Dec 21, 2023

That problem caused by code-workspace file. Try it https://github.com/qmmp123/sandbox .

Thanks. I still can't reproduce it. Maybe it's settings related? Can you provide your user settings.json?

@qmmp123
Copy link

qmmp123 commented Dec 21, 2023

settings.json
{
    "workbench.colorTheme": "GitHub Dark",
    "window.titleBarStyle": "custom",
    "window.customMenuBarAltFocus": false,
    "cmake.configureOnOpen": true,
    "explorer.autoReveal": false,
    "workbench.colorCustomizations": {
        "statusBar.background": "#005f5f",
        "statusBar.noFolderBackground": "#005f5f",
        "statusBar.debuggingBackground": "#005f5f"
    },
    "vscode-neovim.logPath": "~/.vscode-neovim.log",
    "vscode-neovim.neovimExecutablePaths.linux": "/usr/bin/nvim",
    "vscode-neovim.neovimInitVimPaths.linux": "~/.config/nvim/init-vscode.vim",
    "editor.lineNumbers": "relative",
    "workbench.iconTheme": "material-icon-theme",
    "python.analysis.diagnosticSeverityOverrides": {
        "reportUndefinedVariable": "warning"
    },
    "vscode-neovim.neovimExecutablePaths.darwin": "/usr/local/bin/nvim",
    "vscode-neovim.neovimInitVimPaths.darwin": "~/.config/nvim/init-vscode.vim",
    "editor.minimap.enabled": false,
    "problems.showCurrentInStatus": true,
    "editor.suggest.showStatusBar": true,
    "editor.unicodeHighlight.ambiguousCharacters": false,
    "python.analysis.useLibraryCodeForTypes": true,
    "workbench.editor.enablePreview": false,
    "editor.suggest.showColors": true,
    "editor.suggest.showWords": true,
    "python.analysis.autoImportCompletions": false,
    "editor.suggest.preview": true,
    "editor.suggest.localityBonus": true,
    "explorer.confirmDelete": false,
    "editor.largeFileOptimizations": false,
    "workbench.editor.empty.hint": "hidden",
    "extensions.experimental.affinity": {
        "asvetliakov.vscode-neovim": 1
    },
    "python.languageServer": "Pylance",
    "python.analysis.typeCheckingMode": "basic",
    "python.analysis.inlayHints.pytestParameters": true,
    "python.testing.pytestEnabled": true,
    "git.autofetch": true,
}
Did you open project as workspace?
Screenshot

image

@yakkle
Copy link
Author

yakkle commented Dec 25, 2023

@debonte I will try with 2023.12.100. thanks.

@github-actions github-actions bot added user responded Was "waiting for user response" and they responded and removed waiting for user response Requires more information from user labels Dec 25, 2023
@yakkle
Copy link
Author

yakkle commented Dec 26, 2023

@debonte

I've tested it with the 2023.12.100 and 2023.12.101 prerelease versions and it works fine.
However, looking at the changelog, I'm not sure which issue fix made it work.

@debonte debonte removed the user responded Was "waiting for user response" and they responded label Jan 3, 2024
@debonte debonte closed this as completed Jan 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants