Skip to content

Commit

Permalink
fixup pyfmt and logs
Browse files Browse the repository at this point in the history
  • Loading branch information
jwhitaker-gridcog committed Sep 3, 2024
1 parent add689d commit 48070a4
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions bundled/tool/lsp_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -655,20 +655,25 @@ def get_cwd(settings: Dict[str, Any], document: Optional[workspace.Document]) ->
if settings["cwd"] == "${nearestConfig}":
workspaceFolder = pathlib.Path(settings["workspaceFS"])
candidate = pathlib.Path(document.path).parent
# check if pyproject exists
check_for = ["pyproject.toml", "mypy.ini"]
# until we leave the workspace
while candidate.is_relative_to(workspaceFolder):
# check if pyproject exists
check_for = ["pyproject.toml", "mypy.ini"]
for n in check_for:
candidate_file = candidate / n
if candidate_file.is_file():
log_to_output(f"found {n}, using {candidate}", lsp.MessageType.Debug)
log_to_output(
f"found {n}, using {candidate}", lsp.MessageType.Debug
)
return os.fspath(candidate)
# starting from the current file and working our way up
else:
candidate = candidate.parent
else:
log_to_output("failed to find pyproject.toml, using workspace root", lsp.MessageType.Debug)
log_to_output(
f"failed to find {', '.join(check_for)}; using workspace root",
lsp.MessageType.Debug,
)
return settings["workspaceFS"]

return settings["cwd"]
Expand Down

0 comments on commit 48070a4

Please sign in to comment.