Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

fix: remove pythonpath from project discovery #43

Merged
merged 1 commit into from
Sep 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions lua/pymple/utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,6 @@ local MAX_UPWARD_JUMPS = 10
---@param starting_dir string: The directory to start searching from
---@return string | nil: The root of the python project
local function find_project_root(starting_dir, root_markers)
local pythonpath = os.getenv("PYTHONPATH")
if pythonpath then
return pythonpath
end
local dir
if Path:new(starting_dir):is_dir() then
dir = starting_dir
Expand Down
13 changes: 2 additions & 11 deletions lua/tests/utils_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,15 @@ local cwd = vim.fn.getcwd()
local mock = require("luassert.mock")

describe("find_project_root", function()
it("pythonpath", function()
mock(os, "getenv", function()
return "/some/path"
end)
local result = utils.find_project_root(nil, {})
assert.equals("/some/path", result)
mock.revert(os)
end)

it("no pythonpath and src", function()
it("src present", function()
local result = utils.find_project_root(
FIXTURES_PATH .. "/project_with_src/src",
{ "pyproject.toml" }
)
assert.equals(FIXTURES_PATH .. "/project_with_src/src", result)
end)

it("no pythonpath and no src", function()
it("no src", function()
local result = utils.find_project_root(
FIXTURES_PATH .. "/project/module/__init__.py",
{ "pyproject.toml" }
Expand Down