LanguageFormatter
Sub classes¶
| Name | Children | Inherits |
|---|---|---|
| ElixirFormatter anyenv.language_formatters._elixir Elixir formatter using mix format. |
||
| KtlintFormatter anyenv.language_formatters._jvm Kotlin formatter using ktlint. |
||
| PythonRuffFormatter anyenv.language_formatters._python Python formatter using ruff directly. |
||
| PythonUvFormatter anyenv.language_formatters._python Python formatter using uv to run ruff. |
||
| AirFormatter anyenv.language_formatters._r R formatter using air. |
||
| RubocopFormatter anyenv.language_formatters._ruby Ruby formatter using rubocop. |
||
| StandardRBFormatter anyenv.language_formatters._ruby Ruby formatter using standardrb. |
||
| GoFormatter anyenv.language_formatters._systems Go formatter using gofmt. |
||
| RustFormatter anyenv.language_formatters._systems Rust formatter using rustfmt and clippy. |
||
| ZigFormatter anyenv.language_formatters._systems Zig formatter using zig fmt. |
||
| ClangFormatFormatter anyenv.language_formatters._systems C/C++ formatter using clang-format. |
||
| TOMLFormatter anyenv.language_formatters._toml TOML formatter using tombi. |
||
| BiomeFormatter anyenv.language_formatters._web TypeScript/JavaScript/JSON formatter using biome. |
||
| PrettierFormatter anyenv.language_formatters._web Multi-language formatter using prettier. |
||
| HtmlBeautifierFormatter anyenv.language_formatters._web ERB formatter using htmlbeautifier. |
Base classes¶
| Name | Children | Inherits |
|---|---|---|
| ABC abc Helper class that provides a standard way to create an ABC using |
â‹” Inheritance diagram¶
graph TD
3820931366["_base.LanguageFormatter"]
925645236["abc.ABC"]
2751680898["builtins.object"]
925645236 --> 3820931366
2751680898 --> 925645236
🛈 DocStrings¶
Bases: ABC
Abstract base class for language-specific formatters.
Source code in src/anyenv/language_formatters/_base.py
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 | |
command
abstractmethod
property
¶
Primary CLI command required (e.g., 'ruff', 'biome', 'gofmt').
extensions
abstractmethod
property
¶
File extensions this formatter handles (e.g., ['.py', '.pyi']).
pygments_lexers
abstractmethod
property
¶
Pygments lexer names for this language (e.g., ['python', 'python3']).
__init__
¶
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
can_handle
¶
can_handle_language
¶
Check if this formatter can handle the given language name.
format
abstractmethod
async
¶
format(path: Path) -> FormatResult
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
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
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
is_available
¶
lint
abstractmethod
async
¶
lint(path: Path, fix: bool = False) -> LintResult
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 |