From 865a6268cb92828d76f54ec62e618522bc32933d Mon Sep 17 00:00:00 2001 From: Ashutosh Hathidara Date: Sun, 22 Mar 2020 13:11:43 +0530 Subject: [PATCH 1/5] Modified expand_path in config_parser to add environment var for mypy_path --- mypy/config_parser.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/mypy/config_parser.py b/mypy/config_parser.py index 0ee274abd1bcc..642782a5597e5 100644 --- a/mypy/config_parser.py +++ b/mypy/config_parser.py @@ -39,7 +39,12 @@ def expand_path(path: str) -> str: the provided path. """ - return os.path.expandvars(os.path.expanduser(path)) + expanded_path = os.path.expandvars(os.path.expanduser(path)) + if os.environ.get('MYPY_CONFIG_FILE_DIR')=='False': + os.environ['MYPY_CONFIG_FILE_DIR'] = expanded_path + else: + os.environ['MYPY_CONFIG_FILE_DIR'] += (os.pathsep + expanded_path) + return expanded_path def split_and_match_files(paths: str) -> List[str]: From 00e8024ffd187bdbddeb71fcced53cd2912a9410 Mon Sep 17 00:00:00 2001 From: Ashutosh Hathidara Date: Sun, 22 Mar 2020 13:44:50 +0530 Subject: [PATCH 2/5] resolving errors --- mypy/config_parser.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mypy/config_parser.py b/mypy/config_parser.py index 642782a5597e5..0cc92533806a7 100644 --- a/mypy/config_parser.py +++ b/mypy/config_parser.py @@ -40,7 +40,7 @@ def expand_path(path: str) -> str: """ expanded_path = os.path.expandvars(os.path.expanduser(path)) - if os.environ.get('MYPY_CONFIG_FILE_DIR')=='False': + if 'MYPY_CONFIG_FILE_DIR' not in os.environ: os.environ['MYPY_CONFIG_FILE_DIR'] = expanded_path else: os.environ['MYPY_CONFIG_FILE_DIR'] += (os.pathsep + expanded_path) From 3a399c6a142a2ac1dbe43fa7d24da84252019349 Mon Sep 17 00:00:00 2001 From: Ashutosh Hathidara Date: Mon, 23 Mar 2020 09:59:50 +0530 Subject: [PATCH 3/5] Changed position of new code --- mypy/config_parser.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/mypy/config_parser.py b/mypy/config_parser.py index 0cc92533806a7..b1f8f2014a99f 100644 --- a/mypy/config_parser.py +++ b/mypy/config_parser.py @@ -39,12 +39,7 @@ def expand_path(path: str) -> str: the provided path. """ - expanded_path = os.path.expandvars(os.path.expanduser(path)) - if 'MYPY_CONFIG_FILE_DIR' not in os.environ: - os.environ['MYPY_CONFIG_FILE_DIR'] = expanded_path - else: - os.environ['MYPY_CONFIG_FILE_DIR'] += (os.pathsep + expanded_path) - return expanded_path + return os.path.expandvars(os.path.expanduser(path)) def split_and_match_files(paths: str) -> List[str]: @@ -117,6 +112,10 @@ def parse_config_file(options: Options, set_strict_flags: Callable[[], None], if not os.path.exists(config_file): continue try: + if 'MYPY_CONFIG_FILE_DIR' not in os.environ: + os.environ['MYPY_CONFIG_FILE_DIR'] = config_file + else: + os.environ['MYPY_CONFIG_FILE_DIR'] += os.pathsep + config_file parser.read(config_file) except configparser.Error as err: print("%s: %s" % (config_file, err), file=stderr) From bd96c45f5f7bba3214d497f82263727d536c4787 Mon Sep 17 00:00:00 2001 From: Ashutosh Hathidara Date: Mon, 23 Mar 2020 10:02:13 +0530 Subject: [PATCH 4/5] Changed position of new code --- mypy/config_parser.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mypy/config_parser.py b/mypy/config_parser.py index b1f8f2014a99f..74885a355c8a9 100644 --- a/mypy/config_parser.py +++ b/mypy/config_parser.py @@ -112,7 +112,7 @@ def parse_config_file(options: Options, set_strict_flags: Callable[[], None], if not os.path.exists(config_file): continue try: - if 'MYPY_CONFIG_FILE_DIR' not in os.environ: + if 'MYPY_CONFIG_FILE_DIR' not in os.environ: os.environ['MYPY_CONFIG_FILE_DIR'] = config_file else: os.environ['MYPY_CONFIG_FILE_DIR'] += os.pathsep + config_file From ea3b887708ecca952f3bc15a085eaa76fe6c4dfd Mon Sep 17 00:00:00 2001 From: Ashutosh Hathidara Date: Wed, 1 Apr 2020 17:48:47 +0530 Subject: [PATCH 5/5] Added os.path.dirname() for config_file --- mypy/config_parser.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mypy/config_parser.py b/mypy/config_parser.py index 74885a355c8a9..9b35114f9ad7f 100644 --- a/mypy/config_parser.py +++ b/mypy/config_parser.py @@ -113,9 +113,9 @@ def parse_config_file(options: Options, set_strict_flags: Callable[[], None], continue try: if 'MYPY_CONFIG_FILE_DIR' not in os.environ: - os.environ['MYPY_CONFIG_FILE_DIR'] = config_file + os.environ['MYPY_CONFIG_FILE_DIR'] = os.path.dirname(config_file) else: - os.environ['MYPY_CONFIG_FILE_DIR'] += os.pathsep + config_file + os.environ['MYPY_CONFIG_FILE_DIR'] += os.pathsep + os.path.dirname(config_file) parser.read(config_file) except configparser.Error as err: print("%s: %s" % (config_file, err), file=stderr)