Skip to content

Commit 3c8701e

Browse files
authored
Updates to run on ADO (#112)
* Copy exclusions from Azure CLI. * Fix document map check. * Fix `azdev verify document-map`. * Port linter change from azure-cli. * Add wrong-import-order to pylint exceptions. * Azdev style fix for CI. * Update version and history. * Fix CI.
1 parent 0d615ec commit 3c8701e

File tree

9 files changed

+72
-29
lines changed

9 files changed

+72
-29
lines changed

HISTORY.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@
33
Release History
44
===============
55

6+
0.1.4
7+
++++++
8+
* `azdev linter`: Fix issue with help example rule.
9+
* `azdev style`: Omit namespace packages from core modules.
10+
* `azdev verify document-map`: Updates to work correctly on Linux.
11+
612
0.1.3
713
++++++
814
* `azdev linter`: Fix issue where certain installations would fail on `ci_exclusions.yml` not found.

azdev/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44
# license information.
55
# -----------------------------------------------------------------------------
66

7-
__VERSION__ = '0.1.3'
7+
__VERSION__ = '0.1.4'

azdev/config/cli_pylintrc

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,20 @@ reports=no
1111
# chained-comparison: Does not provide guidance on what would be better and arguably these are fine.
1212
# useless-import-alias: Removing the alias often breaks the import, so it isn't really useless after all.
1313
# useless-suppression: Depends on the Python version and the pylint version...
14-
disable=missing-docstring,locally-disabled,fixme,cyclic-import,too-many-arguments,invalid-name,duplicate-code,useless-object-inheritance,chained-comparison,useless-import-alias,useless-suppression
14+
# wrong-import-order: Pylint keeps changing its mind...
15+
disable=
16+
missing-docstring,
17+
locally-disabled,
18+
fixme,
19+
cyclic-import,
20+
too-many-arguments,
21+
invalid-name,
22+
duplicate-code,
23+
useless-object-inheritance,
24+
chained-comparison,
25+
useless-import-alias,
26+
useless-suppression,
27+
wrong-import-order
1528

1629
[FORMAT]
1730
max-line-length=120

azdev/config/ext_pylintrc

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,20 @@ reports=no
1111
# chained-comparison: Does not provide guidance on what would be better and arguably these are fine.
1212
# useless-import-alias: Removing the alias often breaks the import, so it isn't really useless after all.
1313
# useless-suppression: Depends on the Python version and the pylint version...
14-
disable=missing-docstring,locally-disabled,fixme,cyclic-import,too-many-arguments,invalid-name,duplicate-code,useless-object-inheritance,chained-comparison,useless-import-alias,useless-suppression
15-
16-
[TYPECHECK]
17-
# For Azure CLI extensions, we ignore some import errors as they'll be available in the environment of the CLI
18-
ignored-modules=azure,azure.cli,azure.cli.core,azure.cli.core.commands,knack,msrestazure,argcomplete
14+
# wrong-import-order: Pylint keeps changing its mind...
15+
disable=
16+
missing-docstring,
17+
locally-disabled,
18+
fixme,
19+
cyclic-import,
20+
too-many-arguments,
21+
invalid-name,
22+
duplicate-code,
23+
useless-object-inheritance,
24+
chained-comparison,
25+
useless-import-alias,
26+
useless-suppression,
27+
wrong-import-order
1928

2029
[FORMAT]
2130
max-line-length=120
@@ -50,3 +59,7 @@ function-name-hint=lower_case_with_underscores
5059
argument-name-hint=lower_case_with_underscores
5160
variable-name-hint=lower_case_with_underscores
5261
inlinevar-name-hint=lower_case_with_underscores (short is OK)
62+
63+
[TYPECHECK]
64+
# For Azure CLI extensions, we ignore some import errors as they'll be available in the environment of the CLI
65+
ignored-modules=azure,azure.cli,azure.cli.core,azure.cli.core.commands,knack,msrestazure,argcomplete

azdev/operations/help.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ def _help_files_not_in_map(cli_repo, help_files_in_map):
6565
not_in_map = []
6666
for _, path in get_path_table()['mod'].items():
6767
help_path = os.path.join(path, HELP_FILE_NAME)
68-
help_path = help_path.replace(cli_repo.lower() + '\\', '')
69-
if help_path in help_files_in_map:
68+
help_path = help_path.replace(cli_repo.lower() + os.sep, '')
69+
if help_path in help_files_in_map or not os.path.isfile(help_path):
7070
continue
7171
not_in_map.append(help_path)
7272
return not_in_map

azdev/operations/linter/rules/ci_exclusions.yml

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,11 @@
33
# note that this is a TEMPORARY stop-gap and the rule violations should be addressed
44

55
no_ids_for_list_commands:
6-
- advisor
76
- dla
87
- dls
9-
- eventgrid
108
- iot
119
- rdbms
1210
- sql
13-
missing_parameter_help:
14-
- acs
15-
- cdn
16-
- dla
17-
- dls
18-
- eventgrid
19-
- eventhubs
20-
- keyvault
21-
- rdbms
22-
- resource
23-
- role
24-
- servicebus
25-
- servicefabric
26-
- sql
11+
faulty_help_example_parameters_rule:
12+
- find
2713
...

azdev/operations/linter/rules/help_rules.py

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,28 @@ def get_value_side_effect(action, arg_string): # pylint: disable=unused-argumen
142142
def _extract_commands_from_example(example_text):
143143

144144
# fold commands spanning multiple lines into one line. Split commands that use pipes
145-
example_text = example_text.replace("\\\n", " ") # wrap escaped newline into one line.
146-
example_text = example_text.replace("\\ ", " ") # remove left over escape after wrapping
145+
# handle single and double quotes properly
146+
lines = example_text.splitlines()
147+
example_text = ""
148+
quote = None
149+
for line in lines:
150+
for ch in line:
151+
if quote is None:
152+
if ch in ('"', "'"):
153+
quote = ch
154+
elif ch == quote:
155+
quote = None
156+
if quote is None and line.endswith("\\"):
157+
# attach this line with removed '\' and no '\n' (space at the end to keep consistent with initial algorithm)
158+
example_text += line[0:-1] + " "
159+
elif quote is not None:
160+
# attach this line without '\n'
161+
example_text += line
162+
else:
163+
# attach this line with '\n' as no quote and no continuation
164+
example_text += line + "\n"
165+
# this is also for consistency with original algorithm
166+
example_text = example_text.replace("\\ ", " ")
147167

148168
commands = example_text.splitlines()
149169
processed_commands = []

azdev/operations/style.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ def check_style(modules=None, pylint=False, pep8=False):
2525
heading('Style Check')
2626

2727
selected_modules = get_path_table(include_only=modules)
28+
29+
# remove these two non-modules
30+
selected_modules['core'].pop('azure-cli-nspkg', None)
31+
selected_modules['core'].pop('azure-cli-command_modules-nspkg', None)
32+
2833
pep8_result = None
2934
pylint_result = None
3035

scripts/ci/install.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ set -ev
55
echo "Install azdev into virtual environment"
66
python -m venv env
77
. env/bin/activate
8-
pip install -U pip setuptools wheel
9-
pip install $(find ${BUILD_ARTIFACTSTAGINGDIRECTORY}/pypi -name *.tar.gz)
8+
pip install -U pip setuptools wheel -q
9+
pip install $(find ${BUILD_ARTIFACTSTAGINGDIRECTORY}/pypi -name *.tar.gz) -q
1010
git clone https://github.com/Azure/azure-cli.git
1111
git clone https://github.com/Azure/azure-cli-extensions.git
1212
azdev setup -c -r azure-cli-extensions

0 commit comments

Comments
 (0)