-
Notifications
You must be signed in to change notification settings - Fork 28
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
run mypy in the directory of the nearest pyproject.toml or mypy.ini #316
run mypy in the directory of the nearest pyproject.toml or mypy.ini #316
Conversation
@microsoft-github-policy-service agree company="Gridcog" |
8b68a2c
to
2d84c25
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR. Some minor changes and suggestions.
README.md
Outdated
@@ -47,7 +47,7 @@ There are several settings you can configure to customize the behavior of this e | |||
<tr> | |||
<td>mypy-type-checker.cwd</td> | |||
<td><code>${workspaceFolder}</code></td> | |||
<td>Sets the current working directory used to lint Python files with Mypy. By default, it uses the root directory of the workspace <code>${workspaceFolder}</code>. You can set it to <code>${fileDirname}</code> to use the parent folder of the file being linted as the working directory for Mypy. | |||
<td>Sets the current working directory used to lint Python files with Mypy. By default, it uses the root directory of the workspace <code>${workspaceFolder}</code>. You can set it to <code>${fileDirname}</code> to use the parent folder of the file being linted as the working directory for Mypy. You can also set it to <code>${filePyproject}</code> to use the folder of the nearest parent <code>pyproject.toml</code>. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The name should likely be ${nearestConfig}
since it does both pyproject and ini.
/cc @luabud
bundled/tool/lsp_server.py
Outdated
@@ -650,6 +650,27 @@ def get_cwd(settings: Dict[str, Any], document: Optional[workspace.Document]) -> | |||
return os.fspath(pathlib.Path(document.path).parent) | |||
return settings["workspaceFS"] | |||
|
|||
if settings["cwd"] == "${filePyproject}": | |||
if document is None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can probably move (document is None
) case to the beginning of the function. Since it is common to all scenarios.
3b4e9cd
to
add689d
Compare
hey, rebased on new main, fixed fmt lint and squash a couple of fixups, but PR checks need approval again sorry |
hi @jwhitaker-gridcog! Thanks for the submission- could you just make sure the linting check passes? Thanks! |
ty both, sorry i got the js fmt but missed py. also tweaked log messages. |
…ion as well Co-authored-by: Luciana Abud <[email protected]>
48070a4
to
43e8e46
Compare
This should fix the issues #190 and #259 .
Implements a new variable for
cwd
,${filePyproject}
${nearestConfig}
. Ifcwd
is set as such, then the lsp will search upwards from the current file for apyproject.toml
ormypy.ini
. If found, mypy will be run in its directory. If not found, it will run inworkspaceFolder
.Questions:
that variable is ugly, should I call it something else?->${nearestConfig}
mypy.ini?done)