From ca80c2a83c8c9f7e2ca9604650a3a57e3c06de13 Mon Sep 17 00:00:00 2001 From: Kai Ru Date: Fri, 25 Jun 2021 20:54:59 +0800 Subject: [PATCH 1/5] linter check full command group names --- azdev/__init__.py | 2 +- azdev/__main__.py | 2 +- azdev/operations/linter/linter.py | 16 ++++++++++++++-- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/azdev/__init__.py b/azdev/__init__.py index ee935d8b0..708697a78 100644 --- a/azdev/__init__.py +++ b/azdev/__init__.py @@ -4,4 +4,4 @@ # license information. # ----------------------------------------------------------------------------- -__VERSION__ = '0.1.33' +__VERSION__ = '0.1.34' diff --git a/azdev/__main__.py b/azdev/__main__.py index 2ecb1f7b4..6b047c8cc 100644 --- a/azdev/__main__.py +++ b/azdev/__main__.py @@ -15,7 +15,7 @@ class AzDevCli(CLI): def get_cli_version(self): - from . import __VERSION__ + from azdev import __VERSION__ return __VERSION__ diff --git a/azdev/operations/linter/linter.py b/azdev/operations/linter/linter.py index 88c636766..2b5c2425c 100644 --- a/azdev/operations/linter/linter.py +++ b/azdev/operations/linter/linter.py @@ -46,7 +46,7 @@ def __init__(self, command_loader=None, help_file_entries=None, loaded_help=None self._parameters = {} self._help_file_entries = set(help_file_entries.keys()) self._command_parser = command_loader.cli_ctx.invocation.parser - + self._command_groups = [] for command_name, command in self._command_loader.command_table.items(): self._parameters[command_name] = set() for name in command.arguments: @@ -58,7 +58,17 @@ def commands(self): @property def command_groups(self): - return self._command_loader.command_group_table.keys() + if not self._command_groups: + added_command_groups = set() + for command_group in self._command_loader.command_group_table.keys(): + prefix_name = "" + for word in command_group.split(): + prefix_name = "{} {}".format(prefix_name, word).strip() + if prefix_name in added_command_groups: + continue + added_command_groups.add(prefix_name) + self._command_groups.append(prefix_name) + return self._command_groups @property def help_file_entries(self): @@ -139,6 +149,8 @@ def command_group_expired(self, command_group_name): deprecate_info = group_kwargs.get('deprecate_info', None) if deprecate_info: return deprecate_info.expired() + except KeyError: + pass except AttributeError: # Items with only token presence in the command table will not have any data. They can't be expired. pass From 44296bb7a301f89eaf51609e2ae61a4227aab6f4 Mon Sep 17 00:00:00 2001 From: kai ru <69238381+kairu-ms@users.noreply.github.com> Date: Wed, 30 Jun 2021 11:44:27 +0800 Subject: [PATCH 2/5] Update azdev/operations/linter/linter.py --- azdev/operations/linter/linter.py | 1 + 1 file changed, 1 insertion(+) diff --git a/azdev/operations/linter/linter.py b/azdev/operations/linter/linter.py index 2b5c2425c..24d8bc900 100644 --- a/azdev/operations/linter/linter.py +++ b/azdev/operations/linter/linter.py @@ -65,6 +65,7 @@ def command_groups(self): for word in command_group.split(): prefix_name = "{} {}".format(prefix_name, word).strip() if prefix_name in added_command_groups: + # if the parent command group is added continue continue added_command_groups.add(prefix_name) self._command_groups.append(prefix_name) From 8314b7693b0a02acc7c81ea22aa6e39bd8f68ffb Mon Sep 17 00:00:00 2001 From: kai ru <69238381+kairu-ms@users.noreply.github.com> Date: Wed, 30 Jun 2021 13:52:46 +0800 Subject: [PATCH 3/5] add release history --- HISTORY.rst | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/HISTORY.rst b/HISTORY.rst index 96a27eb32..69dd42bff 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -3,6 +3,10 @@ Release History =============== +0.1.34 +++++++ +* `azdev linter`: support to detect commmand groups which are missing in command_group_table. + 0.1.33 ++++++ * Bump `pylint` to 2.8.2 and move `--ignore` to `pylintrc` file (#301) From 543e3d5814d171aab3c8caa405fc5aa218151497 Mon Sep 17 00:00:00 2001 From: kai ru <69238381+kairu-ms@users.noreply.github.com> Date: Mon, 5 Jul 2021 11:23:17 +0800 Subject: [PATCH 4/5] Update azdev/operations/linter/linter.py --- azdev/operations/linter/linter.py | 1 + 1 file changed, 1 insertion(+) diff --git a/azdev/operations/linter/linter.py b/azdev/operations/linter/linter.py index 24d8bc900..60212611d 100644 --- a/azdev/operations/linter/linter.py +++ b/azdev/operations/linter/linter.py @@ -150,6 +150,7 @@ def command_group_expired(self, command_group_name): deprecate_info = group_kwargs.get('deprecate_info', None) if deprecate_info: return deprecate_info.expired() + # ignore command_group_name which is not in command_group_table. except KeyError: pass except AttributeError: From a47c9decfbbded28b807f9cbe1c08d5f45e3ecb1 Mon Sep 17 00:00:00 2001 From: kai ru <69238381+kairu-ms@users.noreply.github.com> Date: Mon, 5 Jul 2021 11:24:36 +0800 Subject: [PATCH 5/5] Update azdev/operations/linter/linter.py --- azdev/operations/linter/linter.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azdev/operations/linter/linter.py b/azdev/operations/linter/linter.py index 60212611d..0ae250544 100644 --- a/azdev/operations/linter/linter.py +++ b/azdev/operations/linter/linter.py @@ -150,8 +150,8 @@ def command_group_expired(self, command_group_name): deprecate_info = group_kwargs.get('deprecate_info', None) if deprecate_info: return deprecate_info.expired() - # ignore command_group_name which is not in command_group_table. except KeyError: + # ignore command_group_name which is not in command_group_table. pass except AttributeError: # Items with only token presence in the command table will not have any data. They can't be expired.