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
↓ 2 callers
Function
_generate_pickle_name
(gt: Path, cache_dir: Optional[Path] = None)
src/blib2to3/pgen2/driver.py:243
↓ 2 callers
Method
_prefer_paren_wrap_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:1175
↓ 2 callers
Method
_update
(self, attrs: Dict[str, Any])
src/blib2to3/pgen2/grammar.py:117
↓ 2 callers
Method
append_child
Equivalent to 'node.children.append(child)'. This method also sets the child's parent attribute appropriately.
src/blib2to3/pytree.py:354
↓ 2 callers
Function
append_to_line
Append `leaf` to current line or to new line if appending impossible.
src/black/linegen.py:1006
↓ 2 callers
Function
bracket_split_build_line
Return a new line with given `leaves` and respective comments from `original`. If it's the head component, brackets will be tracked so trailing c
src/black/linegen.py:866
↓ 2 callers
Function
bracket_split_succeeded_or_raise
Raise :exc:`CannotSplit` if the last left- or right-hand split failed. Do nothing otherwise. A left- or right-hand split is based on a pair
src/black/linegen.py:840
↓ 2 callers
Function
check_file
( subdir: str, filename: str, mode: black.Mode, *, data: bool = True )
tests/test_format.py:25
↓ 2 callers
Function
check_stability_and_equivalence
Perform stability and equivalence checks. Raise AssertionError if source and destination contents are not equivalent, or if a second pass of
src/black/__init__.py:909
↓ 2 callers
Method
clone
Return a cloned (deep) copy of self. This must be implemented by the concrete subclass.
src/blib2to3/pytree.py:112
↓ 2 callers
Method
contains_multiline_strings
(self)
src/black/lines.py:296
↓ 2 callers
Function
contains_pragma_comment
Returns: True iff one of the comments in @comment_list is a pragma used by one of the more common static analysis tools for pytho
src/black/comments.py:324
↓ 2 callers
Method
contains_uncollapsable_type_comments
(self)
src/black/lines.py:227
↓ 2 callers
Function
convert
Convert raw node information to a Node or Leaf instance. This is passed to the parser driver which calls it whenever a reduction of a gr
src/blib2to3/pytree.py:486
↓ 2 callers
Function
count_chars_in_width
Count the number of characters in `line_str` that would fit in a terminal or editor of `max_width` (which respects Unicode East Asian Width).
src/black/strings.py:324
↓ 2 callers
Method
delimiter_count_with_priority
Return the number of delimiters with the given `priority`. If no `priority` is passed, defaults to max priority on the line.
src/black/brackets.py:148
↓ 2 callers
Function
download_and_extract
(package: str, version: Optional[str], directory: Path)
gallery/gallery.py:95
↓ 2 callers
Function
dump_to_file
Dump `output` to a temporary file. Return path to the file.
src/black/output.py:96
↓ 2 callers
Method
eat
(self, point: int)
src/blib2to3/pgen2/driver.py:79
↓ 2 callers
Method
err
(self)
src/black/rusty.py:23
↓ 2 callers
Method
fail
(*args: Any, **kwargs: Any)
tests/test_black.py:1526
↓ 2 callers
Function
find_project_root
Return a directory containing .git, .hg, or pyproject.toml. That directory will be a common parent of all files and directories passed in `sr
src/black/files.py:46
↓ 2 callers
Function
find_user_pyproject_toml
r"""Return the path to the top-level user configuration for black. This looks for ~\.black on Windows and ~/.config/black on Linux and other
src/black/files.py:214
↓ 2 callers
Function
first_leaf_of
Returns the first leaf of the node tree.
src/black/nodes.py:505
↓ 2 callers
Function
format_file_in_place
Format file under `src` path. Return True if changed. If `write_back` is DIFF, write a diff to stdout. If it is YES, write reformatted code t
src/black/__init__.py:794
↓ 2 callers
Function
format_stdin_to_stdout
Format file on stdin. Return True if changed. If content is None, it's read from sys.stdin. If `write_back` is YES, write reformatted code b
src/black/__init__.py:858
↓ 2 callers
Function
format_str
Reformat a string and return new contents. `mode` determines formatting options, such as how many characters per line are allowed. Example:
src/black/__init__.py:1049
↓ 2 callers
Function
fstring_contains_expr
(s: str)
src/black/trans.py:1253
↓ 2 callers
Method
generate_matches
Generator yielding all matches for this pattern. Default implementation for non-wildcard patterns.
src/blib2to3/pytree.py:590
↓ 2 callers
Function
get_base_dir
(data: bool)
tests/util.py:146
↓ 2 callers
Function
get_cache_dir
Get the cache directory used by black. Users can customize this directory on all systems using `BLACK_CACHE_DIR` environment variable. By def
src/black/cache.py:21
↓ 2 callers
Function
get_gitignore
Return a PathSpec matching gitignore content if present.
src/black/files.py:234
↓ 2 callers
Function
get_token
Return randomly generated token to mask IPython magic with. For example, if 'magic' was `%matplotlib inline`, then a possible token to mask i
src/black/handle_ipynb_magics.py:171
↓ 2 callers
Function
git_add_and_commit
(msg: str, repo: Path)
gallery/gallery.py:136
↓ 2 callers
Function
git_switch_branch
( branch: str, repo: Path, new: bool = False, from_branch: Optional[str] = None )
gallery/gallery.py:141
↓ 2 callers
Function
insert_str_child
(child: LN)
src/black/trans.py:2372
↓ 2 callers
Function
insert_str_child_factory
Factory for a convenience function that is used to orphan @string_leaf and then insert multiple new leaves into the same part of the node
src/black/trans.py:2323
↓ 2 callers
Function
is_fmt_on
Determine whether formatting is switched on within a container. Determined by whether the last `# fmt:` comment is `on` or `off`.
src/black/comments.py:301
↓ 2 callers
Function
is_lpar_token
(nl: NL)
src/black/nodes.py:875
↓ 2 callers
Function
is_name_token
(nl: NL)
src/black/nodes.py:871
↓ 2 callers
Function
is_one_sequence_between
Return True if content between `opening` and `closing` is a one-sequence.
src/black/nodes.py:577
↓ 2 callers
Function
is_one_tuple
Return True if `node` holds a tuple with one element, with or without parens.
src/black/nodes.py:550
↓ 2 callers
Function
is_rpar_token
(nl: NL)
src/black/nodes.py:879
↓ 2 callers
Function
is_stub_body
Return True if `node` is a simple statement containing an ellipsis.
src/black/nodes.py:732
↓ 2 callers
Function
is_stub_suite
Return True if `node` is a suite with a stub body.
src/black/nodes.py:719
↓ 2 callers
Function
jupyter_dependencies_are_installed
(*, verbose: bool, quiet: bool)
src/black/handle_ipynb_magics.py:59
↓ 2 callers
Function
lib2to3_parse
Given a string with source, return the lib2to3 Node.
src/black/parsing.py:84
↓ 2 callers
Function
load_grammar
Load the grammar (maybe from a pickle).
src/blib2to3/pgen2/driver.py:254
↓ 2 callers
Method
make_label
(self, c: PgenGrammar, label: Text)
src/blib2to3/pgen2/pgen.py:89
↓ 2 callers
Method
mark
Mark `leaf` with bracket-related metadata. Keep track of delimiters. All leaves receive an int `bracket_depth` field that stores how deep
src/black/brackets.py:76
↓ 2 callers
Function
maybe_install_uvloop
If our environment has uvloop installed we use it. This is called only from command-line entry points to avoid interfering with the parent pr
src/black/concurrency.py:26
↓ 2 callers
Function
normalize_invisible_parens
Make existing optional parentheses invisible or create new ones. `parens_after` is a set of string leaf values immediately after which parens
src/black/linegen.py:1113
↓ 2 callers
Function
normalize_string_prefix
Make all string prefixes lowercase.
src/black/strings.py:153
↓ 2 callers
Method
parse_string
Parse a string and return the syntax tree.
src/blib2to3/pgen2/driver.py:208
↓ 2 callers
Method
parse_tokens
Parse a series of tokens and return the syntax tree.
src/blib2to3/pgen2/driver.py:126
↓ 2 callers
Function
patched_main
()
src/black/__init__.py:1438
↓ 2 callers
Method
raise_error
(self, msg: str, *args: Any)
src/blib2to3/pgen2/pgen.py:369
↓ 2 callers
Function
re_compile_maybe_verbose
Compile a regular expression string in `regex`. If it contains newlines, use verbose mode.
src/black/__init__.py:178
↓ 2 callers
Function
read_cache
Read the cache if it exists and is well formed. If it is not well formed, the call to write_cache later should resolve the issue.
src/black/cache.py:40
↓ 2 callers
Function
set_output
(name: str, value: str)
scripts/diff_shades_gha_helper.py:50
↓ 2 callers
Function
some_func
( unformatted, args )
tests/data/simple_cases/fmtskip8.py:2
↓ 2 callers
Function
transform_line
Transform a `line`, potentially splitting it into many lines. They should fit in the allotted `line_length` but might not be able to. `featu
src/black/linegen.py:496
↓ 2 callers
Method
update_sibling_maps
(self)
src/blib2to3/pytree.py:368
↓ 2 callers
Function
wrap_stream_for_windows
Wrap stream with colorama's wrap_stream so colors are shown on Windows. If `colorama` is unavailable, the original stream is returned unmodi
src/black/files.py:382
↓ 2 callers
Function
write_cache
Update the cache file.
src/black/cache.py:84
↓ 1 callers
Method
__init__
Constructor. The grammar argument is a grammar.Grammar instance; see the grammar module for more information. The parser is
src/blib2to3/pgen2/parse.py:175
↓ 1 callers
Method
__init__
(self)
tests/test_black.py:105
↓ 1 callers
Method
__new__
Constructor that prevents Base from being instantiated.
src/blib2to3/pytree.py:79
↓ 1 callers
Method
__post_init__
You are in a twisty little maze of passages.
src/black/linegen.py:466
↓ 1 callers
Method
_addtoken
(self, ilabel: int, type: int, value: Text, context: Context)
src/blib2to3/pgen2/parse.py:287
↓ 1 callers
Function
_assert_format_inner
( source: str, expected: Optional[str] = None, mode: black.Mode = DEFAULT_MODE, *, fast: b
tests/util.py:114
↓ 1 callers
Method
_assert_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:1936
↓ 1 callers
Method
_assign_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:1971
↓ 1 callers
Method
_bare_name_matches
Special optimized matcher for bare_name.
src/blib2to3/pytree.py:896
↓ 1 callers
Function
_cached_compile
(pattern: str)
src/black/strings.py:175
↓ 1 callers
Function
_can_omit_closing_paren
See `can_omit_invisible_parens`.
src/black/lines.py:988
↓ 1 callers
Function
_can_omit_opening_paren
See `can_omit_invisible_parens`.
src/black/lines.py:963
↓ 1 callers
Function
_combinations
(*l)
src/blib2to3/pgen2/tokenize.py:81
↓ 1 callers
Method
_dict_or_lambda_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:2018
↓ 1 callers
Method
_else_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:1909
↓ 1 callers
Method
_eq
Compare two nodes for equality. This is called by __eq__ and __ne__. It is only called if the two nodes have the same type.
src/blib2to3/pytree.py:98
↓ 1 callers
Function
_err
(message: Optional[str] = None, nl: bool = True, **styles: Any)
src/black/output.py:24
↓ 1 callers
Function
_generate_ignored_nodes_from_fmt_skip
Generate all leaves that should be ignored by the `# fmt: skip` from `leaf`.
src/black/comments.py:259
↓ 1 callers
Method
_get_break_idx
This method contains the algorithm that StringSplitter uses to determine which character to split each string at. Args:
src/black/trans.py:1660
↓ 1 callers
Method
_get_illegal_split_indices
(self, string: str)
src/black/trans.py:1649
↓ 1 callers
Function
_get_last_non_comment_leaf
(line: Line)
src/black/linegen.py:957
↓ 1 callers
Method
_get_max_string_length
Calculates the max string length used when attempting to determine whether or not the target string is responsible for causing the li
src/black/trans.py:1065
↓ 1 callers
Function
_get_normal_name
Imitates get_normal_name in tokenizer.c.
src/blib2to3/pgen2/tokenize.py:299
↓ 1 callers
Method
_get_string_operator_leaves
(self, leaves: Iterable[Leaf])
src/black/trans.py:1776
↓ 1 callers
Method
_iter_fexpr_slices
Yields: All ranges of @string which, if @string were to be split there, would result in the splitting of an f-express
src/black/trans.py:1638
↓ 1 callers
Method
_iter_nameescape_slices
Yields: All ranges of @string which, if @string were to be split there, would result in the splitting of an \\N{...}
src/black/trans.py:1607
↓ 1 callers
Method
_iterative_matches
Helper to iteratively yield the matches.
src/blib2to3/pytree.py:867
↓ 1 callers
Method
_maybe_empty_lines
(self, current_line: Line)
src/black/lines.py:568
↓ 1 callers
Method
_maybe_empty_lines_for_class_or_def
( self, current_line: Line, before: int )
src/black/lines.py:643
↓ 1 callers
Method
_maybe_normalize_string_quotes
(self, leaf: Leaf)
src/black/trans.py:1745
↓ 1 callers
Function
_maybe_split_omitting_optional_parens
( rhs: RHSResult, line: Line, mode: Mode, features: Collection[Feature] = (), omit: Collec
src/black/linegen.py:734
↓ 1 callers
Function
_maybe_wrap_cms_in_parens
When enabled and safe, wrap the multiple context managers in invisible parens. It is only safe when `features` contain Feature.PARENTHESIZED_CONT
src/black/linegen.py:1250
↓ 1 callers
Method
_merge_one_string_group
Merges one string group where the first string in the group is `LL[string_idx]`. Returns: A tuple of `(num_of_st
src/black/trans.py:546
↓ 1 callers
Method
_merge_string_group
Merges string groups (i.e. set of adjacent strings). Each index from `string_indices` designates one string group's first le
src/black/trans.py:491
↓ 1 callers
Function
_newer
Inquire whether file a was written since file b.
src/blib2to3/pgen2/driver.py:279
← previous
next →
101–200 of 1,067, ranked by callers