{Misc.} Improve code style and prepare for pylint 2.17#26685
{Misc.} Improve code style and prepare for pylint 2.17#26685
Conversation
️✔️AzureCLI-FullTest
|
️✔️AzureCLI-BreakingChangeTest
|
|
Misc. |
| function-name-hint=lower_case_with_underscores | ||
| argument-name-hint=lower_case_with_underscores | ||
| variable-name-hint=lower_case_with_underscores | ||
| inlinevar-name-hint=lower_case_with_underscores (short is OK) |
There was a problem hiding this comment.
xxx-hint is shown when pylint found invalid name:
demo/demo.py:19:0: C0103: Class name "aa" doesn't conform to '{invalid-classname-hint}' pattern ('[_]{0,2}[A-Z]{1}[A-Za-z0-9]{0,30}$' pattern) (invalid-name) (pylint-dev/pylint#2663)
I remove these configs:
- These
xxx-hintconfigs never take effect, asinvalid-nameis disabled since first commit: Touch up pylintrc #3806. This is also mentioned in the comment:
The invalid-name checker must be enabled for these hints to be used.
- The default value is enough, for example,
module-naming-styleissnake_case.
PS:
variable-name-hint raises error from pylint 2.14: pylint-dev/pylint#6931
These options changes to xxxx-style, see https://pylint.pycqa.org/en/latest/user_guide/configuration/all-options.html#basic-checker.
There was a problem hiding this comment.
This is very nice investigation and makes the context much clearer.
| def _parse_pair(pair, delimiter): | ||
| if delimiter not in pair: | ||
| InvalidArgumentValueError("invalid format of pair {0}".format(pair)) | ||
| raise InvalidArgumentValueError("invalid format of pair {0}".format(pair)) |
There was a problem hiding this comment.
This line makes no sense without raise.
W0133: Exception statement has no effect (pointless-exception-statement)
| if kwargs[self._request_param['name']] is None: | ||
| raise ValueError(message.format(self._request_param['model'])) | ||
| if kwargs[self._request_param['name']] is None: | ||
| raise ValueError(message.format(self._request_param['model'])) |
There was a problem hiding this comment.
R1720: Unnecessary "else" after "raise", remove the "else" and de-indent the code inside it (no-else-raise)
| cmd.cli_ctx, "acrpull", assignee, scope=registry_id, is_service_principal=is_service_principal | ||
| ): | ||
| raise AzCLIError("Could not delete role assignments for ACR. " "Are you an Owner on this subscription?") | ||
| raise AzCLIError("Could not delete role assignments for ACR. Are you an Owner on this subscription?") |
There was a problem hiding this comment.
W1404: Implicit string concatenation found in call (implicit-str-concat)
|
|
||
| def __format_count(self): | ||
| untouched_keys = [x for x in self.__store.keys() if x not in self.__count.keys()] | ||
| untouched_keys = [x for x in self.__store if x not in self.__count] |
There was a problem hiding this comment.
C0201: Consider iterating the dictionary directly instead of calling .keys() (consider-iterating-dictionary)
| configs = _generic_site_operation(cmd.cli_ctx, resource_group_name, name, 'get_configuration', slot) | ||
| access_rules = configs.scm_ip_security_restrictions if scm_site else configs.ip_security_restrictions | ||
| ip_exists = [(lambda x: x.ip_address == namespace.ip_address)(x) for x in access_rules] | ||
| ip_exists = [x.ip_address == namespace.ip_address for x in access_rules] |
There was a problem hiding this comment.
C3002: Lambda expression called directly. Execute the expression inline instead. (unnecessary-direct-lambda-call)
| for edition_idx, edition in enumerate(capability.supported_flexible_server_editions): | ||
| if edition.name == 'MemoryOptimized': | ||
| result[capability_idx].supported_flexible_server_editions[edition_idx].name = 'BusinessCritical' | ||
| capability.supported_flexible_server_editions[edition_idx].name = 'BusinessCritical' |
There was a problem hiding this comment.
R1736: Unnecessary list index lookup, use 'capability' instead (unnecessary-list-index-lookup)
| def exists(client, table_name): | ||
| generator = client.query_tables("TableName eq '{}'".format(table_name)) | ||
| return list(next(generator.by_page())) != [] | ||
| return bool(list(next(generator.by_page()))) |
There was a problem hiding this comment.
C1803: 'list(...) != []' can be simplified to 'list(...)' as an empty list is falsey (use-implicit-booleaness-not-comparison)
| # Get from the config file | ||
| return None | ||
| if sum([1 if v is not None else 0 for v in (min_count, max_count)]) == 1: | ||
| if sum(1 if v is not None else 0 for v in (min_count, max_count)) == 1: |
There was a problem hiding this comment.
R1728: Consider using a generator instead 'sum(1 if v is not None else 0 for v in (min_count, max_count))' (consider-using-generator)
bbe1967 to
da25845
Compare
| . env/bin/activate | ||
| python -m pip install -U pip | ||
| pip install azdev | ||
| pip install git+https://github.com/dciborow/azure-cli-dev-tools.git@dciborow/pylint |
There was a problem hiding this comment.
This line needs to be removed when azdev is released.
|
Really detailed explanation for every change! Nice work! @bebound |
|
@bebound, you have done an outstanding job with great attention to detail. |
Description
Ensure that the CI passes in the new azdev(Azure/azure-cli-dev-tools#359) and prepare for Python 3.11 support.
Azure is compatible with flake8 6.0 in #25370
Disabled rules:
Testing Guide
History Notes
[Component Name 1] BREAKING CHANGE:
az command a: Make some customer-facing breaking change[Component Name 2]
az command b: Add some customer-facing featureThis checklist is used to make sure that common guidelines for a pull request are followed.
The PR title and description has followed the guideline in Submitting Pull Requests.
I adhere to the Command Guidelines.
I adhere to the Error Handling Guidelines.