ruff ¤
Callable for Ruff.
Functions:
-
check
–Run Ruff on the given files or directories.
-
clean
–Clear any caches in the current directory and any subdirectories.
-
config
–List or describe the available configuration options.
-
format
–Run Ruff formatter on the given files or directories.
-
linter
–List all supported upstream linters.
-
rule
–Explain a rule.
check ¤
check(
*files: str,
config: str | None = None,
fix: bool | None = None,
show_source: bool | None = None,
show_fixes: bool | None = None,
diff: bool | None = None,
watch: bool | None = None,
fix_only: bool | None = None,
output_format: str | None = None,
statistics: bool | None = None,
add_noqa: bool | None = None,
show_files: bool | None = None,
show_settings: bool | None = None,
select: list[str] | None = None,
ignore: list[str] | None = None,
extend_select: list[str] | None = None,
per_file_ignores: dict[str, list[str]] | None = None,
fixable: list[str] | None = None,
unfixable: list[str] | None = None,
exclude: list[str] | None = None,
extend_exclude: list[str] | None = None,
respect_gitignore: bool | None = None,
force_exclude: bool | None = None,
no_cache: bool | None = None,
isolated: bool | None = None,
cache_dir: str | None = None,
stdin_filename: str | None = None,
exit_zero: bool | None = None,
exit_non_zero_on_fix: bool | None = None,
verbose: bool = False,
quiet: bool = False,
silent: bool = False
) -> int
Run Ruff on the given files or directories.
Parameters:
-
fix
(bool | None
, default:None
) –Attempt to automatically fix lint violations
-
config
(str | None
, default:None
) –Path to the
pyproject.toml
orruff.toml
file to use for configuration -
show_source
(bool | None
, default:None
) –Show violations with source code
-
show_fixes
(bool | None
, default:None
) –Show an enumeration of all autofixed lint violations
-
diff
(bool | None
, default:None
) –Avoid writing any fixed files back; instead, output a diff for each changed file to stdout
-
watch
(bool | None
, default:None
) –Run in watch mode by re-running whenever files change
-
fix_only
(bool | None
, default:None
) –Fix any fixable lint violations, but don't report on leftover violations. Implies
--fix
-
output_format
(str | None
, default:None
) –Output serialization format for violations [env: RUFF_FORMAT=] [possible values: text, json, junit, grouped, github, gitlab, pylint]
-
statistics
(bool | None
, default:None
) –Show counts for every rule with at least one violation
-
add_noqa
(bool | None
, default:None
) –Enable automatic additions of
noqa
directives to failing lines -
show_files
(bool | None
, default:None
) –See the files Ruff will be run against with the current settings
-
show_settings
(bool | None
, default:None
) –See the settings Ruff will use to lint a given Python file
-
select
(list[str] | None
, default:None
) –Comma-separated list of rule codes to enable (or ALL, to enable all rules)
-
ignore
(list[str] | None
, default:None
) –Comma-separated list of rule codes to disable
-
extend_select
(list[str] | None
, default:None
) –Like --select, but adds additional rule codes on top of the selected ones
-
per_file_ignores
(dict[str, list[str]] | None
, default:None
) –List of mappings from file pattern to code to exclude
-
fixable
(list[str] | None
, default:None
) –List of rule codes to treat as eligible for autofix. Only applicable when autofix itself is enabled (e.g., via
--fix
) -
unfixable
(list[str] | None
, default:None
) –List of rule codes to treat as ineligible for autofix. Only applicable when autofix itself is enabled (e.g., via
--fix
) -
exclude
(list[str] | None
, default:None
) –List of paths, used to omit files and/or directories from analysis
-
extend_exclude
(list[str] | None
, default:None
) –Like --exclude, but adds additional files and directories on top of those already excluded
-
respect_gitignore
(bool | None
, default:None
) –Respect file exclusions via
.gitignore
and other standard ignore files -
force_exclude
(bool | None
, default:None
) –Enforce exclusions, even for paths passed to Ruff directly on the command-line
-
no_cache
(bool | None
, default:None
) –Disable cache reads
-
isolated
(bool | None
, default:None
) –Ignore all configuration files
-
cache_dir
(str | None
, default:None
) –Path to the cache directory [env: RUFF_CACHE_DIR=]
-
stdin_filename
(str | None
, default:None
) –The name of the file when passing it through stdin
-
exit_zero
(bool | None
, default:None
) –Exit with status code "0", even upon detecting lint violations
-
exit_non_zero_on_fix
(bool | None
, default:None
) –Exit with a non-zero status code if any files were modified via autofix, even if no lint violations remain
-
verbose
(bool
, default:False
) –Enable verbose logging.
-
quiet
(bool
, default:False
) –Print lint violations, but nothing else.
-
silent
(bool
, default:False
) –Disable all logging (but still exit with status code "1" upon detecting lint violations).
Source code in src/duty/callables/ruff.py
55 56 57 58 59 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 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 |
|
clean ¤
Clear any caches in the current directory and any subdirectories.
Parameters:
-
verbose
(bool
, default:False
) –Enable verbose logging.
-
quiet
(bool
, default:False
) –Print lint violations, but nothing else.
-
silent
(bool
, default:False
) –Disable all logging (but still exit with status code "1" upon detecting lint violations).
Source code in src/duty/callables/ruff.py
385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 |
|
config ¤
List or describe the available configuration options.
Parameters:
-
verbose
(bool
, default:False
) –Enable verbose logging.
-
quiet
(bool
, default:False
) –Print lint violations, but nothing else.
-
silent
(bool
, default:False
) –Disable all logging (but still exit with status code "1" upon detecting lint violations).
Source code in src/duty/callables/ruff.py
343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 |
|
format ¤
format(
*files: str,
config: str | None = None,
check: bool | None = None,
diff: bool | None = None,
target_version: str | None = None,
preview: bool | None = None,
exclude: list[str] | None = None,
extend_exclude: list[str] | None = None,
respect_gitignore: bool | None = None,
force_exclude: bool | None = None,
no_cache: bool | None = None,
isolated: bool | None = None,
cache_dir: str | None = None,
stdin_filename: str | None = None,
verbose: bool = False,
quiet: bool = False,
silent: bool = False
) -> int
Run Ruff formatter on the given files or directories.
Parameters:
-
check
(bool | None
, default:None
) –Avoid writing any formatted files back; instead, exit with a non-zero status code if any files would have been modified, and zero otherwise
-
config
(str | None
, default:None
) –Path to the
pyproject.toml
orruff.toml
file to use for configuration -
diff
(bool | None
, default:None
) –Avoid writing any fixed files back; instead, output a diff for each changed file to stdout
-
target_version
(str | None
, default:None
) –The minimum Python version that should be supported [possible values: py37, py38, py39, py310, py311, py312]
-
preview
(bool | None
, default:None
) –Enable preview mode; enables unstable formatting
-
exclude
(list[str] | None
, default:None
) –List of paths, used to omit files and/or directories from analysis
-
extend_exclude
(list[str] | None
, default:None
) –Like --exclude, but adds additional files and directories on top of those already excluded
-
respect_gitignore
(bool | None
, default:None
) –Respect file exclusions via
.gitignore
and other standard ignore files -
force_exclude
(bool | None
, default:None
) –Enforce exclusions, even for paths passed to Ruff directly on the command-line
-
no_cache
(bool | None
, default:None
) –Disable cache reads
-
isolated
(bool | None
, default:None
) –Ignore all configuration files
-
cache_dir
(str | None
, default:None
) –Path to the cache directory [env: RUFF_CACHE_DIR=]
-
stdin_filename
(str | None
, default:None
) –The name of the file when passing it through stdin
-
verbose
(bool
, default:False
) –Enable verbose logging.
-
quiet
(bool
, default:False
) –Print lint violations, but nothing else.
-
silent
(bool
, default:False
) –Disable all logging (but still exit with status code "1" upon detecting lint violations).
Source code in src/duty/callables/ruff.py
228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 |
|
linter ¤
linter(
*,
output_format: str | None = None,
verbose: bool = False,
quiet: bool = False,
silent: bool = False
) -> int
List all supported upstream linters.
Parameters:
-
output_format
(str | None
, default:None
) –Output format [default: pretty] [possible values: text, json, pretty].
-
verbose
(bool
, default:False
) –Enable verbose logging.
-
quiet
(bool
, default:False
) –Print lint violations, but nothing else.
-
silent
(bool
, default:False
) –Disable all logging (but still exit with status code "1" upon detecting lint violations).
Source code in src/duty/callables/ruff.py
360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 |
|
rule ¤
rule(
*,
output_format: str | None = None,
verbose: bool = False,
quiet: bool = False,
silent: bool = False
) -> int
Explain a rule.
Parameters:
-
output_format
(str | None
, default:None
) –Output format (default: pretty, possible values: text, json, pretty).
-
verbose
(bool
, default:False
) –Enable verbose logging.
-
quiet
(bool
, default:False
) –Print lint violations, but nothing else.
-
silent
(bool
, default:False
) –Disable all logging (but still exit with status code "1" upon detecting lint violations).
Source code in src/duty/callables/ruff.py
318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 |
|