diff options
author | Almaz <hsyqixco@protonmail.com> | 2021-07-13 04:03:15 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-07-12 18:03:15 -0700 |
commit | af43190bb7981f2dc56ea43db0c1a5fe02791bd2 (patch) | |
tree | 3f51a2c18aad3ceff91ec67f91d5aae52389e23e | |
parent | 30895d69d0e37b37d211c5b4a0d5320a8c8d4b5c (diff) | |
download | yapf-af43190bb7981f2dc56ea43db0c1a5fe02791bd2.tar.gz |
Replace multiple comparisons with in operator (#941)
Replace multiple comparisons with in operator
-rw-r--r-- | yapf/yapflib/reformatter.py | 3 | ||||
-rw-r--r-- | yapf/yapflib/unwrapped_line.py | 4 |
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 |