Skip to content

language_formatters

Class info

Classes

Name Children Inherits
AirFormatter
anyenv.language_formatters._r
R formatter using air.
    BiomeFormatter
    anyenv.language_formatters._web
    TypeScript/JavaScript/JSON formatter using biome.
      ClangFormatFormatter
      anyenv.language_formatters._systems
      C/C++ formatter using clang-format.
        ElixirFormatter
        anyenv.language_formatters._elixir
        Elixir formatter using mix format.
          FormatAndLintResult
          anyenv.language_formatters._base
          Combined result of format and lint operations.
            FormatResult
            anyenv.language_formatters._base
            Result of a formatting operation.
              FormatterRegistry
              anyenv.language_formatters._registry
              Registry for language formatters.
                GoFormatter
                anyenv.language_formatters._systems
                Go formatter using gofmt.
                  HtmlBeautifierFormatter
                  anyenv.language_formatters._web
                  ERB formatter using htmlbeautifier.
                    KtlintFormatter
                    anyenv.language_formatters._jvm
                    Kotlin formatter using ktlint.
                      LanguageFormatter
                      anyenv.language_formatters._base
                      Abstract base class for language-specific formatters.
                      LintResult
                      anyenv.language_formatters._base
                      Result of a linting operation.
                        PrettierFormatter
                        anyenv.language_formatters._web
                        Multi-language formatter using prettier.
                          PythonRuffFormatter
                          anyenv.language_formatters._python
                          Python formatter using ruff directly.
                            PythonUvFormatter
                            anyenv.language_formatters._python
                            Python formatter using uv to run ruff.
                              RubocopFormatter
                              anyenv.language_formatters._ruby
                              Ruby formatter using rubocop.
                                RustFormatter
                                anyenv.language_formatters._systems
                                Rust formatter using rustfmt and clippy.
                                  StandardRBFormatter
                                  anyenv.language_formatters._ruby
                                  Ruby formatter using standardrb.
                                    TOMLFormatter
                                    anyenv.language_formatters._toml
                                    TOML formatter using tombi.
                                      ZigFormatter
                                      anyenv.language_formatters._systems
                                      Zig formatter using zig fmt.

                                        🛈 DocStrings

                                        Language formatters with anyenv execution environments.

                                        AirFormatter

                                        Bases: LanguageFormatter

                                        R formatter using air.

                                        Source code in src/anyenv/language_formatters/_r.py
                                        class AirFormatter(LanguageFormatter):
                                            """R formatter using air."""
                                        
                                            @property
                                            def name(self) -> str:
                                                return "R"
                                        
                                            @property
                                            def command(self) -> str:
                                                return "air"
                                        
                                            @property
                                            def extensions(self) -> list[str]:
                                                return [".R", ".r"]
                                        
                                            @property
                                            def pygments_lexers(self) -> list[str]:
                                                return ["r", "rlang", "splus"]
                                        
                                            async def format(self, path: Path) -> FormatResult:
                                                cmd = ["air", "format", str(path)]
                                                success, stdout, stderr, duration, error_type = await self._execute_command(cmd)
                                                return FormatResult(
                                                    success=success,
                                                    output=stdout,
                                                    errors=stderr,
                                                    formatted=success,
                                                    duration=duration,
                                                    error_type=error_type,
                                                )
                                        
                                            async def lint(self, path: Path, fix: bool = False) -> LintResult:
                                                cmd = ["air", "format", "--check", str(path)]
                                                success, stdout, stderr, duration, error_type = await self._execute_command(cmd)
                                                return LintResult(
                                                    success=success,
                                                    output=stdout,
                                                    errors=stderr,
                                                    duration=duration,
                                                    error_type=error_type,
                                                )
                                        

                                        BiomeFormatter

                                        Bases: LanguageFormatter

                                        TypeScript/JavaScript/JSON formatter using biome.

                                        Source code in src/anyenv/language_formatters/_web.py
                                        class BiomeFormatter(LanguageFormatter):
                                            """TypeScript/JavaScript/JSON formatter using biome."""
                                        
                                            @property
                                            def name(self) -> str:
                                                return "TypeScript"
                                        
                                            @property
                                            def command(self) -> str:
                                                return "biome"
                                        
                                            @property
                                            def extensions(self) -> list[str]:
                                                return [".ts", ".tsx", ".js", ".jsx", ".json", ".jsonc"]
                                        
                                            @property
                                            def pygments_lexers(self) -> list[str]:
                                                return ["typescript", "ts", "javascript", "js", "jsx", "tsx", "json"]
                                        
                                            async def format(self, path: Path) -> FormatResult:
                                                cmd = ["biome", "format", "--write", str(path)]
                                                success, stdout, stderr, duration, error_type = await self._execute_command(cmd)
                                                return FormatResult(
                                                    success=success,
                                                    output=stdout,
                                                    errors=stderr,
                                                    formatted=success,
                                                    duration=duration,
                                                    error_type=error_type,
                                                )
                                        
                                            async def lint(self, path: Path, fix: bool = False) -> LintResult:
                                                cmd = ["biome", "lint"]
                                                if fix:
                                                    cmd.append("--write")
                                                cmd.append(str(path))
                                                success, stdout, stderr, duration, error_type = await self._execute_command(cmd)
                                                return LintResult(
                                                    success=success,
                                                    output=stdout,
                                                    errors=stderr,
                                                    duration=duration,
                                                    error_type=error_type,
                                                )
                                        

                                        ClangFormatFormatter

                                        Bases: LanguageFormatter

                                        C/C++ formatter using clang-format.

                                        Source code in src/anyenv/language_formatters/_systems.py
                                        class ClangFormatFormatter(LanguageFormatter):
                                            """C/C++ formatter using clang-format."""
                                        
                                            @property
                                            def name(self) -> str:
                                                return "C/C++"
                                        
                                            @property
                                            def command(self) -> str:
                                                return "clang-format"
                                        
                                            @property
                                            def extensions(self) -> list[str]:
                                                return [".c", ".cpp", ".cc", ".cxx", ".h", ".hpp", ".hxx", ".ino"]
                                        
                                            @property
                                            def pygments_lexers(self) -> list[str]:
                                                return ["c", "cpp", "c++", "cxx"]
                                        
                                            async def format(self, path: Path) -> FormatResult:
                                                cmd = ["clang-format", "-i", str(path)]
                                                success, stdout, stderr, duration, error_type = await self._execute_command(cmd)
                                                return FormatResult(
                                                    success=success,
                                                    output=stdout,
                                                    errors=stderr,
                                                    formatted=success,
                                                    duration=duration,
                                                    error_type=error_type,
                                                )
                                        
                                            async def lint(self, path: Path, fix: bool = False) -> LintResult:
                                                # clang-format --dry-run --Werror for lint-like behavior
                                                cmd = ["clang-format", "--dry-run", "--Werror", str(path)]
                                                success, stdout, stderr, duration, error_type = await self._execute_command(cmd)
                                                return LintResult(
                                                    success=success,
                                                    output=stdout,
                                                    errors=stderr,
                                                    duration=duration,
                                                    error_type=error_type,
                                                )
                                        

                                        ElixirFormatter

                                        Bases: LanguageFormatter

                                        Elixir formatter using mix format.

                                        Source code in src/anyenv/language_formatters/_elixir.py
                                        class ElixirFormatter(LanguageFormatter):
                                            """Elixir formatter using mix format."""
                                        
                                            @property
                                            def name(self) -> str:
                                                return "Elixir"
                                        
                                            @property
                                            def command(self) -> str:
                                                return "mix"
                                        
                                            @property
                                            def extensions(self) -> list[str]:
                                                return [".ex", ".exs", ".eex", ".heex", ".leex", ".neex", ".sface"]
                                        
                                            @property
                                            def pygments_lexers(self) -> list[str]:
                                                return ["elixir", "ex", "exs", "eex", "heex"]
                                        
                                            async def format(self, path: Path) -> FormatResult:
                                                cmd = ["mix", "format", str(path)]
                                                success, stdout, stderr, duration, error_type = await self._execute_command(cmd)
                                                return FormatResult(
                                                    success=success,
                                                    output=stdout,
                                                    errors=stderr,
                                                    formatted=success,
                                                    duration=duration,
                                                    error_type=error_type,
                                                )
                                        
                                            async def lint(self, path: Path, fix: bool = False) -> LintResult:
                                                cmd = ["mix", "format", "--check-formatted", str(path)]
                                                success, stdout, stderr, duration, error_type = await self._execute_command(cmd)
                                                return LintResult(
                                                    success=success,
                                                    output=stdout,
                                                    errors=stderr,
                                                    duration=duration,
                                                    error_type=error_type,
                                                )
                                        

                                        FormatAndLintResult dataclass

                                        Combined result of format and lint operations.

                                        Source code in src/anyenv/language_formatters/_base.py
                                        @dataclass
                                        class FormatAndLintResult:
                                            """Combined result of format and lint operations."""
                                        
                                            format_result: FormatResult
                                            lint_result: LintResult
                                        
                                            @property
                                            def success(self) -> bool:
                                                """Overall success if both operations succeeded."""
                                                return self.format_result.success and self.lint_result.success
                                        
                                            @property
                                            def total_duration(self) -> float:
                                                """Total duration of both operations."""
                                                return self.format_result.duration + self.lint_result.duration
                                        

                                        success property

                                        success: bool
                                        

                                        Overall success if both operations succeeded.

                                        total_duration property

                                        total_duration: float
                                        

                                        Total duration of both operations.

                                        FormatResult dataclass

                                        Result of a formatting operation.

                                        Source code in src/anyenv/language_formatters/_base.py
                                        @dataclass
                                        class FormatResult:
                                            """Result of a formatting operation."""
                                        
                                            success: bool
                                            output: str
                                            errors: str
                                            formatted: bool = False
                                            duration: float = 0.0
                                            error_type: str | None = None
                                        

                                        FormatterRegistry

                                        Registry for language formatters.

                                        Source code in src/anyenv/language_formatters/_registry.py
                                        class FormatterRegistry:
                                            """Registry for language formatters."""
                                        
                                            def __init__(
                                                self,
                                                execution_env: ExecutionEnvironment | ExecutionEnvironmentStr = "local",
                                            ) -> None:
                                                """Initialize registry with default execution environment.
                                        
                                                Args:
                                                    execution_env: Default execution environment for all formatters
                                                """
                                                self.formatters: list[LanguageFormatter] = []
                                                self.default_execution_env: ExecutionEnvironment | ExecutionEnvironmentStr = execution_env
                                        
                                            def register(self, formatter: LanguageFormatter) -> None:
                                                """Register a formatter."""
                                                self.formatters.append(formatter)
                                        
                                            def register_default_formatters(self) -> None:
                                                """Register all default formatters with the registry's execution environment."""
                                                from anyenv.language_formatters._elixir import ElixirFormatter
                                                from anyenv.language_formatters._jvm import KtlintFormatter
                                                from anyenv.language_formatters._python import PythonUvFormatter
                                                from anyenv.language_formatters._r import AirFormatter
                                                from anyenv.language_formatters._ruby import RubocopFormatter
                                                from anyenv.language_formatters._systems import (
                                                    ClangFormatFormatter,
                                                    GoFormatter,
                                                    RustFormatter,
                                                    ZigFormatter,
                                                )
                                                from anyenv.language_formatters._toml import TOMLFormatter
                                                from anyenv.language_formatters._web import (
                                                    BiomeFormatter,
                                                    HtmlBeautifierFormatter,
                                                    PrettierFormatter,
                                                )
                                        
                                                self.register(PythonUvFormatter(self.default_execution_env))
                                                self.register(TOMLFormatter(self.default_execution_env))
                                                self.register(BiomeFormatter(self.default_execution_env))
                                                self.register(PrettierFormatter(self.default_execution_env))
                                                self.register(RustFormatter(self.default_execution_env))
                                                self.register(GoFormatter(self.default_execution_env))
                                                self.register(ElixirFormatter(self.default_execution_env))
                                                self.register(ZigFormatter(self.default_execution_env))
                                                self.register(ClangFormatFormatter(self.default_execution_env))
                                                self.register(KtlintFormatter(self.default_execution_env))
                                                self.register(RubocopFormatter(self.default_execution_env))
                                                self.register(HtmlBeautifierFormatter(self.default_execution_env))
                                                self.register(AirFormatter(self.default_execution_env))
                                        
                                            def get_formatter(self, path: Path) -> LanguageFormatter | None:
                                                """Get formatter for given file path."""
                                                return next((f for f in self.formatters if f.can_handle(path)), None)
                                        
                                            def get_formatter_by_language(self, language: str) -> LanguageFormatter | None:
                                                """Get formatter for given language name (pygments lexer)."""
                                                return next((f for f in self.formatters if f.can_handle_language(language)), None)
                                        
                                            def get_formatter_by_command(self, command: str) -> LanguageFormatter | None:
                                                """Get formatter by CLI command name."""
                                                return next((f for f in self.formatters if f.command == command), None)
                                        
                                            def get_available_formatters(self) -> list[LanguageFormatter]:
                                                """Get all formatters whose commands are available on the system."""
                                                return [f for f in self.formatters if f.is_available()]
                                        
                                            def detect_language_from_content(self, content: str) -> str | None:
                                                """Detect language from content using pygments (if available)."""
                                                try:
                                                    from pygments.lexers import guess_lexer
                                        
                                                    lexer = guess_lexer(content)
                                                    return lexer.name.lower()
                                                except ImportError:
                                                    return None
                                                except Exception:  # noqa: BLE001
                                                    return None
                                        
                                            def get_supported_extensions(self) -> list[str]:
                                                """Get all supported file extensions."""
                                                return sorted({e for formatter in self.formatters for e in formatter.extensions})
                                        

                                        __init__

                                        __init__(execution_env: ExecutionEnvironment | ExecutionEnvironmentStr = 'local') -> None
                                        

                                        Initialize registry with default execution environment.

                                        Parameters:

                                        Name Type Description Default
                                        execution_env ExecutionEnvironment | ExecutionEnvironmentStr

                                        Default execution environment for all formatters

                                        'local'
                                        Source code in src/anyenv/language_formatters/_registry.py
                                        def __init__(
                                            self,
                                            execution_env: ExecutionEnvironment | ExecutionEnvironmentStr = "local",
                                        ) -> None:
                                            """Initialize registry with default execution environment.
                                        
                                            Args:
                                                execution_env: Default execution environment for all formatters
                                            """
                                            self.formatters: list[LanguageFormatter] = []
                                            self.default_execution_env: ExecutionEnvironment | ExecutionEnvironmentStr = execution_env
                                        

                                        detect_language_from_content

                                        detect_language_from_content(content: str) -> str | None
                                        

                                        Detect language from content using pygments (if available).

                                        Source code in src/anyenv/language_formatters/_registry.py
                                        def detect_language_from_content(self, content: str) -> str | None:
                                            """Detect language from content using pygments (if available)."""
                                            try:
                                                from pygments.lexers import guess_lexer
                                        
                                                lexer = guess_lexer(content)
                                                return lexer.name.lower()
                                            except ImportError:
                                                return None
                                            except Exception:  # noqa: BLE001
                                                return None
                                        

                                        get_available_formatters

                                        get_available_formatters() -> list[LanguageFormatter]
                                        

                                        Get all formatters whose commands are available on the system.

                                        Source code in src/anyenv/language_formatters/_registry.py
                                        def get_available_formatters(self) -> list[LanguageFormatter]:
                                            """Get all formatters whose commands are available on the system."""
                                            return [f for f in self.formatters if f.is_available()]
                                        

                                        get_formatter

                                        get_formatter(path: Path) -> LanguageFormatter | None
                                        

                                        Get formatter for given file path.

                                        Source code in src/anyenv/language_formatters/_registry.py
                                        def get_formatter(self, path: Path) -> LanguageFormatter | None:
                                            """Get formatter for given file path."""
                                            return next((f for f in self.formatters if f.can_handle(path)), None)
                                        

                                        get_formatter_by_command

                                        get_formatter_by_command(command: str) -> LanguageFormatter | None
                                        

                                        Get formatter by CLI command name.

                                        Source code in src/anyenv/language_formatters/_registry.py
                                        def get_formatter_by_command(self, command: str) -> LanguageFormatter | None:
                                            """Get formatter by CLI command name."""
                                            return next((f for f in self.formatters if f.command == command), None)
                                        

                                        get_formatter_by_language

                                        get_formatter_by_language(language: str) -> LanguageFormatter | None
                                        

                                        Get formatter for given language name (pygments lexer).

                                        Source code in src/anyenv/language_formatters/_registry.py
                                        def get_formatter_by_language(self, language: str) -> LanguageFormatter | None:
                                            """Get formatter for given language name (pygments lexer)."""
                                            return next((f for f in self.formatters if f.can_handle_language(language)), None)
                                        

                                        get_supported_extensions

                                        get_supported_extensions() -> list[str]
                                        

                                        Get all supported file extensions.

                                        Source code in src/anyenv/language_formatters/_registry.py
                                        def get_supported_extensions(self) -> list[str]:
                                            """Get all supported file extensions."""
                                            return sorted({e for formatter in self.formatters for e in formatter.extensions})
                                        

                                        register

                                        register(formatter: LanguageFormatter) -> None
                                        

                                        Register a formatter.

                                        Source code in src/anyenv/language_formatters/_registry.py
                                        def register(self, formatter: LanguageFormatter) -> None:
                                            """Register a formatter."""
                                            self.formatters.append(formatter)
                                        

                                        register_default_formatters

                                        register_default_formatters() -> None
                                        

                                        Register all default formatters with the registry's execution environment.

                                        Source code in src/anyenv/language_formatters/_registry.py
                                        def register_default_formatters(self) -> None:
                                            """Register all default formatters with the registry's execution environment."""
                                            from anyenv.language_formatters._elixir import ElixirFormatter
                                            from anyenv.language_formatters._jvm import KtlintFormatter
                                            from anyenv.language_formatters._python import PythonUvFormatter
                                            from anyenv.language_formatters._r import AirFormatter
                                            from anyenv.language_formatters._ruby import RubocopFormatter
                                            from anyenv.language_formatters._systems import (
                                                ClangFormatFormatter,
                                                GoFormatter,
                                                RustFormatter,
                                                ZigFormatter,
                                            )
                                            from anyenv.language_formatters._toml import TOMLFormatter
                                            from anyenv.language_formatters._web import (
                                                BiomeFormatter,
                                                HtmlBeautifierFormatter,
                                                PrettierFormatter,
                                            )
                                        
                                            self.register(PythonUvFormatter(self.default_execution_env))
                                            self.register(TOMLFormatter(self.default_execution_env))
                                            self.register(BiomeFormatter(self.default_execution_env))
                                            self.register(PrettierFormatter(self.default_execution_env))
                                            self.register(RustFormatter(self.default_execution_env))
                                            self.register(GoFormatter(self.default_execution_env))
                                            self.register(ElixirFormatter(self.default_execution_env))
                                            self.register(ZigFormatter(self.default_execution_env))
                                            self.register(ClangFormatFormatter(self.default_execution_env))
                                            self.register(KtlintFormatter(self.default_execution_env))
                                            self.register(RubocopFormatter(self.default_execution_env))
                                            self.register(HtmlBeautifierFormatter(self.default_execution_env))
                                            self.register(AirFormatter(self.default_execution_env))
                                        

                                        GoFormatter

                                        Bases: LanguageFormatter

                                        Go formatter using gofmt.

                                        Source code in src/anyenv/language_formatters/_systems.py
                                        class GoFormatter(LanguageFormatter):
                                            """Go formatter using gofmt."""
                                        
                                            @property
                                            def name(self) -> str:
                                                return "Go"
                                        
                                            @property
                                            def command(self) -> str:
                                                return "gofmt"
                                        
                                            @property
                                            def extensions(self) -> list[str]:
                                                return [".go"]
                                        
                                            @property
                                            def pygments_lexers(self) -> list[str]:
                                                return ["go", "golang"]
                                        
                                            async def format(self, path: Path) -> FormatResult:
                                                cmd = ["gofmt", "-w", str(path)]
                                                success, stdout, stderr, duration, error_type = await self._execute_command(cmd)
                                                return FormatResult(
                                                    success=success,
                                                    output=stdout,
                                                    errors=stderr,
                                                    formatted=success,
                                                    duration=duration,
                                                    error_type=error_type,
                                                )
                                        
                                            async def lint(self, path: Path, fix: bool = False) -> LintResult:
                                                # gofmt is format-only, use go vet for basic linting
                                                cmd = ["go", "vet", str(path)]
                                                success, stdout, stderr, duration, error_type = await self._execute_command(cmd)
                                                return LintResult(
                                                    success=success,
                                                    output=stdout,
                                                    errors=stderr,
                                                    duration=duration,
                                                    error_type=error_type,
                                                )
                                        

                                        HtmlBeautifierFormatter

                                        Bases: LanguageFormatter

                                        ERB formatter using htmlbeautifier.

                                        Source code in src/anyenv/language_formatters/_web.py
                                        class HtmlBeautifierFormatter(LanguageFormatter):
                                            """ERB formatter using htmlbeautifier."""
                                        
                                            @property
                                            def name(self) -> str:
                                                return "ERB"
                                        
                                            @property
                                            def command(self) -> str:
                                                return "htmlbeautifier"
                                        
                                            @property
                                            def extensions(self) -> list[str]:
                                                return [".erb", ".html.erb"]
                                        
                                            @property
                                            def pygments_lexers(self) -> list[str]:
                                                return ["erb", "rhtml"]
                                        
                                            async def format(self, path: Path) -> FormatResult:
                                                cmd = ["htmlbeautifier", str(path)]
                                                success, stdout, stderr, duration, error_type = await self._execute_command(cmd)
                                                return FormatResult(
                                                    success=success,
                                                    output=stdout,
                                                    errors=stderr,
                                                    formatted=success,
                                                    duration=duration,
                                                    error_type=error_type,
                                                )
                                        
                                            async def lint(self, path: Path, fix: bool = False) -> LintResult:
                                                # htmlbeautifier is format-only, no lint mode
                                                return LintResult(
                                                    success=True,
                                                    output="",
                                                    errors="",
                                                    duration=0.0,
                                                    error_type=None,
                                                )
                                        

                                        KtlintFormatter

                                        Bases: LanguageFormatter

                                        Kotlin formatter using ktlint.

                                        Source code in src/anyenv/language_formatters/_jvm.py
                                        class KtlintFormatter(LanguageFormatter):
                                            """Kotlin formatter using ktlint."""
                                        
                                            @property
                                            def name(self) -> str:
                                                return "Kotlin"
                                        
                                            @property
                                            def command(self) -> str:
                                                return "ktlint"
                                        
                                            @property
                                            def extensions(self) -> list[str]:
                                                return [".kt", ".kts"]
                                        
                                            @property
                                            def pygments_lexers(self) -> list[str]:
                                                return ["kotlin", "kt"]
                                        
                                            async def format(self, path: Path) -> FormatResult:
                                                cmd = ["ktlint", "--format", str(path)]
                                                success, stdout, stderr, duration, error_type = await self._execute_command(cmd)
                                                return FormatResult(
                                                    success=success,
                                                    output=stdout,
                                                    errors=stderr,
                                                    formatted=success,
                                                    duration=duration,
                                                    error_type=error_type,
                                                )
                                        
                                            async def lint(self, path: Path, fix: bool = False) -> LintResult:
                                                cmd = ["ktlint"]
                                                if fix:
                                                    cmd.append("--format")
                                                cmd.append(str(path))
                                                success, stdout, stderr, duration, error_type = await self._execute_command(cmd)
                                                return LintResult(
                                                    success=success,
                                                    output=stdout,
                                                    errors=stderr,
                                                    duration=duration,
                                                    error_type=error_type,
                                                )
                                        

                                        LanguageFormatter

                                        Bases: ABC

                                        Abstract base class for language-specific formatters.

                                        Source code in src/anyenv/language_formatters/_base.py
                                        class LanguageFormatter(ABC):
                                            """Abstract base class for language-specific formatters."""
                                        
                                            def __init__(
                                                self,
                                                execution_env: ExecutionEnvironment | ExecutionEnvironmentStr = "local",
                                            ) -> None:
                                                """Initialize formatter with execution environment.
                                        
                                                Args:
                                                    execution_env: Execution environment - either a string provider name
                                                        or a direct ExecutionEnvironment instance
                                                """
                                                from exxec import ExecutionEnvironment, get_environment
                                        
                                                self._execution_env: ExecutionEnvironment = (
                                                    execution_env
                                                    if isinstance(execution_env, ExecutionEnvironment)
                                                    else get_environment(execution_env)
                                                )
                                        
                                            async def _execute_command(self, cmd: list[str]) -> tuple[bool, str, str, float, str | None]:
                                                """Execute command and return rich result information."""
                                                async with self._execution_env as env:
                                                    result = await env.execute_command(shlex.join(cmd))
                                                    return (
                                                        result.success,
                                                        result.stdout or str(result.result) if result.result else "",
                                                        result.stderr or result.error or "",
                                                        result.duration,
                                                        result.error_type,
                                                    )
                                        
                                            @property
                                            @abstractmethod
                                            def name(self) -> str:
                                                """Language name (e.g., 'Python', 'TOML')."""
                                        
                                            @property
                                            @abstractmethod
                                            def command(self) -> str:
                                                """Primary CLI command required (e.g., 'ruff', 'biome', 'gofmt')."""
                                        
                                            @property
                                            @abstractmethod
                                            def extensions(self) -> list[str]:
                                                """File extensions this formatter handles (e.g., ['.py', '.pyi'])."""
                                        
                                            @property
                                            @abstractmethod
                                            def pygments_lexers(self) -> list[str]:
                                                """Pygments lexer names for this language (e.g., ['python', 'python3'])."""
                                        
                                            @abstractmethod
                                            async def format(self, path: Path) -> FormatResult:
                                                """Format a file."""
                                        
                                            @abstractmethod
                                            async def lint(self, path: Path, fix: bool = False) -> LintResult:
                                                """Lint a file, optionally fixing issues."""
                                        
                                            def is_available(self) -> bool:
                                                """Check if the formatter command is available on the system."""
                                                return shutil.which(self.command) is not None
                                        
                                            async def format_and_lint(self, path: Path, fix: bool = False) -> FormatAndLintResult:
                                                """Format and then lint a file."""
                                                format_result = await self.format(path)
                                                lint_result = await self.lint(path, fix=fix)
                                                return FormatAndLintResult(format_result, lint_result)
                                        
                                            def can_handle(self, path: Path) -> bool:
                                                """Check if this formatter can handle the given file."""
                                                return path.suffix.lower() in self.extensions
                                        
                                            def can_handle_language(self, language: str) -> bool:
                                                """Check if this formatter can handle the given language name."""
                                                return language.lower() in [lexer.lower() for lexer in self.pygments_lexers]
                                        
                                            async def format_string(self, content: str, language: str | None = None) -> FormatResult:
                                                """Format a string by creating a temporary file.
                                        
                                                Args:
                                                    content: String content to format
                                                    language: Language name (pygments lexer name) if extension can't be determined
                                        
                                                Returns:
                                                    FormatResult with formatted content in output field
                                                """
                                                extension = self.extensions[0] if self.extensions else ".txt"
                                        
                                                with tempfile.NamedTemporaryFile(mode="w", suffix=extension, delete=False) as temp_file:
                                                    temp_file.write(content)
                                                    temp_path = Path(temp_file.name)
                                        
                                                try:
                                                    result = await self.format(temp_path)
                                                    if result.success:
                                                        formatted_content = temp_path.read_text("utf-8")
                                                        result.output = formatted_content
                                                    return result
                                                finally:
                                                    temp_path.unlink(missing_ok=True)
                                        
                                            async def lint_string(
                                                self, content: str, language: str | None = None, fix: bool = False
                                            ) -> LintResult:
                                                """Lint a string by creating a temporary file.
                                        
                                                Args:
                                                    content: String content to lint
                                                    language: Language name (pygments lexer name) if extension can't be determined
                                                    fix: Whether to apply fixes
                                        
                                                Returns:
                                                    LintResult with any fixes applied to output field
                                                """
                                                extension = self.extensions[0] if self.extensions else ".txt"
                                        
                                                with tempfile.NamedTemporaryFile(mode="w", suffix=extension, delete=False) as temp_file:
                                                    temp_file.write(content)
                                                    temp_path = Path(temp_file.name)
                                        
                                                try:
                                                    result = await self.lint(temp_path, fix=fix)
                                                    if result.success and fix:
                                                        modified_content = temp_path.read_text("utf-8")
                                                        result.output = modified_content
                                                    return result
                                                finally:
                                                    temp_path.unlink(missing_ok=True)
                                        
                                            async def format_and_lint_string(
                                                self, content: str, language: str | None = None, fix: bool = False
                                            ) -> FormatAndLintResult:
                                                """Format and lint a string."""
                                                format_result = await self.format_string(content, language)
                                                content_to_lint = format_result.output if format_result.success else content
                                                lint_result = await self.lint_string(content_to_lint, language, fix)
                                                return FormatAndLintResult(format_result, lint_result)
                                        

                                        command abstractmethod property

                                        command: str
                                        

                                        Primary CLI command required (e.g., 'ruff', 'biome', 'gofmt').

                                        extensions abstractmethod property

                                        extensions: list[str]
                                        

                                        File extensions this formatter handles (e.g., ['.py', '.pyi']).

                                        name abstractmethod property

                                        name: str
                                        

                                        Language name (e.g., 'Python', 'TOML').

                                        pygments_lexers abstractmethod property

                                        pygments_lexers: list[str]
                                        

                                        Pygments lexer names for this language (e.g., ['python', 'python3']).

                                        __init__

                                        __init__(execution_env: ExecutionEnvironment | ExecutionEnvironmentStr = 'local') -> None
                                        

                                        Initialize formatter with execution environment.

                                        Parameters:

                                        Name Type Description Default
                                        execution_env ExecutionEnvironment | ExecutionEnvironmentStr

                                        Execution environment - either a string provider name or a direct ExecutionEnvironment instance

                                        'local'
                                        Source code in src/anyenv/language_formatters/_base.py
                                        def __init__(
                                            self,
                                            execution_env: ExecutionEnvironment | ExecutionEnvironmentStr = "local",
                                        ) -> None:
                                            """Initialize formatter with execution environment.
                                        
                                            Args:
                                                execution_env: Execution environment - either a string provider name
                                                    or a direct ExecutionEnvironment instance
                                            """
                                            from exxec import ExecutionEnvironment, get_environment
                                        
                                            self._execution_env: ExecutionEnvironment = (
                                                execution_env
                                                if isinstance(execution_env, ExecutionEnvironment)
                                                else get_environment(execution_env)
                                            )
                                        

                                        can_handle

                                        can_handle(path: Path) -> bool
                                        

                                        Check if this formatter can handle the given file.

                                        Source code in src/anyenv/language_formatters/_base.py
                                        def can_handle(self, path: Path) -> bool:
                                            """Check if this formatter can handle the given file."""
                                            return path.suffix.lower() in self.extensions
                                        

                                        can_handle_language

                                        can_handle_language(language: str) -> bool
                                        

                                        Check if this formatter can handle the given language name.

                                        Source code in src/anyenv/language_formatters/_base.py
                                        def can_handle_language(self, language: str) -> bool:
                                            """Check if this formatter can handle the given language name."""
                                            return language.lower() in [lexer.lower() for lexer in self.pygments_lexers]
                                        

                                        format abstractmethod async

                                        format(path: Path) -> FormatResult
                                        

                                        Format a file.

                                        Source code in src/anyenv/language_formatters/_base.py
                                        @abstractmethod
                                        async def format(self, path: Path) -> FormatResult:
                                            """Format a file."""
                                        

                                        format_and_lint async

                                        format_and_lint(path: Path, fix: bool = False) -> FormatAndLintResult
                                        

                                        Format and then lint a file.

                                        Source code in src/anyenv/language_formatters/_base.py
                                        async def format_and_lint(self, path: Path, fix: bool = False) -> FormatAndLintResult:
                                            """Format and then lint a file."""
                                            format_result = await self.format(path)
                                            lint_result = await self.lint(path, fix=fix)
                                            return FormatAndLintResult(format_result, lint_result)
                                        

                                        format_and_lint_string async

                                        format_and_lint_string(
                                            content: str, language: str | None = None, fix: bool = False
                                        ) -> FormatAndLintResult
                                        

                                        Format and lint a string.

                                        Source code in src/anyenv/language_formatters/_base.py
                                        async def format_and_lint_string(
                                            self, content: str, language: str | None = None, fix: bool = False
                                        ) -> FormatAndLintResult:
                                            """Format and lint a string."""
                                            format_result = await self.format_string(content, language)
                                            content_to_lint = format_result.output if format_result.success else content
                                            lint_result = await self.lint_string(content_to_lint, language, fix)
                                            return FormatAndLintResult(format_result, lint_result)
                                        

                                        format_string async

                                        format_string(content: str, language: str | None = None) -> FormatResult
                                        

                                        Format a string by creating a temporary file.

                                        Parameters:

                                        Name Type Description Default
                                        content str

                                        String content to format

                                        required
                                        language str | None

                                        Language name (pygments lexer name) if extension can't be determined

                                        None

                                        Returns:

                                        Type Description
                                        FormatResult

                                        FormatResult with formatted content in output field

                                        Source code in src/anyenv/language_formatters/_base.py
                                        async def format_string(self, content: str, language: str | None = None) -> FormatResult:
                                            """Format a string by creating a temporary file.
                                        
                                            Args:
                                                content: String content to format
                                                language: Language name (pygments lexer name) if extension can't be determined
                                        
                                            Returns:
                                                FormatResult with formatted content in output field
                                            """
                                            extension = self.extensions[0] if self.extensions else ".txt"
                                        
                                            with tempfile.NamedTemporaryFile(mode="w", suffix=extension, delete=False) as temp_file:
                                                temp_file.write(content)
                                                temp_path = Path(temp_file.name)
                                        
                                            try:
                                                result = await self.format(temp_path)
                                                if result.success:
                                                    formatted_content = temp_path.read_text("utf-8")
                                                    result.output = formatted_content
                                                return result
                                            finally:
                                                temp_path.unlink(missing_ok=True)
                                        

                                        is_available

                                        is_available() -> bool
                                        

                                        Check if the formatter command is available on the system.

                                        Source code in src/anyenv/language_formatters/_base.py
                                        def is_available(self) -> bool:
                                            """Check if the formatter command is available on the system."""
                                            return shutil.which(self.command) is not None
                                        

                                        lint abstractmethod async

                                        lint(path: Path, fix: bool = False) -> LintResult
                                        

                                        Lint a file, optionally fixing issues.

                                        Source code in src/anyenv/language_formatters/_base.py
                                        @abstractmethod
                                        async def lint(self, path: Path, fix: bool = False) -> LintResult:
                                            """Lint a file, optionally fixing issues."""
                                        

                                        lint_string async

                                        lint_string(content: str, language: str | None = None, fix: bool = False) -> LintResult
                                        

                                        Lint a string by creating a temporary file.

                                        Parameters:

                                        Name Type Description Default
                                        content str

                                        String content to lint

                                        required
                                        language str | None

                                        Language name (pygments lexer name) if extension can't be determined

                                        None
                                        fix bool

                                        Whether to apply fixes

                                        False

                                        Returns:

                                        Type Description
                                        LintResult

                                        LintResult with any fixes applied to output field

                                        Source code in src/anyenv/language_formatters/_base.py
                                        async def lint_string(
                                            self, content: str, language: str | None = None, fix: bool = False
                                        ) -> LintResult:
                                            """Lint a string by creating a temporary file.
                                        
                                            Args:
                                                content: String content to lint
                                                language: Language name (pygments lexer name) if extension can't be determined
                                                fix: Whether to apply fixes
                                        
                                            Returns:
                                                LintResult with any fixes applied to output field
                                            """
                                            extension = self.extensions[0] if self.extensions else ".txt"
                                        
                                            with tempfile.NamedTemporaryFile(mode="w", suffix=extension, delete=False) as temp_file:
                                                temp_file.write(content)
                                                temp_path = Path(temp_file.name)
                                        
                                            try:
                                                result = await self.lint(temp_path, fix=fix)
                                                if result.success and fix:
                                                    modified_content = temp_path.read_text("utf-8")
                                                    result.output = modified_content
                                                return result
                                            finally:
                                                temp_path.unlink(missing_ok=True)
                                        

                                        LintResult dataclass

                                        Result of a linting operation.

                                        Source code in src/anyenv/language_formatters/_base.py
                                        @dataclass
                                        class LintResult:
                                            """Result of a linting operation."""
                                        
                                            success: bool
                                            output: str
                                            errors: str
                                            fixed_issues: int = 0
                                            remaining_issues: int = 0
                                            duration: float = 0.0
                                            error_type: str | None = None
                                        

                                        PrettierFormatter

                                        Bases: LanguageFormatter

                                        Multi-language formatter using prettier.

                                        Source code in src/anyenv/language_formatters/_web.py
                                        class PrettierFormatter(LanguageFormatter):
                                            """Multi-language formatter using prettier."""
                                        
                                            @property
                                            def name(self) -> str:
                                                return "Prettier"
                                        
                                            @property
                                            def command(self) -> str:
                                                return "prettier"
                                        
                                            @property
                                            def extensions(self) -> list[str]:
                                                return [".html", ".css", ".scss", ".less", ".md", ".markdown", ".yaml", ".yml", ".graphql"]
                                        
                                            @property
                                            def pygments_lexers(self) -> list[str]:
                                                return ["html", "css", "scss", "less", "markdown", "md", "yaml", "graphql"]
                                        
                                            async def format(self, path: Path) -> FormatResult:
                                                cmd = ["prettier", "--write", str(path)]
                                                success, stdout, stderr, duration, error_type = await self._execute_command(cmd)
                                                return FormatResult(
                                                    success=success,
                                                    output=stdout,
                                                    errors=stderr,
                                                    formatted=success,
                                                    duration=duration,
                                                    error_type=error_type,
                                                )
                                        
                                            async def lint(self, path: Path, fix: bool = False) -> LintResult:
                                                # Prettier is format-only, check mode reports if file is formatted
                                                cmd = ["prettier", "--check", str(path)]
                                                success, stdout, stderr, duration, error_type = await self._execute_command(cmd)
                                                return LintResult(
                                                    success=success,
                                                    output=stdout,
                                                    errors=stderr,
                                                    duration=duration,
                                                    error_type=error_type,
                                                )
                                        

                                        PythonRuffFormatter

                                        Bases: LanguageFormatter

                                        Python formatter using ruff directly.

                                        Source code in src/anyenv/language_formatters/_python.py
                                        class PythonRuffFormatter(LanguageFormatter):
                                            """Python formatter using ruff directly."""
                                        
                                            @property
                                            def name(self) -> str:
                                                return "Python"
                                        
                                            @property
                                            def command(self) -> str:
                                                return "ruff"
                                        
                                            @property
                                            def extensions(self) -> list[str]:
                                                return [".py", ".pyi"]
                                        
                                            @property
                                            def pygments_lexers(self) -> list[str]:
                                                return ["python", "python3", "py"]
                                        
                                            async def format(self, path: Path) -> FormatResult:
                                                cmd = ["ruff", "format", str(path)]
                                                success, stdout, stderr, duration, error_type = await self._execute_command(cmd)
                                                return FormatResult(
                                                    success=success,
                                                    output=stdout,
                                                    errors=stderr,
                                                    formatted=success,
                                                    duration=duration,
                                                    error_type=error_type,
                                                )
                                        
                                            async def lint(self, path: Path, fix: bool = False) -> LintResult:
                                                cmd = ["ruff", "check"]
                                                if fix:
                                                    cmd.extend(["--fix", "--unsafe-fixes"])
                                                cmd.append(str(path))
                                                success, stdout, stderr, duration, error_type = await self._execute_command(cmd)
                                                return LintResult(
                                                    success=success,
                                                    output=stdout,
                                                    errors=stderr,
                                                    duration=duration,
                                                    error_type=error_type,
                                                )
                                        

                                        PythonUvFormatter

                                        Bases: LanguageFormatter

                                        Python formatter using uv to run ruff.

                                        Source code in src/anyenv/language_formatters/_python.py
                                        class PythonUvFormatter(LanguageFormatter):
                                            """Python formatter using uv to run ruff."""
                                        
                                            @property
                                            def name(self) -> str:
                                                return "Python"
                                        
                                            @property
                                            def command(self) -> str:
                                                return "uv"
                                        
                                            @property
                                            def extensions(self) -> list[str]:
                                                return [".py", ".pyi"]
                                        
                                            @property
                                            def pygments_lexers(self) -> list[str]:
                                                return ["python", "python3", "py"]
                                        
                                            async def format(self, path: Path) -> FormatResult:
                                                cmd = ["uv", "run", "ruff", "format", str(path)]
                                                success, stdout, stderr, duration, error_type = await self._execute_command(cmd)
                                                return FormatResult(
                                                    success=success,
                                                    output=stdout,
                                                    errors=stderr,
                                                    formatted=success,
                                                    duration=duration,
                                                    error_type=error_type,
                                                )
                                        
                                            async def lint(self, path: Path, fix: bool = False) -> LintResult:
                                                cmd = ["uv", "run", "ruff", "check"]
                                                if fix:
                                                    cmd.extend(["--fix", "--unsafe-fixes"])
                                                cmd.append(str(path))
                                                success, stdout, stderr, duration, error_type = await self._execute_command(cmd)
                                                return LintResult(
                                                    success=success,
                                                    output=stdout,
                                                    errors=stderr,
                                                    duration=duration,
                                                    error_type=error_type,
                                                )
                                        

                                        RubocopFormatter

                                        Bases: LanguageFormatter

                                        Ruby formatter using rubocop.

                                        Source code in src/anyenv/language_formatters/_ruby.py
                                        class RubocopFormatter(LanguageFormatter):
                                            """Ruby formatter using rubocop."""
                                        
                                            @property
                                            def name(self) -> str:
                                                return "Ruby"
                                        
                                            @property
                                            def command(self) -> str:
                                                return "rubocop"
                                        
                                            @property
                                            def extensions(self) -> list[str]:
                                                return [".rb", ".rake", ".gemspec", ".ru"]
                                        
                                            @property
                                            def pygments_lexers(self) -> list[str]:
                                                return ["ruby", "rb"]
                                        
                                            async def format(self, path: Path) -> FormatResult:
                                                cmd = ["rubocop", "--autocorrect", str(path)]
                                                success, stdout, stderr, duration, error_type = await self._execute_command(cmd)
                                                return FormatResult(
                                                    success=success,
                                                    output=stdout,
                                                    errors=stderr,
                                                    formatted=success,
                                                    duration=duration,
                                                    error_type=error_type,
                                                )
                                        
                                            async def lint(self, path: Path, fix: bool = False) -> LintResult:
                                                cmd = ["rubocop"]
                                                if fix:
                                                    cmd.append("--autocorrect")
                                                cmd.append(str(path))
                                                success, stdout, stderr, duration, error_type = await self._execute_command(cmd)
                                                return LintResult(
                                                    success=success,
                                                    output=stdout,
                                                    errors=stderr,
                                                    duration=duration,
                                                    error_type=error_type,
                                                )
                                        

                                        RustFormatter

                                        Bases: LanguageFormatter

                                        Rust formatter using rustfmt and clippy.

                                        Source code in src/anyenv/language_formatters/_systems.py
                                        class RustFormatter(LanguageFormatter):
                                            """Rust formatter using rustfmt and clippy."""
                                        
                                            @property
                                            def name(self) -> str:
                                                return "Rust"
                                        
                                            @property
                                            def command(self) -> str:
                                                return "rustfmt"
                                        
                                            @property
                                            def extensions(self) -> list[str]:
                                                return [".rs"]
                                        
                                            @property
                                            def pygments_lexers(self) -> list[str]:
                                                return ["rust", "rs"]
                                        
                                            async def format(self, path: Path) -> FormatResult:
                                                cmd = ["rustfmt", str(path)]
                                                success, stdout, stderr, duration, error_type = await self._execute_command(cmd)
                                                return FormatResult(
                                                    success=success,
                                                    output=stdout,
                                                    errors=stderr,
                                                    formatted=success,
                                                    duration=duration,
                                                    error_type=error_type,
                                                )
                                        
                                            async def lint(self, path: Path, fix: bool = False) -> LintResult:
                                                cmd = ["cargo", "clippy"]
                                                if fix:
                                                    cmd.append("--fix")
                                                cmd.extend(["--", "--", str(path)])
                                                success, stdout, stderr, duration, error_type = await self._execute_command(cmd)
                                                return LintResult(
                                                    success=success,
                                                    output=stdout,
                                                    errors=stderr,
                                                    duration=duration,
                                                    error_type=error_type,
                                                )
                                        

                                        StandardRBFormatter

                                        Bases: LanguageFormatter

                                        Ruby formatter using standardrb.

                                        Source code in src/anyenv/language_formatters/_ruby.py
                                        class StandardRBFormatter(LanguageFormatter):
                                            """Ruby formatter using standardrb."""
                                        
                                            @property
                                            def name(self) -> str:
                                                return "Ruby"
                                        
                                            @property
                                            def command(self) -> str:
                                                return "standardrb"
                                        
                                            @property
                                            def extensions(self) -> list[str]:
                                                return [".rb", ".rake", ".gemspec", ".ru"]
                                        
                                            @property
                                            def pygments_lexers(self) -> list[str]:
                                                return ["ruby", "rb"]
                                        
                                            async def format(self, path: Path) -> FormatResult:
                                                cmd = ["standardrb", "--fix", str(path)]
                                                success, stdout, stderr, duration, error_type = await self._execute_command(cmd)
                                                return FormatResult(
                                                    success=success,
                                                    output=stdout,
                                                    errors=stderr,
                                                    formatted=success,
                                                    duration=duration,
                                                    error_type=error_type,
                                                )
                                        
                                            async def lint(self, path: Path, fix: bool = False) -> LintResult:
                                                cmd = ["standardrb"]
                                                if fix:
                                                    cmd.append("--fix")
                                                cmd.append(str(path))
                                                success, stdout, stderr, duration, error_type = await self._execute_command(cmd)
                                                return LintResult(
                                                    success=success,
                                                    output=stdout,
                                                    errors=stderr,
                                                    duration=duration,
                                                    error_type=error_type,
                                                )
                                        

                                        TOMLFormatter

                                        Bases: LanguageFormatter

                                        TOML formatter using tombi.

                                        Source code in src/anyenv/language_formatters/_toml.py
                                        class TOMLFormatter(LanguageFormatter):
                                            """TOML formatter using tombi."""
                                        
                                            @property
                                            def name(self) -> str:
                                                return "TOML"
                                        
                                            @property
                                            def command(self) -> str:
                                                return "tombi"
                                        
                                            @property
                                            def extensions(self) -> list[str]:
                                                return [".toml"]
                                        
                                            @property
                                            def pygments_lexers(self) -> list[str]:
                                                return ["toml"]
                                        
                                            async def format(self, path: Path) -> FormatResult:
                                                cmd = ["uv", "run", "tombi", "format", str(path)]
                                                success, stdout, stderr, duration, error_type = await self._execute_command(cmd)
                                                return FormatResult(
                                                    success=success,
                                                    output=stdout,
                                                    errors=stderr,
                                                    formatted=success,
                                                    duration=duration,
                                                    error_type=error_type,
                                                )
                                        
                                            async def lint(self, path: Path, fix: bool = False) -> LintResult:
                                                cmd = ["uv", "run", "tombi", "lint", str(path)]
                                                success, stdout, stderr, duration, error_type = await self._execute_command(cmd)
                                                return LintResult(
                                                    success=success,
                                                    output=stdout,
                                                    errors=stderr,
                                                    duration=duration,
                                                    error_type=error_type,
                                                )
                                        

                                        ZigFormatter

                                        Bases: LanguageFormatter

                                        Zig formatter using zig fmt.

                                        Source code in src/anyenv/language_formatters/_systems.py
                                        class ZigFormatter(LanguageFormatter):
                                            """Zig formatter using zig fmt."""
                                        
                                            @property
                                            def name(self) -> str:
                                                return "Zig"
                                        
                                            @property
                                            def command(self) -> str:
                                                return "zig"
                                        
                                            @property
                                            def extensions(self) -> list[str]:
                                                return [".zig", ".zon"]
                                        
                                            @property
                                            def pygments_lexers(self) -> list[str]:
                                                return ["zig"]
                                        
                                            async def format(self, path: Path) -> FormatResult:
                                                cmd = ["zig", "fmt", str(path)]
                                                success, stdout, stderr, duration, error_type = await self._execute_command(cmd)
                                                return FormatResult(
                                                    success=success,
                                                    output=stdout,
                                                    errors=stderr,
                                                    formatted=success,
                                                    duration=duration,
                                                    error_type=error_type,
                                                )
                                        
                                            async def lint(self, path: Path, fix: bool = False) -> LintResult:
                                                # zig fmt --check for lint-like behavior
                                                cmd = ["zig", "fmt", "--check", str(path)]
                                                success, stdout, stderr, duration, error_type = await self._execute_command(cmd)
                                                return LintResult(
                                                    success=success,
                                                    output=stdout,
                                                    errors=stderr,
                                                    duration=duration,
                                                    error_type=error_type,
                                                )