diff options
author | Timothy Crosley <timothy.crosley@gmail.com> | 2020-02-11 17:37:08 -0800 |
---|---|---|
committer | Timothy Crosley <timothy.crosley@gmail.com> | 2020-02-11 17:37:08 -0800 |
commit | b7e7e61dcfe1ebb9f48bc68e5aece50205aca466 (patch) | |
tree | 1b17ceaeace60dcca7c3b163e1224042e2e7aa3a | |
parent | b99039b3b71c70df46d12c548a303886114a1042 (diff) | |
download | isort-issue/710-settings-path.tar.gz |
Fix issue #710: Allow directly specifying settings file in addition to settings pathissue/710-settings-path
-rw-r--r-- | isort/main.py | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/isort/main.py b/isort/main.py index 1862b30b..5563fb90 100644 --- a/isort/main.py +++ b/isort/main.py @@ -387,8 +387,11 @@ def parse_args(argv: Optional[Sequence[str]] = None) -> Dict[str, Any]: parser.add_argument( "--sp", "--settings-path", + "--settings-file", + "--settings", dest="settings_path", - help="Explicitly set the settings path instead of auto determining based on file location.", + help="Explicitly set the settings path or file instead of auto determining " + "based on file location.", ) parser.add_argument( "-t", @@ -535,12 +538,13 @@ def main(argv: Optional[Sequence[str]] = None) -> None: show_config: bool = arguments.pop("show_config", False) if "settings_path" in arguments: - sp = arguments["settings_path"] - arguments["settings_path"] = ( - os.path.abspath(sp) if os.path.isdir(sp) else os.path.dirname(os.path.abspath(sp)) - ) - if not os.path.isdir(arguments["settings_path"]): + if os.path.isfile(arguments["settings_path"]): + arguments["settings_file"] = os.path.abspath(arguments["settings_path"]) + arguments["settings_path"] = os.path.dirname(arguments["settings_file"]) + elif not os.path.isdir(arguments["settings_path"]): warn(f"settings_path dir does not exist: {arguments['settings_path']}") + else: + arguments["settings_path"] = os.path.abspath(arguments["settings_path"]) if "virtual_env" in arguments: venv = arguments["virtual_env"] |