Code
Hub
Workspaces
Following
Trending
Connect
MCP
copy
Create free account
hub
/
github.com/psf/black
/ functions
Functions
1,067 in github.com/psf/black
⨍
Functions
1,067
◇
Types & classes
148
↳
Endpoints
29
↓ 1 callers
Method
_next_state
Pre-conditions: * On the first call to this function, @leaf MUST be the leaf that was directly after the string leaf
src/black/trans.py:2271
↓ 1 callers
Function
_normalize
(lineend: str, value: str)
src/black/parsing.py:201
↓ 1 callers
Method
_normalize_f_string
Pre-Conditions: * assert_is_leaf_string(@string) Returns: * If @string is an f-string that contains no f-exp
src/black/trans.py:1749
↓ 1 callers
Function
_normalize_import_from
(parent: Node, child: LN, index: int)
src/black/linegen.py:1199
↓ 1 callers
Function
_out
(message: Optional[str] = None, nl: bool = True, **styles: Any)
src/black/output.py:15
↓ 1 callers
Method
_partially_consume_prefix
(self, prefix: Text, column: int)
src/blib2to3/pgen2/driver.py:215
↓ 1 callers
Function
_prefer_split_rhs_oop
Returns whether we should prefer the result from a split omitting optional parens.
src/black/linegen.py:811
↓ 1 callers
Method
_recursive_matches
Helper to recursively yield the matches.
src/blib2to3/pytree.py:913
↓ 1 callers
Method
_remove_backslash_line_continuation_chars
Merge strings that were split across multiple lines using line-continuation backslashes. Returns: Ok(new_line),
src/black/trans.py:450
↓ 1 callers
Method
_return_match
Returns: string_idx such that @LL[string_idx] is equal to our target (i.e. matched) string, if this line matches the
src/black/trans.py:1884
↓ 1 callers
Function
_safe_add_trailing_comma
(safe: bool, delimiter_priority: int, line: Line)
src/black/linegen.py:964
↓ 1 callers
Method
_submatch
(self, node, results=None)
src/blib2to3/pytree.py:543
↓ 1 callers
Function
_toggle_fexpr_quotes
Toggles quotes used in f-string expressions that are `old_quote`. f-string expressions can't contain backslashes, so we need to toggle the
src/black/trans.py:1257
↓ 1 callers
Method
_transform_to_new_line
( self, line: Line, string_and_rpar_indices: List[int] )
src/black/trans.py:927
↓ 1 callers
Method
_validate
Checks that @line meets all of the requirements listed in this classes' docstring. Refer to `help(BaseStringSplitter)` for a detailed
src/black/trans.py:1022
↓ 1 callers
Method
_validate_msg
Validate (M)erge (S)tring (G)roup Transform-time string validation logic for _merge_string_group(...). Returns: * Ok(Non
src/black/trans.py:690
↓ 1 callers
Function
a
()
tests/data/py_38/pep_572_remove_parens.py:43
↓ 1 callers
Method
add_custom_splits
Custom Split Map Setter Method Side Effects: Adds a mapping from @string to the custom splits @custom_splits.
src/black/trans.py:322
↓ 1 callers
Method
add_token
(self, tok_type: int, tok_val: Text, raw: bool = False)
src/blib2to3/pgen2/parse.py:103
↓ 1 callers
Method
add_whitespace
(self, start: Coord)
src/blib2to3/pgen2/tokenize.py:243
↓ 1 callers
Method
addfirstsets
(self)
src/blib2to3/pgen2/pgen.py:140
↓ 1 callers
Method
addtoken
Add a token; return True iff this is the end of the program.
src/blib2to3/pgen2/parse.py:239
↓ 1 callers
Method
all_lines
(self)
src/black/lines.py:505
↓ 1 callers
Method
append_comment
Add an inline or standalone comment to the line.
src/black/lines.py:361
↓ 1 callers
Method
append_safe
Like :func:`append()` but disallow invalid standalone comment structure. Raises ValueError when any `leaf` is appended after a standalone com
src/black/lines.py:95
↓ 1 callers
Function
assert_equivalent
Raise AssertionError if `src` and `dst` aren't equivalent.
src/black/__init__.py:1343
↓ 1 callers
Function
assert_stable
Raise AssertionError if `dst` reformats differently the second time.
src/black/__init__.py:1376
↓ 1 callers
Method
backtrack
Use the node-level invariant ones for basic parsing operations (push/pop/shift). These still will operate on the stack; but they won'
src/blib2to3/pgen2/parse.py:86
↓ 1 callers
Function
bar
This is another docstring with more lines of text
tests/data/simple_cases/docstring.py:20
↓ 1 callers
Function
black_runner
(version: str, black_repo: Path)
gallery/gallery.py:187
↓ 1 callers
Function
blackify
(base_branch: str, black_command: str, logger: logging.Logger)
scripts/migrate-black.py:15
↓ 1 callers
Method
calcfirst
(self, name: Text)
src/blib2to3/pgen2/pgen.py:148
↓ 1 callers
Method
call
(param)
tests/data/simple_cases/fmtonoff5.py:52
↓ 1 callers
Method
can_advance
(self, to: int)
src/blib2to3/pgen2/driver.py:108
↓ 1 callers
Function
can_be_split
Return False if the line cannot be split *for sure*. This is not an exhaustive search but a cheap heuristic that we can use to avoid some unf
src/black/lines.py:843
↓ 1 callers
Function
can_omit_invisible_parens
Does `rhs.body` have a shape safe to reformat without optional parens around it? Returns True for only a subset of potentially nice looking forma
src/black/lines.py:879
↓ 1 callers
Function
char_width
Return the width of a single character as it would be displayed in a terminal or editor (which respects Unicode East Asian Width). Full width
src/black/strings.py:285
↓ 1 callers
Function
child_towards
Return the child of `ancestor` that contains `descendant`.
src/black/nodes.py:455
↓ 1 callers
Function
children_contains_fmt_on
Determine if children have formatting switched on.
src/black/comments.py:314
↓ 1 callers
Method
classify
Turn a token into a label. (Internal) Depending on whether the value is a soft-keyword or not, this function may return multiple lab
src/blib2to3/pgen2/parse.py:332
↓ 1 callers
Method
compat
(self, token: Tuple[int, Text], iterable: Iterable[TokenInfo])
src/blib2to3/pgen2/tokenize.py:266
↓ 1 callers
Function
container_of
Return `leaf` or one of its ancestors that is the topmost container of it. By "container" we mean a node where `leaf` is the very first child.
src/black/nodes.py:480
↓ 1 callers
Function
convert_one_fmt_off_pair
Convert content of a single `# fmt: off`/`# fmt: on` into a standalone comment. Returns True if a pair was converted.
src/black/comments.py:146
↓ 1 callers
Function
cors
(allow_headers: Iterable[str])
src/blackd/middlewares.py:21
↓ 1 callers
Function
detect_target_versions
Detect the version to target based on the nodes used.
src/black/__init__.py:1283
↓ 1 callers
Method
determine_route
(self, value: Optional[Text] = None, force: bool = False)
src/blib2to3/pgen2/parse.py:117
↓ 1 callers
Method
do_match
Returns: * Ok(string_indices) such that for each index, `line.leaves[index]` is our target string if a match was able
src/black/trans.py:204
↓ 1 callers
Method
do_splitter_match
BaseStringSplitter asks its clients to override this method instead of `StringTransformer.do_match(...)`. Follows the same p
src/black/trans.py:995
↓ 1 callers
Method
do_transform
Yields: * Ok(new_line) where new_line is the new transformed line. OR * Err(CannotTransform) if the t
src/black/trans.py:217
↓ 1 callers
Function
download_and_extract_top_packages
( directory: Path, workers: int = 8, limit: slice = DEFAULT_SLICE, )
gallery/gallery.py:119
↓ 1 callers
Function
evalString
(s: Text)
src/blib2to3/pgen2/literals.py:47
↓ 1 callers
Function
f
()
tests/data/simple_cases/slices.py:22
↓ 1 callers
Method
f
(self)
tests/data/simple_cases/fmtskip6.py:2
↓ 1 callers
Function
filter_cached
Split an iterable of paths in `sources` into two sets. The first contains paths of files that modified on disk or are not in the cache. The o
src/black/cache.py:68
↓ 1 callers
Function
find_cookie
(line: bytes)
src/blib2to3/pgen2/tokenize.py:340
↓ 1 callers
Function
find_pyproject_toml
Find the absolute filepath to a pyproject.toml if it exists
src/black/files.py:92
↓ 1 callers
Method
finish_off
Create additional useful structures. (Internal).
src/blib2to3/pgen2/conv.py:248
↓ 1 callers
Function
fix_docstring
(docstring: str, prefix: str)
src/black/strings.py:75
↓ 1 callers
Function
fixup_ast_constants
Map ast nodes deprecated in 3.8 to Constant.
src/black/parsing.py:278
↓ 1 callers
Function
foo
(answer=(p := 42))
tests/data/py_38/pep_572_remove_parens.py:26
↓ 1 callers
Function
foo
(answer=(p := 42))
tests/data/py_38/pep_572.py:14
↓ 1 callers
Function
format_complex_number
Formats a complex string like `10j`
src/black/numerics.py:28
↓ 1 callers
Function
format_hex
Formats a hexadecimal string like "0x12B3"
src/black/numerics.py:7
↓ 1 callers
Function
format_ipynb_string
Format Jupyter notebook. Operate cell-by-cell, only on code cells, only for Python notebooks. If the ``.ipynb`` originally had a trailing new
src/black/__init__.py:1017
↓ 1 callers
Function
format_repo_with_version
( repo: Path, from_branch: Optional[str], black_repo: Path, black_version: BlackVersion, i
gallery/gallery.py:198
↓ 1 callers
Function
format_repos
(repos: Tuple[Path, ...], options: Namespace)
gallery/gallery.py:225
↓ 1 callers
Function
format_scientific_notation
Formats a numeric string utilizing scentific notation
src/black/numerics.py:15
↓ 1 callers
Method
from_configuration
( cls, *, check: bool, diff: bool, color: bool = False )
src/black/__init__.py:105
↓ 1 callers
Function
func
()
tests/data/simple_cases/comments3.py:5
↓ 1 callers
Function
func
()
tests/data/py_37/python37.py:15
↓ 1 callers
Function
function
Docstring comes first. Possibly many lines.
tests/data/simple_cases/comments.py:32
↓ 1 callers
Function
gen_python_files
Generate all files under `path` whose paths are not excluded by the `exclude_regex`, `extend_exclude`, or `force_exclude` regexes, but are inc
src/black/files.py:298
↓ 1 callers
Function
generate_comments
Clean the prefix of the `leaf` and generate comments from it, if any. Comments in lib2to3 are shoved into the whitespace prefix. This happens
src/black/comments.py:53
↓ 1 callers
Function
generate_ignored_nodes
Starting from the container of `leaf`, generate all leaves until `# fmt: on`. If comment is skip, returns leaf only. Stops at the end of the
src/black/comments.py:214
↓ 1 callers
Method
generate_matches
Generator yielding matches for a sequence of nodes. Args: nodes: sequence of nodes Yields: (count,
src/blib2to3/pytree.py:822
↓ 1 callers
Function
generate_tokens
The generate_tokens() generator requires one argument, readline, which must be a callable object which provides the same interface as the
src/blib2to3/pgen2/tokenize.py:409
↓ 1 callers
Function
generate_trailers_to_omit
Generate sets of closing bracket IDs that should be omitted in a RHS. Brackets can be omitted if the entire trailer up to and including a pre
src/black/linegen.py:1428
↓ 1 callers
Function
get_archive_manager
(local_file: str)
gallery/gallery.py:79
↓ 1 callers
Method
get_cache_key
(self)
src/black/mode.py:209
↓ 1 callers
Function
get_features_used
Return a set of (relatively) new Python features used in this file. Currently looking for: - f-strings; - self-documenting expressions in
src/black/__init__.py:1150
↓ 1 callers
Function
get_first_archive_member
(archive: ArchiveKind)
gallery/gallery.py:88
↓ 1 callers
Function
get_future_imports
Return a set of __future__ imports in the file.
src/black/__init__.py:1293
↓ 1 callers
Function
get_grammars
(target_versions: Set[TargetVersion])
src/black/parsing.py:51
↓ 1 callers
Function
get_grammars
(target_versions: Set[TargetVersion])
tests/data/py_310/pattern_matching_generic.py:12
↓ 1 callers
Function
get_imports_from_children
(children: List[LN])
src/black/__init__.py:1297
↓ 1 callers
Function
get_leaves_inside_matching_brackets
Return leaves that are inside matching brackets. The input `leaves` can have non-matching brackets at the head or tail parts. Matching bracke
src/black/brackets.py:355
↓ 1 callers
Function
get_main_revision
()
scripts/diff_shades_gha_helper.py:81
↓ 1 callers
Method
get_open_lsqb
Return the most recent opening square bracket (if any).
src/black/brackets.py:212
↓ 1 callers
Function
get_package_source
(package: str, version: Optional[str])
gallery/gallery.py:64
↓ 1 callers
Function
get_pr_revision
(pr: int)
scripts/diff_shades_gha_helper.py:90
↓ 1 callers
Function
get_pypi_download_url
(package: str, version: Optional[str])
gallery/gallery.py:33
↓ 1 callers
Function
get_pypi_version
()
scripts/diff_shades_gha_helper.py:96
↓ 1 callers
Function
get_sources
Compute the set of files to be formatted.
src/black/__init__.py:622
↓ 1 callers
Function
get_top_packages
()
gallery/gallery.py:57
↓ 1 callers
Function
git
(*args: str)
scripts/migrate-black.py:11
↓ 1 callers
Function
git_create_repository
(repo: Path)
gallery/gallery.py:131
↓ 1 callers
Method
has_custom_splits
Returns: True iff @string is associated with a set of custom splits.
src/black/trans.py:353
↓ 1 callers
Method
has_magic_trailing_comma
Return True if we have a magic trailing comma, that is when: - there's a trailing comma here - it's not a one-tuple - it's not
src/black/lines.py:299
↓ 1 callers
Function
infer_target_version
Infer Black's target version from the project metadata in pyproject.toml. Supports the PyPA standard format (PEP 621): https://packaging.pyth
src/black/files.py:131
↓ 1 callers
Function
init_repos
(options: Namespace)
gallery/gallery.py:153
← previous
next →
201–300 of 1,067, ranked by callers