Azure / Azure/azure-cli

SyntaxWarning: invalid escape sequence in _models.py when running Azure CLI on macOS

Open
#31,789 6 comments 5 reactions 0 assignees View on GitHub
Account act-identity-squad act-observability-squad Auto-Assign Batch customer-reported Possible-Solution question Service Attention Similar-Issue
Dominant language
Python
Stars
4.6k
Forks
3.5k
Avg merge
3d 2h
Merged PRs (30d)
60

Description

### Describe the bug

When running the `azure-cli` on macOS (Homebrew install), Python shows SyntaxWarning messages about invalid escape sequences in `docstrings` within the `azure.batch.models._models.py` file.

### Related command

`az login`

### Errors

```bash
/opt/homebrew/Cellar/azure-cli/2.75.0/libexec/lib/python3.12/site-packages/azure/batch/models/_models.py:9067: SyntaxWarning: invalid escape sequence '\ '
"""The source port ranges to match for the rule. Valid values are '\ *' (for all ports 0 - 65535),
/opt/homebrew/Cellar/azure-cli/2.75.0/libexec/lib/python3.12/site-packages/azure/batch/models/_models.py:9235: SyntaxWarning: invalid escape sequence '\ '
using brackets (for example abc[\ *] would match a file named abc*\ ). Note that both and / are
```

### Issue script & Debug output

Not sure this step is necessary for a syntax error telling the line number.

```bash
/opt/homebrew/Cellar/azure-cli/2.75.0/libexec/lib/python3.12/site-packages/azure/batch/models/_models.py:9067: SyntaxWarning: invalid escape sequence '\ '
"""The source port ranges to match for the rule. Valid values are '\ *' (for all ports 0 - 65535),
/opt/homebrew/Cellar/azure-cli/2.75.0/libexec/lib/python3.12/site-packages/azure/batch/models/_models.py:9235: SyntaxWarning: invalid escape sequence '\ '
using brackets (for example abc[\ *] would match a file named abc*\ ). Note that both and / are
Expected behavior
No SyntaxWarning should appear. Backslashes in docstrings should be escaped (\\) or the string should be marked as a raw string (r'...').
```

### Expected behavior

No SyntaxWarning should appear. Backslashes in docstrings should be escaped (\\) or the string should be marked as a raw string (r'...').

### Environment Summary

macOS Sequoia 15.5 (24F74)
Python 3.12
Azure CLI installed via Homebrew (azure-cli/2.75.0)

### Additional context

This is a docstring only — so there’s no runtime breakage. It just clutters the output with warnings.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.