diff options
author | Timothy Crosley <timothy.crosley@gmail.com> | 2020-09-24 23:19:40 -0700 |
---|---|---|
committer | Timothy Crosley <timothy.crosley@gmail.com> | 2020-09-24 23:19:40 -0700 |
commit | 0ea8a95eaad4698e78ab8fc0a16196778dfe9922 (patch) | |
tree | a91807227022276a272cfad35342fef8f93795c9 | |
parent | e50bd1e774dd15161cac7c102a4a51007af9577e (diff) | |
download | isort-0ea8a95eaad4698e78ab8fc0a16196778dfe9922.tar.gz |
Move chdir util to deprecated finders, since it is only used there and otherwise counts against coverage
-rw-r--r-- | isort/deprecated/finders.py | 14 | ||||
-rw-r--r-- | isort/utils.py | 13 |
2 files changed, 13 insertions, 14 deletions
diff --git a/isort/deprecated/finders.py b/isort/deprecated/finders.py index 77eb23fa..dbb6fec0 100644 --- a/isort/deprecated/finders.py +++ b/isort/deprecated/finders.py @@ -7,6 +7,7 @@ import re import sys import sysconfig from abc import ABCMeta, abstractmethod +from contextlib import contextmanager from fnmatch import fnmatch from functools import lru_cache from glob import glob @@ -15,7 +16,7 @@ from typing import Dict, Iterable, Iterator, List, Optional, Pattern, Sequence, from isort import sections from isort.settings import KNOWN_SECTION_MAPPING, Config -from isort.utils import chdir, exists_case_sensitive +from isort.utils import exists_case_sensitive try: from pipreqs import pipreqs @@ -36,6 +37,17 @@ except ImportError: Pipfile = None +@contextmanager +def chdir(path: str) -> Iterator[None]: + """Context manager for changing dir and restoring previous workdir after exit.""" + curdir = os.getcwd() + os.chdir(path) + try: + yield + finally: + os.chdir(curdir) + + class BaseFinder(metaclass=ABCMeta): def __init__(self, config: Config) -> None: self.config = config diff --git a/isort/utils.py b/isort/utils.py index 27f17b4a..63b51990 100644 --- a/isort/utils.py +++ b/isort/utils.py @@ -1,7 +1,5 @@ import os import sys -from contextlib import contextmanager -from typing import Iterator def exists_case_sensitive(path: str) -> bool: @@ -16,14 +14,3 @@ def exists_case_sensitive(path: str) -> bool: directory, basename = os.path.split(path) result = basename in os.listdir(directory) return result - - -@contextmanager -def chdir(path: str) -> Iterator[None]: - """Context manager for changing dir and restoring previous workdir after exit.""" - curdir = os.getcwd() - os.chdir(path) - try: - yield - finally: - os.chdir(curdir) |