From 0619c41d81ccd9f00f855071389cb25f0983aea3 Mon Sep 17 00:00:00 2001 From: Nasy Date: Fri, 7 Sep 2018 22:59:05 +0800 Subject: [PATCH 1/5] Add mypy config file --- prospector/tools/mypy/__init__.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/prospector/tools/mypy/__init__.py b/prospector/tools/mypy/__init__.py index 520c56d0..7951af08 100644 --- a/prospector/tools/mypy/__init__.py +++ b/prospector/tools/mypy/__init__.py @@ -29,6 +29,8 @@ def __init__(self, *args, **kwargs): def configure(self, prospector_config, _): options = prospector_config.tool_options('mypy') + + mypy_ini = options.get('config-file', None) follow_imports = options.get('follow-imports', 'normal') ignore_missing_imports = options.get('ignore-missing-imports', False) @@ -39,6 +41,9 @@ def configure(self, prospector_config, _): strict_optional = options.get('strict-optional', False) self.options.append('--follow-imports=%s' % follow_imports) + + if mypy_ini: + self.options.append('--config-file mypy_ini') if ignore_missing_imports: self.options.append('--ignore-missing-imports') @@ -88,4 +93,4 @@ def run(self, found_files): ) messages.append(message) - return messages \ No newline at end of file + return messages From 86e43f0c51c12b87aea39d002387e5e5520074a0 Mon Sep 17 00:00:00 2001 From: Nasy Date: Fri, 7 Sep 2018 23:03:35 +0800 Subject: [PATCH 2/5] Add strict --- prospector/tools/mypy/__init__.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/prospector/tools/mypy/__init__.py b/prospector/tools/mypy/__init__.py index 7951af08..eac9374d 100644 --- a/prospector/tools/mypy/__init__.py +++ b/prospector/tools/mypy/__init__.py @@ -30,7 +30,7 @@ def __init__(self, *args, **kwargs): def configure(self, prospector_config, _): options = prospector_config.tool_options('mypy') - mypy_ini = options.get('config-file', None) + strict = options.get('strict', False) follow_imports = options.get('follow-imports', 'normal') ignore_missing_imports = options.get('ignore-missing-imports', False) @@ -42,8 +42,8 @@ def configure(self, prospector_config, _): self.options.append('--follow-imports=%s' % follow_imports) - if mypy_ini: - self.options.append('--config-file mypy_ini') + if strict: + self.options.append('--strict') if ignore_missing_imports: self.options.append('--ignore-missing-imports') From 504ed1ed148f97b8b871fadd5151c3d0c4957931 Mon Sep 17 00:00:00 2001 From: Nasy Date: Fri, 7 Sep 2018 23:32:52 +0800 Subject: [PATCH 3/5] Update __init__.py When formatted as emacs, the character should use int. --- prospector/tools/mypy/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/prospector/tools/mypy/__init__.py b/prospector/tools/mypy/__init__.py index eac9374d..8b8aab4e 100644 --- a/prospector/tools/mypy/__init__.py +++ b/prospector/tools/mypy/__init__.py @@ -82,7 +82,7 @@ def run(self, found_files): module=None, function=None, line=line, - character=char, + character=int(char), absolute_path=True ) message = Message( From d61c55a7f272f1fce4375186e1f9ef961507e063 Mon Sep 17 00:00:00 2001 From: Nasy Date: Fri, 7 Sep 2018 23:35:26 +0800 Subject: [PATCH 4/5] remove space in err_type --- prospector/tools/mypy/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/prospector/tools/mypy/__init__.py b/prospector/tools/mypy/__init__.py index 8b8aab4e..6355cab3 100644 --- a/prospector/tools/mypy/__init__.py +++ b/prospector/tools/mypy/__init__.py @@ -87,7 +87,7 @@ def run(self, found_files): ) message = Message( source='mypy', - code=err_type, + code=err_type.lstrip(" "), location=location, message=''.join(err_msg).strip() ) From dabefc5f99bd739837cce6edda35d27e99a96f5e Mon Sep 17 00:00:00 2001 From: Nasy Date: Fri, 7 Sep 2018 23:41:47 +0800 Subject: [PATCH 5/5] remove space in err_msg --- prospector/tools/mypy/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/prospector/tools/mypy/__init__.py b/prospector/tools/mypy/__init__.py index 6355cab3..6ec64edf 100644 --- a/prospector/tools/mypy/__init__.py +++ b/prospector/tools/mypy/__init__.py @@ -76,7 +76,7 @@ def run(self, found_files): for message in report.splitlines(): iter_message = iter(message.split(':')) - (path, line, char, err_type), err_msg = islice(iter_message, 4), list(message) + (path, line, char, err_type, err_msg) = islice(iter_message, 5) location = Location( path=path, module=None, @@ -89,7 +89,7 @@ def run(self, found_files): source='mypy', code=err_type.lstrip(" "), location=location, - message=''.join(err_msg).strip() + message=err_msg.lstrip(" ") ) messages.append(message)