MCPcopy
hub / github.com/psf/black / sub_twice

Function sub_twice

src/black/strings.py:29–35  ·  view source on GitHub ↗

Replace `regex` with `replacement` twice on `original`. This is used by string normalization to perform replaces on overlapping matches.

(regex: Pattern[str], replacement: str, original: str)

Source from the content-addressed store, hash-verified

27
28
29def sub_twice(regex: Pattern[str], replacement: str, original: str) -> str:
30 """Replace `regex` with `replacement` twice on `original`.
31
32 This is used by string normalization to perform replaces on
33 overlapping matches.
34 """
35 return regex.sub(replacement, regex.sub(replacement, original))
36
37
38def has_triple_quotes(string: str) -> bool:

Callers 2

normalize_string_quotesFunction · 0.85
normalize_fstring_quotesFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected