]>
git.madduck.net Git - etc/vim.git/blobdiff - black.py
madduck's git repository
Every one of the projects in this repository is available at the canonical
URL git://git.madduck.net/madduck/pub/<projectpath> — see
each project's metadata for the exact URL.
All patches and comments are welcome. Please squash your changes to logical
commits before using git-format-patch and git-send-email to
patches@ git. madduck. net .
If you'd read over the Git project's submission guidelines and adhered to them,
I'd be especially grateful.
SSH access, as well as push access can be individually
arranged .
If you use my repositories frequently, consider adding the following
snippet to ~/.gitconfig and using the third clone URL listed for each
project:
[url "git://git.madduck.net/madduck/"]
insteadOf = madduck:
from blib2to3.pgen2.parse import ParseError
from blib2to3.pgen2.parse import ParseError
DEFAULT_LINE_LENGTH = 88
CACHE_DIR = Path(user_cache_dir("black", version=__version__))
DEFAULT_LINE_LENGTH = 88
CACHE_DIR = Path(user_cache_dir("black", version=__version__))
AUTO_DETECT = 0
PYTHON36 = 1
PYI = 2
AUTO_DETECT = 0
PYTHON36 = 1
PYI = 2
+ NO_STRING_NORMALIZATION = 4
"**kwargs. [default: per-file auto-detection]"
),
)
"**kwargs. [default: per-file auto-detection]"
),
)
+@click.option(
+ "-S",
+ "--skip-string-normalization",
+ is_flag=True,
+ help="Don't normalize string quotes or prefixes.",
+)
@click.version_option(version=__version__)
@click.argument(
"src",
@click.version_option(version=__version__)
@click.argument(
"src",
fast: bool,
pyi: bool,
py36: bool,
fast: bool,
pyi: bool,
py36: bool,
+ skip_string_normalization: bool,
quiet: bool,
src: List[str],
) -> None:
quiet: bool,
src: List[str],
) -> None:
mode |= FileMode.PYTHON36
if pyi:
mode |= FileMode.PYI
mode |= FileMode.PYTHON36
if pyi:
mode |= FileMode.PYI
+ if skip_string_normalization:
+ mode |= FileMode.NO_STRING_NORMALIZATION
report = Report(check=check, quiet=quiet)
if len(sources) == 0:
out("No paths given. Nothing to do 😴")
report = Report(check=check, quiet=quiet)
if len(sources) == 0:
out("No paths given. Nothing to do 😴")
future_imports = get_future_imports(src_node)
is_pyi = bool(mode & FileMode.PYI)
py36 = bool(mode & FileMode.PYTHON36) or is_python36(src_node)
future_imports = get_future_imports(src_node)
is_pyi = bool(mode & FileMode.PYI)
py36 = bool(mode & FileMode.PYTHON36) or is_python36(src_node)
+ normalize_strings = not bool(mode & FileMode.NO_STRING_NORMALIZATION)
- remove_u_prefix=py36 or "unicode_literals" in future_imports, is_pyi=is_pyi
+ remove_u_prefix=py36 or "unicode_literals" in future_imports,
+ is_pyi=is_pyi,
+ normalize_strings=normalize_strings,
)
elt = EmptyLineTracker(is_pyi=is_pyi)
empty_line = Line()
)
elt = EmptyLineTracker(is_pyi=is_pyi)
empty_line = Line()
+ normalize_strings: bool = True
current_line: Line = Factory(Line)
remove_u_prefix: bool = False
current_line: Line = Factory(Line)
remove_u_prefix: bool = False
else:
normalize_prefix(node, inside_brackets=any_open_brackets)
else:
normalize_prefix(node, inside_brackets=any_open_brackets)
- if node.type == token.STRING:
+ if self.normalize_strings and node.type == token.STRING:
normalize_string_prefix(node, remove_u_prefix=self.remove_u_prefix)
normalize_string_quotes(node)
if node.type not in WHITESPACE:
normalize_string_prefix(node, remove_u_prefix=self.remove_u_prefix)
normalize_string_quotes(node)
if node.type not in WHITESPACE: