From c9f85963578a476dddf9c6e471b9e76e39885a3c Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 28 Mar 2024 19:36:07 +0530 Subject: [PATCH] Switch to LSP for mypy --- kitty/boss.py | 2 ++ mypy-editor-integration | 19 ------------------- pyproject.toml | 5 +++++ session.vim | 10 ---------- 4 files changed, 7 insertions(+), 29 deletions(-) delete mode 100755 mypy-editor-integration diff --git a/kitty/boss.py b/kitty/boss.py index 2489e2fa2..956e98d5d 100644 --- a/kitty/boss.py +++ b/kitty/boss.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # License: GPL v3 Copyright: 2016, Kovid Goyal +# Imports {{{ import atexit import base64 import json @@ -154,6 +155,7 @@ from .window import CommandOutput, CwdRequest, Window if TYPE_CHECKING: from .rc.base import ResponseType +# }}} RCResponse = Union[Dict[str, Any], None, AsyncResponse] diff --git a/mypy-editor-integration b/mypy-editor-integration deleted file mode 100755 index df7d6915f..000000000 --- a/mypy-editor-integration +++ /dev/null @@ -1,19 +0,0 @@ -#!/usr/bin/env python - -import os -import subprocess -import sys - -base = os.path.dirname(os.path.abspath(__file__)) -files = [os.path.relpath(x, base) for x in sys.argv[1:] if not x.startswith('-')] -if not files: - raise SystemExit(subprocess.Popen(['mypy'] + sys.argv[1:]).wait()) - -output = subprocess.run('dmypy run -- --follow-imports=error --show-column-numbers --no-color-output'.split(), stdout=subprocess.PIPE).stdout -q = files[0] + ':' -rc = 0 -for line in output.decode('utf-8').splitlines(): - if line.startswith(q): - print(line) - rc = 1 -raise SystemExit(rc) diff --git a/pyproject.toml b/pyproject.toml index 97b041925..877f13b85 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -16,6 +16,11 @@ disallow_incomplete_defs = true strict = true no_implicit_reexport = true +[tool.pylsp-mypy] +enabled = true +dmypy = true +report_progress = true + [tool.ruff] line-length = 160 target-version = 'py38' diff --git a/session.vim b/session.vim index 6d946b79a..6f27d844c 100644 --- a/session.vim +++ b/session.vim @@ -1,15 +1,5 @@ " Scan the following dirs recursively for tags let g:project_tags_dirs = ['kitty', 'kittens', 'tools'] -if exists('g:ale_linters') - let g:ale_linters['python'] = ['mypy', 'ruff'] -else - let g:ale_linters = {'python': ['mypy', 'ruff']} -endif -let g:ale_python_mypy_executable = './mypy-editor-integration' -let g:ale_fixers = { -\ "python": ["ruff"], -\} -autocmd FileType python noremap \i :ALEFix set wildignore+==template.py set wildignore+=tags set expandtab