Skip to content

mypy.ini, setup.cfg not checked for ${nearestConfig} cwd #437

@edvilme

Description

@edvilme

Discussed in https://github.com/microsoft/vscode-mypy/discussions/356

Originally posted by tdscheper March 21, 2025
When cwd is ${nearestConfig}, the extension only looks for pyproject.toml and mypy.ini, per this code:

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):
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
)
return os.fspath(candidate)
# starting from the current file and working our way up
else:
candidate = candidate.parent
else:
log_to_output(
f"failed to find {', '.join(check_for)}; using workspace root",
lsp.MessageType.Debug,
)
return settings["workspaceFS"]

Shouldn't it also look for .mypy.ini and setup.cfg, since this is what Mypy does?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions