diff options
| author | Anthony Sottile <asottile@umich.edu> | 2021-04-07 08:52:26 -0700 |
|---|---|---|
| committer | Anthony Sottile <asottile@umich.edu> | 2021-04-07 08:52:26 -0700 |
| commit | 737e0492d0f30f65d9af9bfc8657fd98822b96f1 (patch) | |
| tree | afb44b7e3ad324610cbe4f09436517d2d480d288 /src | |
| parent | 5899e7d7206d35328b0feca9b1d407ff0ffcc484 (diff) | |
| download | flake8-737e0492d0f30f65d9af9bfc8657fd98822b96f1.tar.gz | |
improve code coverage in a few places
Diffstat (limited to 'src')
| -rw-r--r-- | src/flake8/processor.py | 14 | ||||
| -rw-r--r-- | src/flake8/utils.py | 5 |
2 files changed, 2 insertions, 17 deletions
diff --git a/src/flake8/processor.py b/src/flake8/processor.py index 7c4672a..5fd78a8 100644 --- a/src/flake8/processor.py +++ b/src/flake8/processor.py @@ -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 diff --git a/src/flake8/utils.py b/src/flake8/utils.py index c5c134e..96c3485 100644 --- a/src/flake8/utils.py +++ b/src/flake8/utils.py @@ -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: |
