black ¤
Callable for Black.
Functions:
-
run
–Run
black
.
run ¤
run(
*src: str,
config: str | None = None,
code: str | None = None,
line_length: int | None = None,
target_version: str | None = None,
check: bool | None = None,
diff: bool | None = None,
color: bool | None = None,
fast: bool | None = None,
pyi: bool | None = None,
ipynb: bool | None = None,
python_cell_magics: str | None = None,
skip_source_first_line: bool | None = None,
skip_string_normalization: bool | None = None,
skip_magic_trailing_comma: bool | None = None,
experimental_string_processing: bool | None = None,
preview: bool | None = None,
quiet: bool | None = None,
verbose: bool | None = None,
required_version: str | None = None,
include: str | None = None,
exclude: str | None = None,
extend_exclude: str | None = None,
force_exclude: str | None = None,
stdin_filename: str | None = None,
workers: int | None = None
) -> None
Run black
.
Parameters:
-
src
(str
, default:()
) –Format the directories and file paths.
-
config
(str | None
, default:None
) –Read configuration from this file path.
-
code
(str | None
, default:None
) –Format the code passed in as a string.
-
line_length
(int | None
, default:None
) –How many characters per line to allow [default: 120].
-
target_version
(str | None
, default:None
) –Python versions that should be supported by Black's output. By default, Black will try to infer this from the project metadata in pyproject.toml. If this does not yield conclusive results, Black will use per-file auto-detection.
-
check
(bool | None
, default:None
) –Don't write the files back, just return the status. Return code 0 means nothing would change. Return code 1 means some files would be reformatted. Return code 123 means there was an internal error.
-
diff
(bool | None
, default:None
) –Don't write the files back, just output a diff for each file on stdout.
-
color
(bool | None
, default:None
) –Show colored diff. Only applies when
--diff
is given. -
fast
(bool | None
, default:None
) –If --fast given, skip temporary sanity checks. [default: --safe]
-
pyi
(bool | None
, default:None
) –Format all input files like typing stubs regardless of file extension (useful when piping source on standard input).
-
ipynb
(bool | None
, default:None
) –Format all input files like Jupyter Notebooks regardless of file extension (useful when piping source on standard input).
-
python_cell_magics
(str | None
, default:None
) –When processing Jupyter Notebooks, add the given magic to the list of known python-magics (capture, prun, pypy, python, python3, time, timeit). Useful for formatting cells with custom python magics.
-
skip_source_first_line
(bool | None
, default:None
) –Skip the first line of the source code.
-
skip_string_normalization
(bool | None
, default:None
) –Don't normalize string quotes or prefixes.
-
skip_magic_trailing_comma
(bool | None
, default:None
) –Don't use trailing commas as a reason to split lines.
-
preview
(bool | None
, default:None
) –Enable potentially disruptive style changes that may be added to Black's main functionality in the next major release.
-
quiet
(bool | None
, default:None
) –Don't emit non-error messages to stderr. Errors are still emitted; silence those with 2>/dev/null.
-
verbose
(bool | None
, default:None
) –Also emit messages to stderr about files that were not changed or were ignored due to exclusion patterns.
-
required_version
(str | None
, default:None
) –Require a specific version of Black to be running (useful for unifying results across many environments e.g. with a pyproject.toml file). It can be either a major version number or an exact version.
-
include
(str | None
, default:None
) –A regular expression that matches files and directories that should be included on recursive searches. An empty value means all files are included regardless of the name. Use forward slashes for directories on all platforms (Windows, too). Exclusions are calculated first, inclusions later [default: (.pyi?|.ipynb)$].
-
exclude
(str | None
, default:None
) –A regular expression that matches files and directories that should be excluded on recursive searches. An empty value means no paths are excluded. Use forward slashes for directories on all platforms (Windows, too). Exclusions are calculated first, inclusions later [default: /(.direnv|.eggs|.git|.hg|.mypy_cache|.nox| .tox|.venv|venv|.svn|.ipynb_checkpoints|_build|buck-out|build|dist|pypackages)/].
-
extend_exclude
(str | None
, default:None
) –Like --exclude, but adds additional files and directories on top of the excluded ones (useful if you simply want to add to the default).
-
force_exclude
(str | None
, default:None
) –Like --exclude, but files and directories matching this regex will be excluded even when they are passed explicitly as arguments.
-
stdin_filename
(str | None
, default:None
) –The name of the file when passing it through stdin. Useful to make sure Black will respect --force-exclude option on some editors that rely on using stdin.
-
workers
(int | None
, default:None
) –Number of parallel workers [default: number CPUs in the system].
Source code in src/duty/callables/black.py
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 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 |
|