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) 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..0ae250544 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,18 @@ 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: + # if the parent command group is added continue + 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 +150,9 @@ 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: + # 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. pass