Skip to content

Commit 8cb6bca

Browse files
authored
When cwd config option is ${nearestConfig}, look for all of mypy.ini, .mypy.ini, pyproject.toml, setup.cfg (microsoft#357)
* When cwd config option is ${nearestConfig}, look for all of mypy.ini, .mypy.ini, pyproject.toml, setup.cfg - Related: microsoft#356 * remove unnecessary global var to pass lint check
1 parent 2bed8ab commit 8cb6bca

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ There are several settings you can configure to customize the behavior of this e
4747
<tr>
4848
<td>mypy-type-checker.cwd</td>
4949
<td><code>${workspaceFolder}</code></td>
50-
<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>${nearestConfig}</code> to use the nearest parent/ancestor folder which contains a <code>pyproject.toml</code> or a <code>mypy.ini</code> file.
50+
<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>${nearestConfig}</code> to use the nearest parent/ancestor folder which contains a <code>mypy.ini</code>, <code>.mypy.ini</code>, <code>pyproject.toml</code>, or <code>setup.cfg</code> file.
5151
</td>
5252
</tr>
5353
<tr>

bundled/tool/lsp_server.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -659,7 +659,7 @@ def get_cwd(settings: Dict[str, Any], document: Optional[workspace.Document]) ->
659659
workspaceFolder = pathlib.Path(settings["workspaceFS"])
660660
candidate = pathlib.Path(document.path).parent
661661
# check if pyproject exists
662-
check_for = ["pyproject.toml", "mypy.ini"]
662+
check_for = ["mypy.ini", ".mypy.ini", "pyproject.toml", "setup.cfg"]
663663
# until we leave the workspace
664664
while candidate.is_relative_to(workspaceFolder):
665665
for n in check_for:

package.nls.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"extension.description": "Type checking support for Python files using Mypy.",
33
"command.restartServer": "Restart Server",
44
"settings.args.description": "Arguments passed to Mypy to enable type checking on Python files. Each argument should be provided as a separate string in the array. \n Example: \n `\"mypy-type-checker.args\" : [\"--config-file=<file>\"]`",
5-
"settings.cwd.description": "Sets the current working directory used to lint Python files with Mypy. By default, it uses the root directory of the workspace `${workspaceFolder}`. You can set it to `${fileDirname}` to use the parent folder of the file being linted as the working directory for Mypy. You can also set it to `${nearestConfig}` to use the nearest parent/ancestor folder which contains a `pyproject.toml` or a `mypy.ini` file.",
5+
"settings.cwd.description": "Sets the current working directory used to lint Python files with Mypy. By default, it uses the root directory of the workspace `${workspaceFolder}`. You can set it to `${fileDirname}` to use the parent folder of the file being linted as the working directory for Mypy. You can also set it to `${nearestConfig}` to use the nearest parent/ancestor folder which contains a `mypy.ini`, `.mypy.ini`, `pyproject.toml`, or `setup.cfg` file.",
66
"settings.severity.description": "Mapping of Mypy's message types to VS Code's diagnostic severity levels as displayed in the Problems window. You can also use it to override specific Mypy error codes. <br>For example: `{\"error\": \"Error\", \"note\": \"Information\", \"name-defined\": \"Warning\" }`",
77
"settings.path.description": "Path or command to be used by the extension to type check Python files with Mypy. Accepts an array of a single or multiple strings. If passing a command, each argument should be provided as a separate string in the array. If set to `[\"mypy\"]`, it will use the version of Mypy available in the `PATH` environment variable. <br> Note: Using this option may slowdown type checking. \n Examples: \n- `[\"~/global_env/mypy\"]` \n- `[\"conda\", \"run\", \"-n\", \"lint_env\", \"python\", \"-m\", \"mypy\"]`",
88
"settings.ignorePatterns.description": "Configure [glob patterns](https://docs.python.org/3/library/fnmatch.html) as supported by the fnmatch Python library to exclude files or folders from being linted with Mypy.",

0 commit comments

Comments
 (0)