Skip to content

Commit

Permalink
Closes #36
Browse files Browse the repository at this point in the history
  • Loading branch information
Richardk2n committed Jul 2, 2022
1 parent 478562c commit b99622b
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/psf/black
rev: 21.6b0
rev: 22.3.0
hooks:
- id: black
- repo: https://github.com/Lucas-C/pre-commit-hooks-markup
Expand Down
2 changes: 1 addition & 1 deletion pylsp_mypy/_version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.5.8"
__version__ = "0.6.0"
16 changes: 12 additions & 4 deletions pylsp_mypy/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,14 @@
# https://github.com/python-lsp/python-lsp-server/blob/v1.0.1/pylsp/plugins/pylint_lint.py#L55-L62
last_diagnostics: Dict[str, List[Dict[str, Any]]] = collections.defaultdict(list)

# Windows started opening opening a cmd-like window for every subprocess call
# This flag prevents that.
# This flag is new in python 3.7
# THis flag only exists on Windows
windows_flag: Dict[str, int] = (
{"startupinfo": subprocess.CREATE_NO_WINDOW} if os.name == "nt" else {} # type: ignore
)


def parse_line(line: str, document: Optional[Document] = None) -> Optional[Dict[str, Any]]:
"""
Expand Down Expand Up @@ -214,7 +222,7 @@ def pylsp_lint(
# -> use mypy on path
log.info("executing mypy args = %s on path", args)
completed_process = subprocess.run(
["mypy", *args], stdout=subprocess.PIPE, stderr=subprocess.PIPE
["mypy", *args], stdout=subprocess.PIPE, stderr=subprocess.PIPE, **windows_flag
)
report = completed_process.stdout.decode()
errors = completed_process.stderr.decode()
Expand All @@ -234,15 +242,15 @@ def pylsp_lint(
# dmypy exists on path
# -> use mypy on path
completed_process = subprocess.run(
["dmypy", *apply_overrides(args, overrides)], stderr=subprocess.PIPE
["dmypy", *apply_overrides(args, overrides)], stderr=subprocess.PIPE, **windows_flag
)
_err = completed_process.stderr.decode()
_status = completed_process.returncode
if _status != 0:
log.info(
"restarting dmypy from status: %s message: %s via path", _status, _err.strip()
)
subprocess.run(["dmypy", "kill"])
subprocess.run(["dmypy", "kill"], **windows_flag)
else:
# dmypy does not exist on path, but must exist in the env pylsp-mypy is installed in
# -> use dmypy via api
Expand All @@ -261,7 +269,7 @@ def pylsp_lint(
# -> use mypy on path
log.info("dmypy run args = %s via path", args)
completed_process = subprocess.run(
["dmypy", *args], stdout=subprocess.PIPE, stderr=subprocess.PIPE
["dmypy", *args], stdout=subprocess.PIPE, stderr=subprocess.PIPE, **windows_flag
)
report = completed_process.stdout.decode()
errors = completed_process.stderr.decode()
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ live_mode = true
strict = true

[tool.mypy]
python_version = "3.6"
python_version = "3.7"

[[tool.mypy.overrides]]
module = "pylsp.*"
Expand Down
3 changes: 1 addition & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,13 @@ classifiers =
Intended Audience :: Developers
Topic :: Software Development
License :: OSI Approved :: MIT License
Programming Language :: Python :: 3.6
Programming Language :: Python :: 3.7
Programming Language :: Python :: 3.8
Programming Language :: Python :: 3.9
Programming Language :: Python :: 3.10

[options]
python_requires = >= 3.6
python_requires = >= 3.7
packages = find:
install_requires =
python-lsp-server
Expand Down

0 comments on commit b99622b

Please sign in to comment.