MCPcopy Create free account

hub / github.com/psf/black / functions

Functions1,067 in github.com/psf/black

↓ 65 callersMethodappend
Add a new `leaf` to the end of the line. Unless `preformatted` is True, the `leaf` will receive a new consistent whitespace prefix an
src/black/lines.py:61
↓ 44 callersFunctionread_data
read_data('test_name') -> 'input', 'output
tests/util.py:167
↓ 25 callersFunctionassert_format
Convenience function to check that Black formats as expected. You can pass @minimum_version if you're passing code with newer syntax to guard
tests/util.py:64
↓ 24 callersFunctionformat_cell
Format code in given cell of Jupyter notebook. General idea is: - if cell has trailing semicolon, remove it; - if cell has IPython m
src/black/__init__.py:968
↓ 24 callersMethodmatch
Does this pattern exactly match a node? Returns True if it matches, False if not. If results is not None, it must be a dict
src/blib2to3/pytree.py:554
↓ 22 callersFunctioncache_dir
(exists: bool = True)
tests/test_black.py:81
↓ 19 callersFunctionreplace
(m: Match[str])
src/black/strings.py:260
↓ 18 callersFunctionany
(*choices)
src/blib2to3/pgen2/tokenize.py:73
↓ 18 callersMethodpop
Pop a nonterminal. (Internal)
src/blib2to3/pgen2/parse.py:380
↓ 16 callersMethodreplace
Replace this node with a new one in the parent.
src/blib2to3/pytree.py:136
↓ 15 callersFunctionis_valid_index
Returns: True iff @idx is positive AND seq[@idx] does NOT raise an IndexError.
src/black/trans.py:2400
↓ 15 callersMethodvisit
Main method to visit `node` and its children. It tries to find a `visit_*()` method for the given `node.type`, like `visit_simple_stm
src/black/nodes.py:147
↓ 14 callersMethodassertFormatEqual
(self, expected: str, actual: str)
tests/util.py:142
↓ 14 callersFunctionget_case_path
Get case path from name
tests/util.py:156
↓ 14 callersFunctionis_valid_index_factory
Examples: ``` my_list = [1, 2, 3] is_valid_index = is_valid_index_factory(my_list) assert is_valid_index(0)
src/black/trans.py:2384
↓ 13 callersFunctionassert_collected_sources
( src: Sequence[Union[str, Path]], expected: Sequence[Union[str, Path]], *, ctx: Optional[Fake
tests/test_black.py:2138
↓ 12 callersMethodline
Generate a line. If the line is empty, only emit if it makes sense. If the line is too long, split it first and then generate.
src/black/linegen.py:102
↓ 11 callersMethodvisit_default
Default `visit_*()` implementation. Recurses to children of `node`.
src/black/linegen.py:129
↓ 10 callersMethodcomments_after
Generate comments that should appear directly after `leaf`.
src/black/lines.py:398
↓ 10 callersMethodparse
Pre-conditions: * @leaves[@string_idx].type == token.STRING Returns: The index directly after the last leaf
src/black/trans.py:2253
↓ 9 callersFunctionTErr
(T)ransform Err Convenience function used when working with the TResult type.
src/black/trans.py:79
↓ 9 callersMethodappend
(self)
tests/data/preview/long_strings__regression.py:109
↓ 9 callersMethodinsert_child
Equivalent to 'node.children.insert(i, child)'. This method also sets the child's parent attribute appropriately.
src/blib2to3/pytree.py:344
↓ 9 callersMethodremove
Remove the node from the tree. Returns the position of the node in its parent's children before it was removed.
src/blib2to3/pytree.py:176
↓ 8 callersFunctiondiff
Return a unified diff string between strings `a` and `b`.
src/black/output.py:58
↓ 8 callersFunctionformat_file_contents
Reformat contents of a file and return new contents. If `fast` is False, additionally confirm that the reformatted code is valid by calling :
src/black/__init__.py:922
↓ 8 callersFunctionout
(message: Optional[str] = None, nl: bool = True, **styles: Any)
src/black/output.py:33
↓ 7 callersMethodclone
(self)
src/black/lines.py:449
↓ 7 callersMethoddone
Increment the counter for successful reformatting. Write out a message.
src/black/report.py:35
↓ 7 callersFunctionerr
(message: Optional[str] = None, nl: bool = True, **styles: Any)
src/black/output.py:37
↓ 7 callersFunctionparent_type
Returns: @node.parent.type, if @node is not None and has a parent. OR None, otherwise.
src/black/nodes.py:442
↓ 7 callersMethodpath_ignored
(self, path: Path, message: str)
src/black/report.py:56
↓ 7 callersMethodrun
Load the grammar tables from the text files written by pgen.
src/blib2to3/pgen2/conv.py:49
↓ 7 callersFunctionwrap_in_parentheses
Wrap `child` in parentheses. This replaces `child` with an atom holding the parentheses and the old child. That requires moving the prefix.
src/black/nodes.py:827
↓ 6 callersFunctionappend_leaves
Append leaves (taken from @old_line) to @new_line, making sure to fix the underlying Node structure where appropriate. All of the leaves
src/black/lines.py:728
↓ 6 callersMethodchanged
(self)
src/blib2to3/pytree.py:169
↓ 6 callersMethodcompare_results
Helper method to test the value and exit code of a click Result.
tests/test_black.py:1785
↓ 6 callersMethodfailed
Increment the counter for failed reformatting. Write out a message.
src/black/report.py:51
↓ 6 callersFunctionget_string_prefix
Pre-conditions: * assert_is_leaf_string(@string) Returns: @string's prefix (e.g. '', 'r', 'f', or 'rf').
src/black/strings.py:99
↓ 6 callersMethodgettoken
(self)
src/blib2to3/pgen2/pgen.py:362
↓ 6 callersMethodinvalidate_sibling_maps
(self)
src/blib2to3/pytree.py:364
↓ 6 callersFunctioninvokeBlack
( args: List[str], exit_code: int = 0, ignore_config: bool = True )
tests/test_black.py:125
↓ 6 callersFunctionis_empty_par
(leaf: Leaf)
src/black/nodes.py:766
↓ 6 callersMethodload
Load the grammar tables from a pickle file.
src/blib2to3/pgen2/grammar.py:121
↓ 6 callersMethodloads
Load the grammar tables from a pickle bytes object.
src/blib2to3/pgen2/grammar.py:127
↓ 5 callersMethodaddarc
(self, next: "NFAState", label: Optional[Text] = None)
src/blib2to3/pgen2/pgen.py:384
↓ 5 callersFunctionget_cache_file
(mode: Mode)
src/black/cache.py:58
↓ 5 callersFunctionis_line_short_enough
For non-multiline strings, return True if `line` is no longer than `line_length`. For multiline strings, looks at the context around `line` to det
src/black/lines.py:752
↓ 5 callersFunctionis_multiline_string
Return True if `leaf` is a multiline string that actually spans many lines.
src/black/nodes.py:714
↓ 5 callersFunctioniter_fexpr_spans
Yields spans corresponding to expressions in a given f-string. Spans are half-open ranges (left inclusive, right exclusive). Assumes the
src/black/trans.py:1206
↓ 5 callersMethodleaves
(self)
src/blib2to3/pytree.py:219
↓ 5 callersFunctionlist_comments
Return a list of :class:`ProtoComment` objects parsed from the given `prefix`.
src/black/comments.py:77
↓ 5 callersMethodmax_delimiter_priority
Return the highest priority of a delimiter found on the line. Values are consistent with what `is_split_*_delimiter()` return. Raises
src/black/brackets.py:140
↓ 5 callersFunctionmaybe_make_parens_invisible_in_atom
If it's safe, make the parens in the atom `node` invisible, recursively. Additionally, remove repeated, adjacent invisible parens from the atom `n
src/black/linegen.py:1335
↓ 5 callersFunctionread_jupyter_notebook
(subdir_name: str, name: str, data: bool = True)
tests/util.py:191
↓ 5 callersFunctionreplace_child
Side Effects: * If @old_child.parent is set, replace @old_child with @new_child in @old_child's underlying Node structure.
src/black/nodes.py:463
↓ 5 callersFunctiontype_repr
(type_num: int)
src/blib2to3/pytree.py:40
↓ 4 callersFunctionassert_is_leaf_string
Checks the pre-condition that @string has the format that you would expect of `leaf.value` where `leaf` is some Leaf such that `leaf.type ==
src/black/strings.py:118
↓ 4 callersFunctionchange_directory
Context manager to temporarily chdir to a different directory.
tests/util.py:204
↓ 4 callersMethodcontains_standalone_comments
If so, needs to be split before emitting.
src/black/lines.py:219
↓ 4 callersMethodcopy
Copy the grammar.
src/blib2to3/pgen2/grammar.py:131
↓ 4 callersFunctionf
()
tests/data/py_39/python39.py:4
↓ 4 callersFunctionhas_triple_quotes
Returns: True iff @string starts with three quotation characters.
src/black/strings.py:44
↓ 4 callersFunctionhttp_get
(url: str, *, is_json: bool = True, **kwargs: Any)
scripts/diff_shades_gha_helper.py:58
↓ 4 callersFunctionnormalize_path_maybe_ignore
Normalize `path`. May return `None` if `path` was ignored. `report` is where "path ignored" output goes.
src/black/files.py:248
↓ 4 callersFunctionnormalize_string_quotes
Prefer double quotes but only if it doesn't cause more escaping. Adds or removes backslashes as appropriate. Doesn't parse and fix strings ne
src/black/strings.py:179
↓ 4 callersFunctionpreceding_leaf
Return the first leaf that precedes `node`, if any.
src/black/nodes.py:408
↓ 4 callersFunctionread_data_from_file
(file_name: Path)
tests/util.py:172
↓ 3 callersMethod_get_key
Returns: A unique identifier that is used internally to map @string to a group of custom splits.
src/black/trans.py:314
↓ 3 callersFunction_get_str_args
(args: List[ast.expr])
src/black/handle_ipynb_magics.py:302
↓ 3 callersFunction_is_ipython_magic
Check if attribute is IPython magic. Note that the source of the abstract syntax tree will already have been processed by IPython's Trans
src/black/handle_ipynb_magics.py:287
↓ 3 callersMethodany_open_brackets
Return True if there is an yet unmatched open bracket on the line.
src/black/brackets.py:136
↓ 3 callersFunctioncheck
( string: str, expected_spans: List[Tuple[int, int]], expected_slices: List[str] )
tests/test_trans.py:7
↓ 3 callersFunctioncolor_diff
Inject the ANSI color codes to the diff.
src/black/output.py:79
↓ 3 callersMethodcontains_unsplittable_type_ignore
(self)
src/black/lines.py:263
↓ 3 callersFunctiondecode_bytes
Return a tuple of (decoded_contents, encoding, newline). `newline` is either CRLF or LF but `decoded_contents` is decoded with universal newl
src/black/__init__.py:1133
↓ 3 callersMethoddump
Dump the grammar tables to a pickle file.
src/blib2to3/pgen2/grammar.py:100
↓ 3 callersFunctionensure_visible
Make sure parentheses are visible. They could be invisible as part of some statements (see :func:`normalize_invisible_parens` and :func:`visi
src/black/nodes.py:859
↓ 3 callersMethodenumerate_with_length
Return an enumeration of leaves with their length. Stops prematurely on multiline strings and standalone comments.
src/black/lines.py:428
↓ 3 callersMethodexpect
(self, type: int, value: Optional[Any] = None)
src/blib2to3/pgen2/pgen.py:353
↓ 3 callersFunctionformat_float_or_int_string
Formats a float string like "1.0".
src/black/numerics.py:35
↓ 3 callersFunctiongenerate_matches
Generator yielding matches for a sequence of patterns and nodes. Args: patterns: a sequence of patterns nodes: a sequence of
src/blib2to3/pytree.py:962
↓ 3 callersFunctionget_cache_info
Return the information used to check if a file is already formatted or not.
src/black/cache.py:62
↓ 3 callersFunctiongroup
(*choices)
src/blib2to3/pgen2/tokenize.py:69
↓ 3 callersFunctionis_empty_lpar
(leaf: Leaf)
src/black/nodes.py:770
↓ 3 callersFunctionis_empty_rpar
(leaf: Leaf)
src/black/nodes.py:774
↓ 3 callersFunctionis_type_comment
Return True if the given leaf is a special comment. Only returns true for type comments for now.
src/black/nodes.py:819
↓ 3 callersFunctionis_vararg
Return True if `leaf` is a star or double star in a vararg or kwarg. If `within` includes VARARGS_PARENTS, this applies to function signatures.
src/black/nodes.py:691
↓ 3 callersFunctionline_to_string
Returns the string representation of @line. WARNING: This is known to be computationally expensive.
src/black/lines.py:1005
↓ 3 callersFunctionnormalize_prefix
Leave existing extra newlines if not `inside_brackets`. Remove everything else. Note: don't use backslashes for formatting or you'll lose you
src/black/linegen.py:1095
↓ 3 callersMethodok
(self)
src/black/rusty.py:15
↓ 3 callersMethodparse_rhs
(self)
src/blib2to3/pgen2/pgen.py:288
↓ 3 callersMethodpre_order
Return a pre-order iterator for the tree. This must be implemented by the concrete subclass.
src/blib2to3/pytree.py:128
↓ 3 callersMethodpush
Push a nonterminal. (Internal)
src/blib2to3/pgen2/parse.py:368
↓ 3 callersFunctionstr_width
Return the width of `line_str` as it would be displayed in a terminal or editor (which respects Unicode East Asian Width). You could utilize
src/black/strings.py:311
↓ 3 callersFunctionsupports_feature
(target_versions: Set[TargetVersion], feature: Feature)
src/black/mode.py:149
↓ 3 callersFunctionunwrap_singleton_parenthesis
Returns `wrapped` if `node` is of the shape ( wrapped ). Parenthesis can be optional. Returns None otherwise
src/black/nodes.py:845
↓ 2 callersFunction_assert_format_equal
(expected: str, actual: str)
tests/util.py:36
↓ 2 callersFunction_first_right_hand_split
Split the line into head, body, tail starting with the last bracket pair. Note: this function should not have side effects. It's relied upon by
src/black/linegen.py:686
↓ 2 callersFunction_format_str_once
(src_contents: str, *, mode: Mode)
src/black/__init__.py:1088
next →1–100 of 1,067, ranked by callers