nvim-neotest / neotest-python

MIT License
126 stars 38 forks source link

feat: add poetry and pipenv python detection #9

Closed nikita-orca closed 2 years ago

nikita-orca commented 2 years ago

Closed previous PR.

Found cli commands for detecting python interpreter path (for poetry and pipenv). Using commands like poetry run python or pipenv run python is fine, but it's not working with dap.

Added memorization for M.get_python_command, because it's heavily used and os.popen takes a lot of time (I have a pretty huge python project, and it took 3-4 minutes before the test started)

Also I think it makes sense to add another data source - lsp servers. This is what is have for my dap python config. It's using vim, I guess there are alternatives from the plenary lua lib, would be nice if you can port it and include to the repo :)

            local path
            for _, server in pairs(vim.lsp.buf_get_clients()) do
                if server.name == "pyright" or server.name == "pylance" then
                    path = vim.tbl_get(server, "config", "settings", "python", "pythonPath")
                    break
                end
            end
            -- path = vim.fn.input("Python path: ", path or "", "file")
            path = path ~= "" and vim.fn.expand(path) or nil

P.S. I really hate starting python venv before using nvim, so I'm aiming for lsp, debuggers and test runners to pick it up automatically

nikita-orca commented 2 years ago

@rcarriga

nikita-orca commented 2 years ago

Thanks for new PR. Two small comments, then LGTM.

I have a pretty huge python project, and it took 3-4 minutes before the test started

I'm curious what exactly took so long, was it Neotest starting up or actually running the test?

M.get_python_command was invoked a lot, without memorization it took few minutes, when I added it 1-2 seconds

rcarriga commented 2 years ago

Thanks again!