Skip to content

ZubanServer

Base classes

Name Children Inherits
LSPServerInfo
anyenv.lsp_servers._base
Static configuration for an LSP server.

⋔ Inheritance diagram

graph TD
  1831919433["python_lsps.ZubanServer"]
  514706066["_base.LSPServerInfo"]
  2751680898["builtins.object"]
  514706066 --> 1831919433
  2751680898 --> 514706066

🛈 DocStrings

Bases: LSPServerInfo

Zuban type checker with mypy-compatible text output parsing.

Source code in src/anyenv/lsp_servers/_servers/python_lsps.py
@dataclass
class ZubanServer(LSPServerInfo):
    """Zuban type checker with mypy-compatible text output parsing."""

    def _parse_text_diagnostics(self, output: str) -> list[Diagnostic]:
        """Parse zuban mypy-compatible text output.

        Format: file.py:line:column: severity: message  [error-code]
        """
        import re

        diagnostics: list[Diagnostic] = []
        # Pattern: path:line:col: severity: message  [code]
        pattern = re.compile(
            r"^(.+?):(\d+):(\d+): (error|warning|note): (.+?)(?:\s+\[([^\]]+)\])?$"
        )

        for line in output.strip().splitlines():
            line = line.strip()
            if match := pattern.match(line):
                file_path, line_no, col, severity, message, code = match.groups()
                diagnostics.append(
                    Diagnostic(
                        file=file_path,
                        line=int(line_no),
                        column=int(col),
                        severity=severity_from_string(severity),
                        message=message.strip(),
                        code=code,
                        source=self.id,
                    )
                )

        return diagnostics

    def parse_diagnostics(self, stdout: str, stderr: str) -> list[Diagnostic]:
        """Parse diagnostics from CLI output."""
        return self._parse_text_diagnostics(stdout or stderr)

parse_diagnostics

parse_diagnostics(stdout: str, stderr: str) -> list[Diagnostic]

Parse diagnostics from CLI output.

Source code in src/anyenv/lsp_servers/_servers/python_lsps.py
def parse_diagnostics(self, stdout: str, stderr: str) -> list[Diagnostic]:
    """Parse diagnostics from CLI output."""
    return self._parse_text_diagnostics(stdout or stderr)

:fa-brands-github: Show source on GitHub