{CI} Fix all style errors for pylint 4.x compatibility#33347
{CI} Fix all style errors for pylint 4.x compatibility#33347YangAn-microsoft wants to merge 7 commits into
Conversation
… duplicate functions, codecs.open migration)
️✔️AzureCLI-FullTest
|
️✔️AzureCLI-BreakingChangeTest
|
|
The git hooks are available for azure-cli and azure-cli-extensions repos. They could help you run required checks before creating the PR. Please sync the latest code with latest dev branch (for azure-cli) or main branch (for azure-cli-extensions). pip install azdev --upgrade
azdev setup -c <your azure-cli repo path> -r <your azure-cli-extensions repo path>
|
|
Thank you for your contribution! We will review the pull request and get back to you soon. |
There was a problem hiding this comment.
Pull request overview
This PR updates Azure CLI source to pass azdev style --pylint under pylint 4.x (notably on Python 3.14), primarily by addressing logging-format issues, removing duplicate function definitions, and updating deprecated file-reading usage.
Changes:
- Fix logging calls to use parameterized formatting compatible with pylint 4.x checks.
- Remove duplicate helper function definitions flagged by pylint (keeping the canonical definitions).
- Replace
codecs.openwith built-inopen(..., encoding=...)in core file-reading utility.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/azure-cli/azure/cli/command_modules/synapse/manual/operations/sqlpoolblobauditingpolicy.py | Removes a duplicate diagnostic-settings helper implementation. |
| src/azure-cli/azure/cli/command_modules/cosmosdb/custom.py | Removes a duplicate _handle_exists_exception helper definition. |
| src/azure-cli/azure/cli/command_modules/containerapp/_utils.py | Removes a duplicate _remove_env_vars definition, keeping a single implementation. |
| src/azure-cli/azure/cli/command_modules/botservice/custom.py | Adjusts log messages and fixes a logging call to be properly parameterized. |
| src/azure-cli/azure/cli/command_modules/batch/_command_type.py | Tweaks Optional/Union(None) type-hint handling to satisfy pylint 4.x. |
| src/azure-cli/azure/cli/command_modules/appservice/custom.py | Removes an unnecessary _list_app import (function is defined locally). |
| src/azure-cli/azure/cli/command_modules/apim/custom.py | Fixes an incorrect logger.warning format string/arguments pairing. |
| src/azure-cli-core/azure/cli/core/util.py | Replaces deprecated codecs.open usage with built-in open and explicit encodings. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| try: | ||
| # Extract the link from the response where results are stored | ||
| link = response_dict['additional_properties']['properties']['value']['link'] | ||
| except KeyError: | ||
| logger.warning("Error exporting api from APIManagement. The expected link is not present in the response.") | ||
| return |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
…rning - Replace silent return statements with CLIError exceptions in apim_api_export - Raises CLIError when response link is missing (KeyError) - Raises CLIError when API export request returns non-OK status - Raises CLIError when API export request times out - This ensures proper error signaling in automation/CI pipelines (exit code non-zero on failure) - Addresses review feedback: guard clauses must not mask failures
…roper error handling
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 8 out of 8 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (1)
src/azure-cli/azure/cli/command_modules/apim/custom.py:605
- In
apim_api_export, if the downloaded export payload is not valid JSON/YAML/XML, the nested parse attempts fall through after logging "Content is not in JSON, YAML, or XML format." without assigningexportedResultContent. The subsequent file-writing block then dereferencesexportedResultContent, which will raiseUnboundLocalErrorand hide the real payload/format issue. EnsureexportedResultContentis always assigned (e.g., default toexportedResults.text) or raise aCLIErrorwhen parsing fails so the command exits cleanly.
try:
# Try to parse as JSON
exportedResultContent = json.loads(exportedResults.text)
except json.JSONDecodeError:
try:
# Try to parse as YAML
exportedResultContent = yaml.safe_load(exportedResults.text)
except yaml.YAMLError:
try:
# Try to parse as XML
exportedResultContent = ET.fromstring(exportedResults.text)
except ET.ParseError:
logger.warning("Content is not in JSON, YAML, or XML format.")
This PR contains Azure CLI code changes required to pass style checks with pylint 4.x.
What is included
Scope
Coordination