aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlmaz <hsyqixco@protonmail.com>2021-07-13 04:03:15 +0300
committerGitHub <noreply@github.com>2021-07-12 18:03:15 -0700
commitaf43190bb7981f2dc56ea43db0c1a5fe02791bd2 (patch)
tree3f51a2c18aad3ceff91ec67f91d5aae52389e23e
parent30895d69d0e37b37d211c5b4a0d5320a8c8d4b5c (diff)
downloadyapf-af43190bb7981f2dc56ea43db0c1a5fe02791bd2.tar.gz
Replace multiple comparisons with in operator (#941)
Replace multiple comparisons with in operator
-rw-r--r--yapf/yapflib/reformatter.py3
-rw-r--r--yapf/yapflib/unwrapped_line.py4
2 files changed, 3 insertions, 4 deletions
diff --git a/yapf/yapflib/reformatter.py b/yapf/yapflib/reformatter.py
index ff84de9..c5282b1 100644
--- a/yapf/yapflib/reformatter.py
+++ b/yapf/yapflib/reformatter.py
@@ -648,8 +648,7 @@ def _CalculateNumberOfNewlines(first_token, indent_depth, prev_uwline,
return NO_BLANK_LINES
if first_token.is_name and not indent_depth:
- if (prev_uwline.first.value == 'from' or
- prev_uwline.first.value == 'import'):
+ if prev_uwline.first.value in {'from', 'import'}:
# Support custom number of blank lines between top-level imports and
# variable definitions.
return 1 + style.Get(
diff --git a/yapf/yapflib/unwrapped_line.py b/yapf/yapflib/unwrapped_line.py
index 0986314..0bc537c 100644
--- a/yapf/yapflib/unwrapped_line.py
+++ b/yapf/yapflib/unwrapped_line.py
@@ -405,10 +405,10 @@ def _SpaceRequiredBetween(left, right, is_line_disabled):
return False
if left.is_keyword and rval == '.':
# Add space between keywords and dots.
- return lval != 'None' and lval != 'print'
+ return lval not in {'None', 'print'}
if lval == '.' and right.is_keyword:
# Add space between keywords and dots.
- return rval != 'None' and rval != 'print'
+ return rval not in {'None', 'print'}
if lval == '.' or rval == '.':
# Don't place spaces between dots.
return False