Update yapf
This commit is contained in:
parent
e6eea3a3a5
commit
7b164fa5ae
2 changed files with 56 additions and 149 deletions
180
.style.yapf
180
.style.yapf
|
@ -1,155 +1,37 @@
|
||||||
[style]
|
[style]
|
||||||
|
based_on_style = chromium
|
||||||
|
COLUMN_LIMIT=99
|
||||||
|
INDENT_WIDTH=2
|
||||||
|
BLANK_LINE_BEFORE_CLASS_DOCSTRING=False
|
||||||
|
#True
|
||||||
|
ALIGN_CLOSING_BRACKET_WITH_VISUAL_INDENT=True
|
||||||
|
# False
|
||||||
|
ALLOW_MULTILINE_DICTIONARY_KEYS=True
|
||||||
|
# False
|
||||||
|
BLANK_LINE_BEFORE_NESTED_CLASS_OR_DEF=False
|
||||||
|
# False
|
||||||
|
COALESCE_BRACKETS=True
|
||||||
|
DEDENT_CLOSING_BRACKETS=False
|
||||||
|
CONTINUATION_INDENT_WIDTH=2
|
||||||
|
# False
|
||||||
|
INDENT_DICTIONARY_VALUE=True
|
||||||
|
JOIN_MULTIPLE_LINES=False
|
||||||
|
# True
|
||||||
|
SPACE_BETWEEN_ENDING_COMMA_AND_CLOSING_BRACKET=False
|
||||||
|
# True
|
||||||
|
SPLIT_BEFORE_NAMED_ASSIGNS=False
|
||||||
|
SPLIT_PENALTY_AFTER_OPENING_BRACKET=30
|
||||||
|
SPLIT_PENALTY_AFTER_UNARY_OPERATOR=10000
|
||||||
|
SPLIT_PENALTY_BEFORE_IF_EXPR=0
|
||||||
|
SPLIT_PENALTY_BITWISE_OPERATOR=300
|
||||||
|
SPLIT_PENALTY_EXCESS_CHARACTER=10000
|
||||||
|
SPLIT_PENALTY_FOR_ADDED_LINE_SPLIT=30
|
||||||
|
SPLIT_PENALTY_IMPORT_NAMES=450
|
||||||
|
SPLIT_PENALTY_LOGICAL_OPERATOR=300
|
||||||
|
USE_TABS=False
|
||||||
|
SPLIT_ARGUMENTS_WHEN_COMMA_TERMINATED=False
|
||||||
# Align closing bracket with visual indentation.
|
# Align closing bracket with visual indentation.
|
||||||
align_closing_bracket_with_visual_indent=True
|
align_closing_bracket_with_visual_indent=True
|
||||||
|
|
||||||
# Allow lambdas to be formatted on more than one line.
|
# Allow lambdas to be formatted on more than one line.
|
||||||
allow_multiline_lambdas=True
|
allow_multiline_lambdas=True
|
||||||
|
|
||||||
# Insert a blank line before a 'def' or 'class' immediately nested
|
|
||||||
# within another 'def' or 'class'. For example:
|
|
||||||
#
|
|
||||||
# class Foo:
|
|
||||||
# # <------ this blank line
|
|
||||||
# def method():
|
|
||||||
# ...
|
|
||||||
blank_line_before_nested_class_or_def=False
|
|
||||||
|
|
||||||
# Do not split consecutive brackets. Only relevant when
|
|
||||||
# dedent_closing_brackets is set. For example:
|
|
||||||
#
|
|
||||||
# call_func_that_takes_a_dict(
|
|
||||||
# {
|
|
||||||
# 'key1': 'value1',
|
|
||||||
# 'key2': 'value2',
|
|
||||||
# }
|
|
||||||
# )
|
|
||||||
#
|
|
||||||
# would reformat to:
|
|
||||||
#
|
|
||||||
# call_func_that_takes_a_dict({
|
|
||||||
# 'key1': 'value1',
|
|
||||||
# 'key2': 'value2',
|
|
||||||
# })
|
|
||||||
coalesce_brackets=False
|
|
||||||
|
|
||||||
# The column limit.
|
|
||||||
column_limit=99
|
|
||||||
|
|
||||||
# Indent width used for line continuations.
|
|
||||||
continuation_indent_width=1
|
|
||||||
|
|
||||||
# Put closing brackets on a separate line, dedented, if the bracketed
|
|
||||||
# expression can't fit in a single line. Applies to all kinds of brackets,
|
|
||||||
# including function definitions and calls. For example:
|
|
||||||
#
|
|
||||||
# config = {
|
|
||||||
# 'key1': 'value1',
|
|
||||||
# 'key2': 'value2',
|
|
||||||
# } # <--- this bracket is dedented and on a separate line
|
|
||||||
#
|
|
||||||
# time_series = self.remote_client.query_entity_counters(
|
|
||||||
# entity='dev3246.region1',
|
|
||||||
# key='dns.query_latency_tcp',
|
|
||||||
# transform=Transformation.AVERAGE(window=timedelta(seconds=60)),
|
|
||||||
# start_ts=now()-timedelta(days=3),
|
|
||||||
# end_ts=now(),
|
|
||||||
# ) # <--- this bracket is dedented and on a separate line
|
|
||||||
dedent_closing_brackets=False
|
|
||||||
|
|
||||||
# The regex for an i18n comment. The presence of this comment stops
|
|
||||||
# reformatting of that line, because the comments are required to be
|
|
||||||
# next to the string they translate.
|
|
||||||
i18n_comment=
|
|
||||||
|
|
||||||
# The i18n function call names. The presence of this function stops
|
|
||||||
# reformattting on that line, because the string it has cannot be moved
|
|
||||||
# away from the i18n comment.
|
|
||||||
i18n_function_call=
|
|
||||||
|
|
||||||
# Indent the dictionary value if it cannot fit on the same line as the
|
|
||||||
# dictionary key. For example:
|
|
||||||
#
|
|
||||||
# config = {
|
|
||||||
# 'key1':
|
|
||||||
# 'value1',
|
|
||||||
# 'key2': value1 +
|
|
||||||
# value2,
|
|
||||||
# }
|
|
||||||
indent_dictionary_value=False
|
|
||||||
|
|
||||||
# The number of columns to use for indentation.
|
|
||||||
indent_width=2
|
|
||||||
|
|
||||||
# Join short lines into one line. E.g., single line 'if' statements.
|
|
||||||
join_multiple_lines=False
|
|
||||||
|
|
||||||
# Use spaces around default or named assigns.
|
|
||||||
spaces_around_default_or_named_assign=False
|
|
||||||
|
|
||||||
# Use spaces around the power operator.
|
|
||||||
spaces_around_power_operator=False
|
|
||||||
|
|
||||||
# The number of spaces required before a trailing comment.
|
|
||||||
spaces_before_comment=2
|
|
||||||
|
|
||||||
# Insert a space between the ending comma and closing bracket of a list,
|
|
||||||
# etc.
|
|
||||||
space_between_ending_comma_and_closing_bracket=True
|
|
||||||
|
|
||||||
# Split before arguments if the argument list is terminated by a
|
|
||||||
# comma.
|
|
||||||
split_arguments_when_comma_terminated=False
|
|
||||||
|
|
||||||
# Set to True to prefer splitting before '&', '|' or '^' rather than
|
|
||||||
# after.
|
|
||||||
split_before_bitwise_operator=False
|
|
||||||
|
|
||||||
# If an argument / parameter list is going to be split, then split before
|
|
||||||
# the first argument.
|
|
||||||
split_before_first_argument=False
|
|
||||||
|
|
||||||
# Set to True to prefer splitting before 'and' or 'or' rather than
|
|
||||||
# after.
|
|
||||||
split_before_logical_operator=False
|
|
||||||
|
|
||||||
# Split named assignments onto individual lines.
|
|
||||||
split_before_named_assigns=True
|
|
||||||
|
|
||||||
# The penalty for splitting right after the opening bracket.
|
|
||||||
split_penalty_after_opening_bracket=30
|
|
||||||
|
|
||||||
# The penalty for splitting the line after a unary operator.
|
|
||||||
split_penalty_after_unary_operator=10000
|
|
||||||
|
|
||||||
# The penalty for splitting right before an if expression.
|
|
||||||
split_penalty_before_if_expr=0
|
|
||||||
|
|
||||||
# The penalty of splitting the line around the '&', '|', and '^'
|
|
||||||
# operators.
|
|
||||||
split_penalty_bitwise_operator=300
|
|
||||||
|
|
||||||
# The penalty for characters over the column limit.
|
|
||||||
split_penalty_excess_character=2600
|
|
||||||
|
|
||||||
# The penalty incurred by adding a line split to the unwrapped line. The
|
|
||||||
# more line splits added the higher the penalty.
|
|
||||||
split_penalty_for_added_line_split=30
|
|
||||||
|
|
||||||
# The penalty of splitting a list of "import as" names. For example:
|
|
||||||
#
|
|
||||||
# from a_very_long_or_indented_module_name_yada_yad import (long_argument_1,
|
|
||||||
# long_argument_2,
|
|
||||||
# long_argument_3)
|
|
||||||
#
|
|
||||||
# would reformat to something like:
|
|
||||||
#
|
|
||||||
# from a_very_long_or_indented_module_name_yada_yad import (
|
|
||||||
# long_argument_1, long_argument_2, long_argument_3)
|
|
||||||
split_penalty_import_names=0
|
|
||||||
|
|
||||||
# The penalty of splitting the line around the 'and' and 'or'
|
|
||||||
# operators.
|
|
||||||
split_penalty_logical_operator=300
|
|
||||||
|
|
||||||
# Use the Tab character for indentation.
|
|
||||||
use_tabs=False
|
|
||||||
|
|
25
Makefile
25
Makefile
|
@ -4,6 +4,12 @@ SHA := $(shell git rev-parse --short HEAD )
|
||||||
REPO := quay.io/quay/quay
|
REPO := quay.io/quay/quay
|
||||||
TAG := $(REPO):$(SHA)
|
TAG := $(REPO):$(SHA)
|
||||||
|
|
||||||
|
MODIFIED_FILES_COUNT = $(shell git diff --name-only origin/master | grep -E .+\.py$ | wc -l)
|
||||||
|
MODIFIED_FILES = $(shell git diff --name-only origin/master | grep -E .+\.py$ | paste -sd ' ')
|
||||||
|
|
||||||
|
show-modified:
|
||||||
|
echo $(MODIFIED_FILES)
|
||||||
|
|
||||||
.PHONY: all unit test pkgs build run clean
|
.PHONY: all unit test pkgs build run clean
|
||||||
|
|
||||||
all: clean pkgs test build
|
all: clean pkgs test build
|
||||||
|
@ -92,3 +98,22 @@ clean:
|
||||||
rm -rf build
|
rm -rf build
|
||||||
rm -rf conf/stack
|
rm -rf conf/stack
|
||||||
rm -rf screenshots
|
rm -rf screenshots
|
||||||
|
|
||||||
|
|
||||||
|
yapf-all:
|
||||||
|
yapf -r . -p -i -e './data/model/*.py' -e './data/oci_model/*.py' -e './data/migrations/versions/*.py'
|
||||||
|
|
||||||
|
|
||||||
|
yapf-diff:
|
||||||
|
if [ $(MODIFIED_FILES_COUNT) -ne 0 ]; then yapf -d -p $(MODIFIED_FILES) ; fi
|
||||||
|
|
||||||
|
yapf:
|
||||||
|
ifneq (0,$(shell git diff-index HEAD | wc -l))
|
||||||
|
echo "Failed, git dirty" && false
|
||||||
|
else ifneq (0,$(shell yapf -d -p $(MODIFIED_FILES) | wc -l))
|
||||||
|
yapf -i -p $(MODIFIED_FILES)
|
||||||
|
git commit -a -m "code-stye Yapf: $(MODIFIED_FILES_COUNT) files updated" -m "$(MODIFIED_FILES)"
|
||||||
|
endif
|
||||||
|
|
||||||
|
yapf-test:
|
||||||
|
if [ `yapf -d -p $(MODIFIED_FILES) | wc -l` -gt 0 ] ; then false ; else true ;fi
|
||||||
|
|
Reference in a new issue