From afdc9a0b3f367c97aaf544eb3be75704a716559d Mon Sep 17 00:00:00 2001 From: Alejandro Lujan Toro Date: Wed, 4 Apr 2018 09:10:29 -0400 Subject: [PATCH 01/11] Refactoring check out of process_tokens --- shopify_python/shopify_styleguide.py | 39 ++++++++++++++++++---------- 1 file changed, 25 insertions(+), 14 deletions(-) diff --git a/shopify_python/shopify_styleguide.py b/shopify_python/shopify_styleguide.py index f3937e9..700a109 100644 --- a/shopify_python/shopify_styleguide.py +++ b/shopify_python/shopify_styleguide.py @@ -32,22 +32,33 @@ class ShopifyStyleGuideChecker(checkers.BaseTokenChecker): RE_PYLINT_DISABLE = re.compile(r'^#[ \t]*pylint:[ \t]*(disable|enable)[ \t]*=(?P[a-zA-Z0-9\-_, \t]+)$') RE_PYLINT_MESSAGE_CODE = re.compile(r'^[A-Z]{1,2}[0-9]{4}$') + def process_tokens(self, tokens): # type: (typing.Sequence[typing.Tuple]) -> None - for _type, string, start, _, _ in tokens: + for _type, string, start, end, _ in tokens: start_row, _ = start if _type == tokenize.COMMENT: + self.__validate_comment(string, start, end) + + def __validate_comment(self, string, start, end): + # type: (str, typing.Tuple[int, int], typing.Tuple[int, int]) -> None + self.__disable_name_only(string, start) + + def __disable_name_only(self, string, start): + # type: (str, typing.Tuple[int, int]) -> None + start_row, _ = start + + def get_name(code): + try: + return self.linter.msgs_store.get_msg_display_string(code) + except pylint.utils.UnknownMessageError: + return 'unknown' + + matches = self.RE_PYLINT_DISABLE.match(string) + if matches: + for msg in matches.group('messages').split(','): + msg = msg.strip() + if self.RE_PYLINT_MESSAGE_CODE.match(msg): + self.add_message('disable-name-only', line=start_row, + args={'code': msg, 'name': get_name(msg)}) - def get_name(code): - try: - return self.linter.msgs_store.get_msg_display_string(code) - except pylint.utils.UnknownMessageError: - return 'unknown' - - matches = self.RE_PYLINT_DISABLE.match(string) - if matches: - for msg in matches.group('messages').split(','): - msg = msg.strip() - if self.RE_PYLINT_MESSAGE_CODE.match(msg): - self.add_message('disable-name-only', line=start_row, - args={'code': msg, 'name': get_name(msg)}) From 01173a760d889ff9fb344f8c10ebf6751b87a733 Mon Sep 17 00:00:00 2001 From: Alejandro Lujan Toro Date: Wed, 4 Apr 2018 09:38:59 -0400 Subject: [PATCH 02/11] Adding check for Sequence[str] --- shopify_python/shopify_styleguide.py | 21 ++++++++++++++++----- tests/functional/sequence_of_string.py | 7 +++++++ tests/functional/sequence_of_string.txt | 1 + 3 files changed, 24 insertions(+), 5 deletions(-) create mode 100644 tests/functional/sequence_of_string.py create mode 100644 tests/functional/sequence_of_string.txt diff --git a/shopify_python/shopify_styleguide.py b/shopify_python/shopify_styleguide.py index 700a109..e3a3691 100644 --- a/shopify_python/shopify_styleguide.py +++ b/shopify_python/shopify_styleguide.py @@ -27,27 +27,32 @@ class ShopifyStyleGuideChecker(checkers.BaseTokenChecker): 'disable-name-only', "Disable pylint rules via message name (e.g. unused-import) and not message code (e.g. W0611) to " "help code reviewers understand why a linter rule was disabled for a line of code."), + 'C6102': ('Forbidden use of typing.Sequence[str], use typing.List[str] instead', + 'sequence-of-string', + 'Since str itself also satisfies typing.Sequence[str], the latter should be replaced by ' + 'a more specific iterable type, such as typing.List[str]') } RE_PYLINT_DISABLE = re.compile(r'^#[ \t]*pylint:[ \t]*(disable|enable)[ \t]*=(?P[a-zA-Z0-9\-_, \t]+)$') RE_PYLINT_MESSAGE_CODE = re.compile(r'^[A-Z]{1,2}[0-9]{4}$') + RE_SEQUENCE_STRING = re.compile(r'^#.*type:.*Sequence\[str\].*$') def process_tokens(self, tokens): # type: (typing.Sequence[typing.Tuple]) -> None - for _type, string, start, end, _ in tokens: + for _type, string, start, _, _ in tokens: start_row, _ = start if _type == tokenize.COMMENT: - self.__validate_comment(string, start, end) + self.__validate_comment(string, start) - def __validate_comment(self, string, start, end): - # type: (str, typing.Tuple[int, int], typing.Tuple[int, int]) -> None + def __validate_comment(self, string, start): + # type: (str, typing.Tuple[int, int]) -> None self.__disable_name_only(string, start) + self.__sequence_str(string, start) def __disable_name_only(self, string, start): # type: (str, typing.Tuple[int, int]) -> None start_row, _ = start - def get_name(code): try: return self.linter.msgs_store.get_msg_display_string(code) @@ -62,3 +67,9 @@ def get_name(code): self.add_message('disable-name-only', line=start_row, args={'code': msg, 'name': get_name(msg)}) + def __sequence_str(self, string, start): + # type: (str, typing.Tuple[int, int]) -> None + start_row, _ = start + if self.RE_SEQUENCE_STRING.match(string): + self.add_message('sequence-of-string', line=start_row, + args={'code': 'foobar', 'name': 'baz'}) diff --git a/tests/functional/sequence_of_string.py b/tests/functional/sequence_of_string.py new file mode 100644 index 0000000..6133de0 --- /dev/null +++ b/tests/functional/sequence_of_string.py @@ -0,0 +1,7 @@ +# pylint:disable=missing-docstring,unused-import +import typing + + +def some_method(seq): + # type: (typing.Sequence[str]) -> None # [sequence-of-string] + return seq diff --git a/tests/functional/sequence_of_string.txt b/tests/functional/sequence_of_string.txt new file mode 100644 index 0000000..f66d98a --- /dev/null +++ b/tests/functional/sequence_of_string.txt @@ -0,0 +1 @@ +sequence-of-string:6::Forbidden use of typing.Sequence[str], use typing.List[str] instead \ No newline at end of file From 831f936c01c232115d8e04a1e93f2a646ea76504 Mon Sep 17 00:00:00 2001 From: Alejandro Lujan Toro Date: Wed, 4 Apr 2018 13:31:16 -0400 Subject: [PATCH 03/11] Adding more tests for different uses of type annotations --- tests/functional/sequence_of_string.py | 17 +++++++++++++---- tests/functional/sequence_of_string.txt | 5 ++++- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/tests/functional/sequence_of_string.py b/tests/functional/sequence_of_string.py index 6133de0..94d5d9c 100644 --- a/tests/functional/sequence_of_string.py +++ b/tests/functional/sequence_of_string.py @@ -1,7 +1,16 @@ -# pylint:disable=missing-docstring,unused-import +# pylint:disable=missing-docstring,unused-import,unused-argument import typing -def some_method(seq): - # type: (typing.Sequence[str]) -> None # [sequence-of-string] - return seq +def one_param(seq): + # type: (typing.Sequence[str]) -> str # [sequence-of-string] + copy = seq # type:typing.Sequence[str] # [sequence-of-string] + return copy[0] + +def multiple_params(message, seq, index): + # type: (string, typing.Sequence[str], int) -> str # [sequence-of-string] + return seq[index] + +def return_type(message_1, message_2): + # type: (str, str) -> typing.Sequence[str] # [sequence-of-string] + return [message_1, message_2] diff --git a/tests/functional/sequence_of_string.txt b/tests/functional/sequence_of_string.txt index f66d98a..1f9c4d2 100644 --- a/tests/functional/sequence_of_string.txt +++ b/tests/functional/sequence_of_string.txt @@ -1 +1,4 @@ -sequence-of-string:6::Forbidden use of typing.Sequence[str], use typing.List[str] instead \ No newline at end of file +sequence-of-string:6::Forbidden use of typing.Sequence[str], use typing.List[str] instead +sequence-of-string:7::Forbidden use of typing.Sequence[str], use typing.List[str] instead +sequence-of-string:11::Forbidden use of typing.Sequence[str], use typing.List[str] instead +sequence-of-string:15::Forbidden use of typing.Sequence[str], use typing.List[str] instead \ No newline at end of file From 585d3cb6bc55230118ce965659868cf44913286c Mon Sep 17 00:00:00 2001 From: Alejandro Lujan Toro Date: Wed, 4 Apr 2018 13:42:49 -0400 Subject: [PATCH 04/11] Added tests for Py3 catching of Sequence[str] --- ...nce_of_string.py => sequence_of_string_2.py} | 4 ++-- ...e_of_string.txt => sequence_of_string_2.txt} | 0 tests/functional/sequence_of_string_3.py | 17 +++++++++++++++++ tests/functional/sequence_of_string_3.rc | 3 +++ tests/functional/sequence_of_string_3.txt | 4 ++++ 5 files changed, 26 insertions(+), 2 deletions(-) rename tests/functional/{sequence_of_string.py => sequence_of_string_2.py} (83%) rename tests/functional/{sequence_of_string.txt => sequence_of_string_2.txt} (100%) create mode 100644 tests/functional/sequence_of_string_3.py create mode 100644 tests/functional/sequence_of_string_3.rc create mode 100644 tests/functional/sequence_of_string_3.txt diff --git a/tests/functional/sequence_of_string.py b/tests/functional/sequence_of_string_2.py similarity index 83% rename from tests/functional/sequence_of_string.py rename to tests/functional/sequence_of_string_2.py index 94d5d9c..377589b 100644 --- a/tests/functional/sequence_of_string.py +++ b/tests/functional/sequence_of_string_2.py @@ -1,4 +1,4 @@ -# pylint:disable=missing-docstring,unused-import,unused-argument +# pylint:disable=missing-docstring,unused-import import typing @@ -9,7 +9,7 @@ def one_param(seq): def multiple_params(message, seq, index): # type: (string, typing.Sequence[str], int) -> str # [sequence-of-string] - return seq[index] + return message + seq[index] def return_type(message_1, message_2): # type: (str, str) -> typing.Sequence[str] # [sequence-of-string] diff --git a/tests/functional/sequence_of_string.txt b/tests/functional/sequence_of_string_2.txt similarity index 100% rename from tests/functional/sequence_of_string.txt rename to tests/functional/sequence_of_string_2.txt diff --git a/tests/functional/sequence_of_string_3.py b/tests/functional/sequence_of_string_3.py new file mode 100644 index 0000000..78d418b --- /dev/null +++ b/tests/functional/sequence_of_string_3.py @@ -0,0 +1,17 @@ +# pylint:disable=missing-docstring,unused-import +import typing + + +def one_param(seq: typing.Sequence[str]) -> str: # [sequence-of-string] + copy: typing.Sequence[str] = seq # [sequence-of-string] + return copy[0] + +def multiple_params( + message: str, + seq: typing.Sequence[str], # [sequence-of-string] + index: int) -> str: + return message + seq[index] + +def return_type(message_1: str, message_2: str + ) -> typing.Sequence[str]: # [sequence-of-string] + return [message_1, message_2] diff --git a/tests/functional/sequence_of_string_3.rc b/tests/functional/sequence_of_string_3.rc new file mode 100644 index 0000000..9bf6df0 --- /dev/null +++ b/tests/functional/sequence_of_string_3.rc @@ -0,0 +1,3 @@ +[testoptions] +min_pyver=3.0 + diff --git a/tests/functional/sequence_of_string_3.txt b/tests/functional/sequence_of_string_3.txt new file mode 100644 index 0000000..6f6ec48 --- /dev/null +++ b/tests/functional/sequence_of_string_3.txt @@ -0,0 +1,4 @@ +sequence-of-string:6::Forbidden use of typing.Sequence[str], use typing.List[str] instead +sequence-of-string:8::Forbidden use of typing.Sequence[str], use typing.List[str] instead +sequence-of-string:13::Forbidden use of typing.Sequence[str], use typing.List[str] instead +sequence-of-string:18::Forbidden use of typing.Sequence[str], use typing.List[str] instead \ No newline at end of file From d6f552b081df20e1f44122673d2450f8bc2a071d Mon Sep 17 00:00:00 2001 From: Alejandro Lujan Toro Date: Wed, 4 Apr 2018 13:47:13 -0400 Subject: [PATCH 05/11] Dogfooding Sequence[str] to List[str] --- shopify_python/git_utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shopify_python/git_utils.py b/shopify_python/git_utils.py index 268039f..e7e24ed 100644 --- a/shopify_python/git_utils.py +++ b/shopify_python/git_utils.py @@ -22,7 +22,7 @@ def _remote_origin_master(git_repo): def _modified_in_branch(git_repo, other_ref): - # type: (repo.Repo, head.Head) -> typing.Sequence[str] + # type: (repo.Repo, head.Head) -> typing.List[str] common_commit = git_repo.merge_base(git_repo.active_branch, other_ref)[0] diffs = common_commit.diff(git_repo.active_branch.commit) changed_files = [] From 3167b4f20c9051a1394a7f30d4808052bf29d0eb Mon Sep 17 00:00:00 2001 From: Alejandro Lujan Toro Date: Wed, 4 Apr 2018 13:51:23 -0400 Subject: [PATCH 06/11] Cleaning up linting violations --- shopify_python/shopify_styleguide.py | 2 +- tests/functional/sequence_of_string_2.py | 10 ++++++---- tests/functional/sequence_of_string_3.py | 2 ++ 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/shopify_python/shopify_styleguide.py b/shopify_python/shopify_styleguide.py index e3a3691..f5c0566 100644 --- a/shopify_python/shopify_styleguide.py +++ b/shopify_python/shopify_styleguide.py @@ -41,7 +41,6 @@ class ShopifyStyleGuideChecker(checkers.BaseTokenChecker): def process_tokens(self, tokens): # type: (typing.Sequence[typing.Tuple]) -> None for _type, string, start, _, _ in tokens: - start_row, _ = start if _type == tokenize.COMMENT: self.__validate_comment(string, start) @@ -53,6 +52,7 @@ def __validate_comment(self, string, start): def __disable_name_only(self, string, start): # type: (str, typing.Tuple[int, int]) -> None start_row, _ = start + def get_name(code): try: return self.linter.msgs_store.get_msg_display_string(code) diff --git a/tests/functional/sequence_of_string_2.py b/tests/functional/sequence_of_string_2.py index 377589b..2fec379 100644 --- a/tests/functional/sequence_of_string_2.py +++ b/tests/functional/sequence_of_string_2.py @@ -3,14 +3,16 @@ def one_param(seq): - # type: (typing.Sequence[str]) -> str # [sequence-of-string] - copy = seq # type:typing.Sequence[str] # [sequence-of-string] + # type: (typing.Sequence[str]) -> str # [sequence-of-string] + copy = seq # type:typing.Sequence[str] # [sequence-of-string] return copy[0] + def multiple_params(message, seq, index): - # type: (string, typing.Sequence[str], int) -> str # [sequence-of-string] + # type: (string, typing.Sequence[str], int) -> str # [sequence-of-string] return message + seq[index] + def return_type(message_1, message_2): - # type: (str, str) -> typing.Sequence[str] # [sequence-of-string] + # type: (str, str) -> typing.Sequence[str] # [sequence-of-string] return [message_1, message_2] diff --git a/tests/functional/sequence_of_string_3.py b/tests/functional/sequence_of_string_3.py index 78d418b..56715e9 100644 --- a/tests/functional/sequence_of_string_3.py +++ b/tests/functional/sequence_of_string_3.py @@ -6,12 +6,14 @@ def one_param(seq: typing.Sequence[str]) -> str: # [sequence-of-string] copy: typing.Sequence[str] = seq # [sequence-of-string] return copy[0] + def multiple_params( message: str, seq: typing.Sequence[str], # [sequence-of-string] index: int) -> str: return message + seq[index] + def return_type(message_1: str, message_2: str ) -> typing.Sequence[str]: # [sequence-of-string] return [message_1, message_2] From f8204a6833200c0719390e7232b485dd8b63c52d Mon Sep 17 00:00:00 2001 From: Alejandro Lujan Toro Date: Thu, 5 Apr 2018 10:04:09 -0400 Subject: [PATCH 07/11] Adjusting line numbers for expected messages --- tests/functional/sequence_of_string_2.txt | 4 ++-- tests/functional/sequence_of_string_3.txt | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/functional/sequence_of_string_2.txt b/tests/functional/sequence_of_string_2.txt index 1f9c4d2..1d3a480 100644 --- a/tests/functional/sequence_of_string_2.txt +++ b/tests/functional/sequence_of_string_2.txt @@ -1,4 +1,4 @@ sequence-of-string:6::Forbidden use of typing.Sequence[str], use typing.List[str] instead sequence-of-string:7::Forbidden use of typing.Sequence[str], use typing.List[str] instead -sequence-of-string:11::Forbidden use of typing.Sequence[str], use typing.List[str] instead -sequence-of-string:15::Forbidden use of typing.Sequence[str], use typing.List[str] instead \ No newline at end of file +sequence-of-string:12::Forbidden use of typing.Sequence[str], use typing.List[str] instead +sequence-of-string:17::Forbidden use of typing.Sequence[str], use typing.List[str] instead \ No newline at end of file diff --git a/tests/functional/sequence_of_string_3.txt b/tests/functional/sequence_of_string_3.txt index 6f6ec48..6106177 100644 --- a/tests/functional/sequence_of_string_3.txt +++ b/tests/functional/sequence_of_string_3.txt @@ -1,4 +1,4 @@ +sequence-of-string:5::Forbidden use of typing.Sequence[str], use typing.List[str] instead sequence-of-string:6::Forbidden use of typing.Sequence[str], use typing.List[str] instead -sequence-of-string:8::Forbidden use of typing.Sequence[str], use typing.List[str] instead -sequence-of-string:13::Forbidden use of typing.Sequence[str], use typing.List[str] instead +sequence-of-string:12::Forbidden use of typing.Sequence[str], use typing.List[str] instead sequence-of-string:18::Forbidden use of typing.Sequence[str], use typing.List[str] instead \ No newline at end of file From 90d3f91ec4db922e927aa2d1f9e3606d48221917 Mon Sep 17 00:00:00 2001 From: Alejandro Lujan Toro Date: Thu, 5 Apr 2018 14:27:06 -0400 Subject: [PATCH 08/11] Py3 support for sequence of string --- shopify_python/shopify_styleguide.py | 21 +++++++++++++++------ tests/functional/sequence_of_string_3.py | 2 +- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/shopify_python/shopify_styleguide.py b/shopify_python/shopify_styleguide.py index f5c0566..e7c72a8 100644 --- a/shopify_python/shopify_styleguide.py +++ b/shopify_python/shopify_styleguide.py @@ -1,6 +1,7 @@ import re import tokenize import typing # pylint: disable=unused-import +import astroid # pylint: disable=unused-import import pylint.utils @@ -36,18 +37,27 @@ class ShopifyStyleGuideChecker(checkers.BaseTokenChecker): RE_PYLINT_DISABLE = re.compile(r'^#[ \t]*pylint:[ \t]*(disable|enable)[ \t]*=(?P[a-zA-Z0-9\-_, \t]+)$') RE_PYLINT_MESSAGE_CODE = re.compile(r'^[A-Z]{1,2}[0-9]{4}$') - RE_SEQUENCE_STRING = re.compile(r'^#.*type:.*Sequence\[str\].*$') + RE_COMMENT_TYPE_ANNOTATION = re.compile(r'^# type.*:.*$') + RE_SEQUENCE_STRING = re.compile(r'^.*Sequence\[str\].*$') def process_tokens(self, tokens): # type: (typing.Sequence[typing.Tuple]) -> None - for _type, string, start, _, _ in tokens: - if _type == tokenize.COMMENT: + for _type, string, start, _, line in tokens: + if _type == tokenize.NAME: + self.__validate_name(string, start, line) + elif _type == tokenize.COMMENT: self.__validate_comment(string, start) def __validate_comment(self, string, start): # type: (str, typing.Tuple[int, int]) -> None self.__disable_name_only(string, start) - self.__sequence_str(string, start) + if self.RE_COMMENT_TYPE_ANNOTATION.match(string): + self.__sequence_str(string, start) + + def __validate_name(self, string, start, line): + # type: (str, typing.Tuple[int, int], str) -> None + if string == 'Sequence' and 'Sequence[str]' in line: + self.__sequence_str(line, start) def __disable_name_only(self, string, start): # type: (str, typing.Tuple[int, int]) -> None @@ -71,5 +81,4 @@ def __sequence_str(self, string, start): # type: (str, typing.Tuple[int, int]) -> None start_row, _ = start if self.RE_SEQUENCE_STRING.match(string): - self.add_message('sequence-of-string', line=start_row, - args={'code': 'foobar', 'name': 'baz'}) + self.add_message('sequence-of-string', line=start_row) diff --git a/tests/functional/sequence_of_string_3.py b/tests/functional/sequence_of_string_3.py index 56715e9..d51305a 100644 --- a/tests/functional/sequence_of_string_3.py +++ b/tests/functional/sequence_of_string_3.py @@ -15,5 +15,5 @@ def multiple_params( def return_type(message_1: str, message_2: str - ) -> typing.Sequence[str]: # [sequence-of-string] + ) -> typing.Sequence[str]: # [sequence-of-string] return [message_1, message_2] From 78ea38886542dc8cc22733eacb4bff209b73765b Mon Sep 17 00:00:00 2001 From: Alejandro Lujan Toro Date: Thu, 5 Apr 2018 14:32:22 -0400 Subject: [PATCH 09/11] Removing unnecessary newline --- tests/functional/sequence_of_string_3.py | 3 +-- tests/functional/sequence_of_string_3.txt | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/tests/functional/sequence_of_string_3.py b/tests/functional/sequence_of_string_3.py index d51305a..b4772c1 100644 --- a/tests/functional/sequence_of_string_3.py +++ b/tests/functional/sequence_of_string_3.py @@ -14,6 +14,5 @@ def multiple_params( return message + seq[index] -def return_type(message_1: str, message_2: str - ) -> typing.Sequence[str]: # [sequence-of-string] +def return_type(message_1: str, message_2: str) -> typing.Sequence[str]: # [sequence-of-string] return [message_1, message_2] diff --git a/tests/functional/sequence_of_string_3.txt b/tests/functional/sequence_of_string_3.txt index 6106177..1a66e77 100644 --- a/tests/functional/sequence_of_string_3.txt +++ b/tests/functional/sequence_of_string_3.txt @@ -1,4 +1,4 @@ sequence-of-string:5::Forbidden use of typing.Sequence[str], use typing.List[str] instead sequence-of-string:6::Forbidden use of typing.Sequence[str], use typing.List[str] instead sequence-of-string:12::Forbidden use of typing.Sequence[str], use typing.List[str] instead -sequence-of-string:18::Forbidden use of typing.Sequence[str], use typing.List[str] instead \ No newline at end of file +sequence-of-string:17::Forbidden use of typing.Sequence[str], use typing.List[str] instead \ No newline at end of file From 78d83fc5a0e01805875630e4e25fa994d905a1ca Mon Sep 17 00:00:00 2001 From: Alejandro Lujan Toro Date: Thu, 5 Apr 2018 14:37:59 -0400 Subject: [PATCH 10/11] Increasing the min python version requirement for :type annotation syntax --- tests/functional/sequence_of_string_3.rc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/functional/sequence_of_string_3.rc b/tests/functional/sequence_of_string_3.rc index 9bf6df0..0ba2b63 100644 --- a/tests/functional/sequence_of_string_3.rc +++ b/tests/functional/sequence_of_string_3.rc @@ -1,3 +1,2 @@ [testoptions] -min_pyver=3.0 - +min_pyver=3.6 From 6f6cad6efa2776d8cb0485530d432ba92211df3c Mon Sep 17 00:00:00 2001 From: Alejandro Lujan Toro Date: Thu, 5 Apr 2018 14:47:01 -0400 Subject: [PATCH 11/11] Cleanup --- shopify_python/shopify_styleguide.py | 3 +-- tests/functional/sequence_of_string_2.txt | 8 ++++---- tests/functional/sequence_of_string_3.txt | 8 ++++---- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/shopify_python/shopify_styleguide.py b/shopify_python/shopify_styleguide.py index e7c72a8..40b2952 100644 --- a/shopify_python/shopify_styleguide.py +++ b/shopify_python/shopify_styleguide.py @@ -1,7 +1,6 @@ import re import tokenize import typing # pylint: disable=unused-import -import astroid # pylint: disable=unused-import import pylint.utils @@ -28,7 +27,7 @@ class ShopifyStyleGuideChecker(checkers.BaseTokenChecker): 'disable-name-only', "Disable pylint rules via message name (e.g. unused-import) and not message code (e.g. W0611) to " "help code reviewers understand why a linter rule was disabled for a line of code."), - 'C6102': ('Forbidden use of typing.Sequence[str], use typing.List[str] instead', + 'C6102': ('Forbidden use of typing.Sequence[str], use typing.List[str] or some specific collection instead', 'sequence-of-string', 'Since str itself also satisfies typing.Sequence[str], the latter should be replaced by ' 'a more specific iterable type, such as typing.List[str]') diff --git a/tests/functional/sequence_of_string_2.txt b/tests/functional/sequence_of_string_2.txt index 1d3a480..59455b9 100644 --- a/tests/functional/sequence_of_string_2.txt +++ b/tests/functional/sequence_of_string_2.txt @@ -1,4 +1,4 @@ -sequence-of-string:6::Forbidden use of typing.Sequence[str], use typing.List[str] instead -sequence-of-string:7::Forbidden use of typing.Sequence[str], use typing.List[str] instead -sequence-of-string:12::Forbidden use of typing.Sequence[str], use typing.List[str] instead -sequence-of-string:17::Forbidden use of typing.Sequence[str], use typing.List[str] instead \ No newline at end of file +sequence-of-string:6::Forbidden use of typing.Sequence[str], use typing.List[str] or some specific collection instead +sequence-of-string:7::Forbidden use of typing.Sequence[str], use typing.List[str] or some specific collection instead +sequence-of-string:12::Forbidden use of typing.Sequence[str], use typing.List[str] or some specific collection instead +sequence-of-string:17::Forbidden use of typing.Sequence[str], use typing.List[str] or some specific collection instead \ No newline at end of file diff --git a/tests/functional/sequence_of_string_3.txt b/tests/functional/sequence_of_string_3.txt index 1a66e77..d11504a 100644 --- a/tests/functional/sequence_of_string_3.txt +++ b/tests/functional/sequence_of_string_3.txt @@ -1,4 +1,4 @@ -sequence-of-string:5::Forbidden use of typing.Sequence[str], use typing.List[str] instead -sequence-of-string:6::Forbidden use of typing.Sequence[str], use typing.List[str] instead -sequence-of-string:12::Forbidden use of typing.Sequence[str], use typing.List[str] instead -sequence-of-string:17::Forbidden use of typing.Sequence[str], use typing.List[str] instead \ No newline at end of file +sequence-of-string:5::Forbidden use of typing.Sequence[str], use typing.List[str] or some specific collection instead +sequence-of-string:6::Forbidden use of typing.Sequence[str], use typing.List[str] or some specific collection instead +sequence-of-string:12::Forbidden use of typing.Sequence[str], use typing.List[str] or some specific collection instead +sequence-of-string:17::Forbidden use of typing.Sequence[str], use typing.List[str] or some specific collection instead \ No newline at end of file