Skip to content
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

Update extension to support the latest version of tach #9

Merged
merged 7 commits into from
Nov 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
@@ -10,7 +10,6 @@
],
"rules": {
"@typescript-eslint/naming-convention": "warn",
"@typescript-eslint/semi": "warn",
"curly": "warn",
"eqeqeq": "warn",
"no-throw-literal": "warn",
14 changes: 6 additions & 8 deletions bundled/tool/lsp_server.py
Original file line number Diff line number Diff line change
@@ -10,12 +10,10 @@
import pathlib
import sys
import traceback
from typing import Any
from typing import TYPE_CHECKING, Any

try:
from tach.check import CheckResult
except ImportError:
pass
if TYPE_CHECKING:
from tach.extension import CheckResult


# **********************************************************
@@ -52,7 +50,7 @@ def update_sys_path(path_to_add: str, strategy: str) -> None:
MAX_WORKERS = 5
# TODO: Centralize version
LSP_SERVER = server.LanguageServer(
name="Tach", version="0.10.3", max_workers=MAX_WORKERS
name="Tach", version="0.14.3", max_workers=MAX_WORKERS
)


@@ -113,7 +111,7 @@ def _parse_boundary_errors(checked_result: CheckResult | None, uri):
return []
diagnostics = []
for err in checked_result.errors:
if str(err.file_path) in uri and err.error_info.exception_message:
if str(err.file_path) in uri and err.error_info.to_pystring():
start = lsp.Position(
line=err.line_number - 1,
character=0,
@@ -124,7 +122,7 @@ def _parse_boundary_errors(checked_result: CheckResult | None, uri):
start=start,
end=end,
),
message=err.error_info.exception_message,
message=err.error_info.to_pystring(),
severity=lsp.DiagnosticSeverity.Error,
source=TOOL_MODULE,
)
19 changes: 6 additions & 13 deletions bundled/tool/tach_util.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
from __future__ import annotations
from typing import TYPE_CHECKING

from tach.check import CheckResult, check
from tach.extension import check
from tach.parsing.config import parse_project_config
from tach.cli import parse_arguments
from tach.colors import BCOLORS
from tach.constants import CONFIG_FILE_NAME
from tach.errors import TachSetupError
from tach.filesystem import find_project_config_root
from tach.parsing import parse_project_config

if TYPE_CHECKING:
from tach.extension import CheckResult


def run_tach_check(argv: list[str], path: str):
@@ -29,15 +33,4 @@ def run_tach_check(argv: list[str], path: str):
checked_result: CheckResult = check(
project_root=root, project_config=project_config, exclude_paths=exclude_paths
)
for boundary_error in checked_result.errors:
# Hack for now - update error message displayed to user
error_info = boundary_error.error_info
if (
not error_info.exception_message
and boundary_error.error_info.is_dependency_error
):
error_info.exception_message = (
f"Cannot import '{boundary_error.import_mod_path}'. "
f"Module '{error_info.source_module}' cannot depend on '{error_info.invalid_module}'."
)
return checked_result
2 changes: 1 addition & 1 deletion dev-requirements.txt
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@ pip==24.0
pytest==8.2.2
pyright==1.1.377
ruff==0.4.1
tach==0.10.3
tach==0.14.3
# LSP
pygls==1.3.1
nox==2024.4.15
Loading