improve code coverage in a few places

This commit is contained in:
Anthony Sottile 2021-04-07 08:52:26 -07:00
parent 5899e7d720
commit 737e0492d0
3 changed files with 9 additions and 17 deletions

View file

@ -446,8 +446,6 @@ def log_token(log: logging.Logger, token: _Token) -> None:
)
# NOTE(sigmavirus24): This was taken wholesale from
# https://github.com/PyCQA/pycodestyle
def expand_indent(line: str) -> int:
r"""Return the amount of indentation.
@ -462,17 +460,7 @@ def expand_indent(line: str) -> int:
>>> expand_indent(' \t')
16
"""
if "\t" not in line:
return len(line) - len(line.lstrip())
result = 0
for char in line:
if char == "\t":
result = result // 8 * 8 + 8
elif char == " ":
result += 1
else:
break
return result
return len(line.expandtabs(8))
# NOTE(sigmavirus24): This was taken wholesale from

View file

@ -231,9 +231,7 @@ def parse_unified_diff(diff: Optional[str] = None) -> Dict[str, Set[int]]:
parsed_paths: Dict[str, Set[int]] = collections.defaultdict(set)
for line in diff.splitlines():
if number_of_rows:
# NOTE(sigmavirus24): Below we use a slice because stdin may be
# bytes instead of text on Python 3.
if line[:1] != "-":
if not line or line[0] != "-":
number_of_rows -= 1
# We're in the part of the diff that has lines starting with +, -,
# and ' ' to show context and the changes made. We skip these
@ -317,7 +315,6 @@ def _default_predicate(*args: str) -> bool:
def filenames_from(
arg: str, predicate: Optional[Callable[[str], bool]] = None
) -> Generator[str, None, None]:
# noqa: E501
"""Generate filenames from an argument.
:param str arg: