Skip to content

[monitor-control-service] Fix invalid escape sequence SyntaxWarning in data-collection rule create example - #10532

Open
nabeleon94 wants to merge 1 commit into
Azure:mainfrom
nabeleon94:amcs-fix-invalid-escape-warning
Open

nabeleon94 wants to merge 1 commit into
Azure:mainfrom
nabeleon94:amcs-fix-invalid-escape-warning

Conversation

@nabeleon94

@nabeleon94 nabeleon94 commented Oct 28, 2026 •

Copy link
Copy Markdown

🤖 PR Validation — ️✔️ All clear

Breaking Changes Suppressions
️✔️ None ️✔️ None

Fixes #10531

Related command

az monitor data-collection rule create (and every az monitor ... command, since the extension module is imported while building the command table)

Description

With Python 3.12+ (e.g. Azure CLI 2.91.0), any az monitor help/command prints:

.../azext_amcs/aaz/latest/monitor/data_collection/rule/_create.py:21: SyntaxWarning: "\s" is an invalid escape sequence. ...

The class docstring for monitor data-collection rule create contains the example path "C:\samples\dcrEx1.json" in a regular (non-raw) string, so \s is an invalid escape. This escapes the backslashes (C:\\samples\\dcrEx1.json), the same way the sibling _update.py already writes \\Process(_Total)\\Thread Count. The rendered help text is unchanged.

Also bumps the extension to 1.2.1 with a HISTORY entry.

This is the only invalid escape sequence in the extension (checked by compiling every .py under src/monitor-control-service with warnings as errors).

Testing

  • Before: python -W error::SyntaxWarning -c "import azext_amcs.aaz.latest.monitor.data_collection.rule._create" fails with SyntaxError: invalid escape sequence '\s'.
  • After: the import succeeds with warnings as errors, and Create.__doc__ (the help text) is byte-identical to before. It still shows --rule-file "C:\samples\dcrEx1.json".
  • Tested with Python 3.13 and azure-cli-core.

General Guidelines

  • Have you run azdev style <YOUR_EXT> locally? The changed file is # pylint: skip-file / # flake8: noqa generated code. Only a string literal changed.
  • Have you run python scripts/ci/test_index.py -q locally? Not applicable: src/index.json is not modified.
  • My extension version conforms to the Extension version schema (patch bump 1.2.0 → 1.2.1).

Copilot AI balanced review requested due to automatic review settings October 28, 2026 14:36
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

@microsoft-github-policy-service microsoft-github-policy-service Bot added the customer-reported Issues that are reported by GitHub users external to the Azure organization. label Oct 28, 2026
@microsoft-github-policy-service

Copy link
Copy Markdown
Contributor

Thank you for your contribution nabeleon94! We will review the pull request and get back to you soon.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues are reported for the change addressing the Python 3.12+ invalid-escape warning.

No open issues 🎉

What changed in this PR

Fixes the invalid-escape SyntaxWarning emitted when the monitor-control-service extension loads for az monitor commands on Python 3.12+, addressing #10531 without changing rendered help text.

Changes:

  • Escapes backslashes in the data collection rule creation example.
  • Bumps the extension version to 1.2.1 and documents the fix.
File Description
src/​monitor-control-service/​setup.py Bumps the extension version to 1.2.1.
src/​monitor-control-service/​HISTORY.rst Adds a release note describing the warning fix.
src/​monitor-control-service/​azext_amcs/​aaz/​latest/​monitor/​data_collection/​rule/​_create.py Escapes the example path’s backslashes while preserving help output.

Review effort: Balanced

@nabeleon94

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

@yonzhan

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 2 pipeline(s).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

act-observability-squad Auto-Assign Auto assign by bot customer-reported Issues that are reported by GitHub users external to the Azure organization. Monitor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Python SyntaxWarning from monitor-control-service appears across az monitor command groups

5 participants