Skip to content

Commit 66dfd44

Browse files
Merge branch 'main' into Chakradhar886-patch-1
2 parents bbe4d76 + 59e1823 commit 66dfd44

20 files changed

Lines changed: 3353 additions & 94 deletions

File tree

.github/chronus/package-lock.json

Lines changed: 2509 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.github/chronus/package.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"name": "azure-sdk-for-python-changelog-tools",
3+
"private": true,
4+
"description": "Pinned Node dev dependencies used by 'azpysdk changelog' (Chronus).",
5+
"devDependencies": {
6+
"@chronus/chronus": "1.3.1",
7+
"@chronus/github": "1.0.6"
8+
}
9+
}

.github/workflows/azure-sdk-tools.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ jobs:
7979

8080
- name: Install azure-sdk-tools on in global uv, discover azpysdk checks
8181
run: |
82-
uv pip install --system eng/tools/azure-sdk-tools[ghtools,conda,systemperf]
82+
uv pip install --system -e eng/tools/azure-sdk-tools[ghtools,conda,systemperf]
8383
8484
# Discover available azpysdk commands from the {command1,command2,...} line in help output
8585
CHECKS=$(azpysdk -h 2>&1 | \
@@ -88,6 +88,7 @@ jobs:
8888
tr -d '{}' | \
8989
tr ',' '\n' | \
9090
grep -v '^next-' | \
91+
grep -v '^changelog$' | \
9192
sort | \
9293
paste -sd,)
9394

.mcp.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"mcpServers": {
3+
"azure-sdk-mcp": {
4+
"type": "stdio",
5+
"command": "pwsh",
6+
"args": [
7+
"./eng/common/mcp/azure-sdk-mcp.ps1",
8+
"-Run"
9+
]
10+
},
11+
"github-agentic-workflows": {
12+
"command": "gh",
13+
"args": [
14+
"aw",
15+
"mcp-server"
16+
]
17+
}
18+
}
19+
}

.vscode/cspell.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -495,6 +495,7 @@
495495
"vnet",
496496
"volcz",
497497
"vsts",
498+
"waza",
498499
"wchar",
499500
"wesh",
500501
"westcentralus",

doc/dev/static_type_checking.md

Lines changed: 42 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -130,30 +130,46 @@ Almost anything can be used as a type in annotations.
130130
or [collections.abc](https://docs.python.org/3/library/collections.abc.html), or external packages
131131
3) Types from the [typing](https://docs.python.org/3/library/typing.html)
132132
or [typing_extensions](https://github.com/python/typing_extensions) modules
133-
4) Built-in generic types, like `list` or `dict`*.
134-
> *Note: Supported in Python 3.9+. For <3.9, You must include `from __future__ import annotations` import to be able to pass in generic `list[str]` as a type hint rather than `typing.List[str]`.
133+
4) Built-in generic types, like `list` or `dict`.
135134

136-
Here are a few considerations and notes on Python version support:
135+
Here are a few considerations and notes on Python version support. The Azure SDK for Python supports Python 3.10 and higher, so the examples in this guide assume Python 3.10 as the baseline.
137136

138137
- With [PEP585](https://peps.python.org/pep-0585/) and [PEP563](https://peps.python.org/pep-0563/), importing certain
139138
generic collection types from `typing` has been [deprecated](https://peps.python.org/pep-0585/#implementation) in
140139
favor for using the types in `collections.abc` or generic collection type hints (like `list`) from the standard library.
141-
If you'd like to use types from `collections.abc`, you can check the Python version at runtime (`collections.abc` types did not have [] notation / indexing support added until 3.9).
140+
Since Python 3.10 is the minimum supported version, you can import directly from `collections.abc` and use `[]` indexing without a version check:
142141

143142
```python
144-
import sys
143+
from collections.abc import Sequence
144+
```
145+
146+
- The `typing-extensions` library backports types that are introduced only in later versions of Python so that they can be used in earlier Python versions. Since the Azure SDK for Python supports Python 3.10 and higher, most commonly used typing constructs (e.g. `Protocol`, `Literal`, `TypedDict`, `Final`, `runtime_checkable`, `TypeAlias`, `ParamSpec`, `Concatenate`) are available directly from `typing` and do not need `typing-extensions`.
145147

146-
if sys.version_info < (3, 9):
147-
from typing import Sequence
148-
else:
149-
from collections.abc import Sequence
148+
```python
149+
from typing import Protocol
150150
```
151151

152-
- The `typing-extensions` library backports types that are introduced only in later versions of Python (e.g. `Protocol`
153-
which was introduced in Python 3.8) so that they can be used in earlier Python versions.
152+
Features added after 3.10 still require `typing-extensions` on the Python 3.10 baseline, including:
153+
154+
- `Self` (3.11)
155+
- `LiteralString` (3.11)
156+
- `Required` / `NotRequired` for `TypedDict` (3.11)
157+
- Generic `TypedDict` (3.11)
158+
- `Never` / `assert_never` / `assert_type` / `reveal_type` (3.11)
159+
- `TypeVarTuple` / `Unpack` (3.11)
160+
- `dataclass_transform` (3.11)
161+
- `@override` (3.12)
162+
- PEP 695 `type` statement / `TypeAliasType` (3.12)
163+
- `ReadOnly` for `TypedDict` (3.13)
154164

155165
```python
156-
from typing_extensions import Protocol
166+
# Self was added to typing in 3.11, so import from typing_extensions on 3.10
167+
from typing_extensions import Self
168+
169+
class Tree:
170+
@classmethod
171+
def build(cls) -> Self:
172+
return cls()
157173
```
158174

159175
If using `typing-extensions`, you must add it to the install dependencies for your library (do not rely on install by `azure-core`)
@@ -163,8 +179,7 @@ from `typing` if supported, or `typing-extensions` if the Python version is too
163179
check yourself.
164180

165181
See the [typing-extensions](https://github.com/python/typing_extensions) docs to check what has been
166-
backported. This document calls out which types are needed through `typing-extensions` based on support of Python 3.7+.
167-
Some commonly used types imported from `typing-extensions` are Literal, TypedDict, Protocol, runtime_checkable, and Final.
182+
backported. This document calls out which types are needed through `typing-extensions` only when they are not yet available in the standard `typing` module on Python 3.10.
168183

169184
## Install and run type checkers on your client library code
170185

@@ -382,7 +397,7 @@ def begin_export_project(
382397

383398
Per PEP 484, type checkers have moved towards requiring the Optional type to be made explicit when a default of None is provided.
384399

385-
> Note: The `X | None` syntax is only supported in Python 3.10+.
400+
> Note: Since Python 3.10 is the minimum supported version, you can also use the `X | None` syntax (PEP 604) instead of `Optional[X]`.
386401
387402
### Typing for collections
388403

@@ -422,11 +437,10 @@ specified a generic `typing.Dict` here, the `entity` passed must be a `dict` or
422437
accepted.
423438

424439
With [PEP 589](https://peps.python.org/pep-0589/), a `TypedDict` was introduced in Python 3.8 which allows you to add
425-
type hints for dictionaries with a fixed set of keys. The syntax for this looks similar to building a dataclass:
440+
type hints for dictionaries with a fixed set of keys. It is available directly from `typing` in Python 3.10. The syntax for this looks similar to building a dataclass:
426441

427442
```python
428-
# from typing import TypedDict # Python >= 3.8
429-
from typing_extensions import TypedDict
443+
from typing import TypedDict
430444

431445

432446
class Employee(TypedDict):
@@ -464,11 +478,10 @@ e.g. `isinstance(employee, Employee)` will throw a `TypeError`. Usage of `TypedD
464478
type checkers and Intellisense how a specific dict should be constructed and help the type checkers warn users if
465479
they try to access keys which don't exist.
466480

467-
Use of generic TypedDict is also supported via typing_extensions (>=4.3.0). For example,
481+
Generic `TypedDict` is supported in Python 3.11+. On Python 3.10, use `typing_extensions` (>=4.3.0) to use generic `TypedDict`. For example,
468482

469483
```python
470-
# from typing import TypedDict # Python >= 3.8
471-
from typing_extensions import TypedDict
484+
from typing_extensions import TypedDict # use typing_extensions for generic TypedDict on 3.10
472485
from typing import Generic, TypeVar, List
473486

474487
T = TypeVar("T")
@@ -486,8 +499,6 @@ employee = Employee[str](name="krista", title="swe", id=123, current=True, addit
486499

487500
See the [TypedDict](https://docs.python.org/3/library/typing.html#typing.TypedDict) docs for more options.
488501

489-
> Note that TypedDict is backported to older versions of Python by using typing_extensions.
490-
491502
#### List
492503

493504
The [typing.List](https://docs.python.org/3/library/typing.html#typing.List) docs make a recommendation:
@@ -801,14 +812,11 @@ If it's possible that a type alias could be confused with a global assignment, e
801812
This removes ambiguity for the type checker and indicates this isn't a normal variable assignment.
802813

803814
```python
804-
# from typing import TypeAlias Python >=3.10
805-
from typing_extensions import TypeAlias
815+
from typing import TypeAlias
806816

807817
x: TypeAlias = 1
808818
```
809819

810-
> Note that TypeAlias is backported to older versions of Python by using typing_extensions.
811-
812820
### Use typing.overload to overload a function
813821

814822
`typing.overload` allows for annotating different combinations of typed arguments for a function. This can be useful when the
@@ -1095,8 +1103,7 @@ Below we create a `SupportsFly` protocol class which expects a `fly()` method on
10951103
into `ascend()`.
10961104

10971105
```python
1098-
# from typing import Protocol # Python >=3.8
1099-
from typing_extensions import Protocol
1106+
from typing import Protocol
11001107

11011108

11021109
class SupportsFly(Protocol):
@@ -1157,8 +1164,7 @@ See more on Protocols in the [reference documentation](https://docs.python.org/3
11571164
If a Protocol is marked with @runtime_checkable, it can be used with `isinstance()` and `issubclass()` at runtime.
11581165

11591166
```python
1160-
# from typing import runtime_checkable Python >=3.8
1161-
from typing_extensions import runtime_checkable, Protocol
1167+
from typing import runtime_checkable, Protocol
11621168

11631169

11641170
@runtime_checkable
@@ -1173,17 +1179,14 @@ assert isinstance(Penguin, SupportsFly) # False
11731179
Because this is a runtime check, only the presence of the required methods defined by the Protocol is checked -- not
11741180
their type signatures.
11751181

1176-
> Note that runtime_checkable is backported to older versions of Python by using typing_extensions.
1177-
11781182
### Use typing.Literal to restrict based on exact values
11791183

11801184
[PEP 586](https://peps.python.org/pep-0586/) introduced the `typing.Literal` type which can be used to indicate that an
11811185
expression has a literal specific value. A Literal can contain one or more literal bool, int, str, bytes, or enum
11821186
values:
11831187

11841188
```python
1185-
# from typing import Literal Python >=3.8
1186-
from typing_extensions import Literal
1189+
from typing import Literal
11871190

11881191
doc_type = Literal["prebuilt-receipt"]
11891192
allowed_content_types = Literal["application/json", "text/plain", "image/png", "image/jpeg"]
@@ -1249,7 +1252,7 @@ main.py:51: note: Revealed type is "__main__.SelectionMark"
12491252
To solve this issue, we can update the `get_element` function to have overloads based on their Literal `kind`:
12501253

12511254
```python
1252-
from typing_extensions import Literal, overload
1255+
from typing import Literal, overload
12531256

12541257

12551258
@overload
@@ -1293,8 +1296,7 @@ making `isinstance` checks to understand the result. The following example shows
12931296
a Union of types which each contain a discriminator property, `kind`, typed as a Literal.
12941297

12951298
```python
1296-
from typing import Union
1297-
from typing_extensions import Literal
1299+
from typing import Union, Literal
12981300

12991301

13001302
# client library code
@@ -1361,8 +1363,6 @@ elif isinstance(ele, FormLine):
13611363

13621364
Therefore, it is preferred to use `typing.Literal` in this situation to provide the best type checking experience for our users.
13631365

1364-
> Note that Literal is backported to older versions of Python by using typing_extensions.
1365-
13661366
### Use typing.NewType to restrict a type to a specific context
13671367

13681368
`NewType` can be useful to catch errors where a particular type is expected. `NewType` will take an existing type and
@@ -1398,8 +1398,7 @@ At runtime, `NewType` will return an object that returns its argument when calle
13981398
It is best used when a variable's scope spans a large amount of modules and you want to ensure that it stays immutable (i.e. no line of code tries to change it).
13991399

14001400
```python
1401-
# from typing import Final Python >=3.8
1402-
from typing_extensions import Final
1401+
from typing import Final
14031402

14041403
MAX_BLOB_SIZE: Final = 4 * 1024 * 1024
14051404
```
@@ -1414,7 +1413,7 @@ Found 1 error in 1 file (checked 1 source file)
14141413
Additionally, If you have a method that should not be overridden or a class that should not be subclassed, consider decorating with `@final`.
14151414

14161415
```python
1417-
from typing_extensions import final
1416+
from typing import final
14181417

14191418
class BlobClient:
14201419
@final

doc/dev/static_type_checking_cheat_sheet.md

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -85,14 +85,19 @@ class Tree:
8585
- Do use the latest typing features available. If not supported by older versions of Python, consider taking a dependency and importing from `typing-extensions`.
8686

8787
```python
88-
# from typing import TypedDict Python >3.8
89-
from typing_extensions import TypedDict
88+
# Self was added to typing in 3.11, so import from typing_extensions on 3.10
89+
from typing_extensions import Self
90+
91+
class Tree:
92+
@classmethod
93+
def build(cls) -> Self:
94+
return cls()
9095
```
9196

9297
### Importing types
9398

9499
- Do use only publicly exposed client library types in type hints.
95-
- Do import types from modules such as `typing`, `typing_extensions`, `collections`, and `collections.abc`(Note that indexing support for generic collection types from `collections.abc` is only supported on Python 3.9+).
100+
- Do import types from modules such as `typing`, `typing_extensions`, `collections`, and `collections.abc`. Generic collection types from `collections.abc` support `[]` indexing on Python 3.10 (the minimum supported version).
96101
- Do not import regular type hints under a `typing.TYPE_CHECKING` block. You may use `TYPE_CHECKING` to fix a circular import or avoid importing a type only needed in type annotations that is otherwise costly to load at runtime.
97102

98103
```python
@@ -278,7 +283,7 @@ class Triangle:
278283
- Mark your `Protocol`s as `@runtime_checkable` so users can use them in `isinstance` and `issubclass` checks.
279284

280285
```python
281-
from typing_extensions import Protocol, runtime_checkable
286+
from typing import Protocol, runtime_checkable
282287

283288
@runtime_checkable
284289
class TokenCredential(Protocol):
@@ -386,7 +391,7 @@ CredentialTypes = Union[AzureKeyCredential, TokenCredential, AzureSasCredential,
386391
- You can use `typing.Literal` when you want to restrict based on exact values.
387392

388393
```python
389-
from typing_extensions import Literal
394+
from typing import Literal
390395

391396
PrimaryColors = Literal["red", "yellow", "blue"]
392397
```
@@ -398,15 +403,15 @@ PrimaryColors = Literal["red", "yellow", "blue"]
398403
- If you have a type that should not change or get re-assigned in the code, consider typing it as `typing.Final`.
399404

400405
```python
401-
from typing_extensions import Final
406+
from typing import Final
402407

403408
MAX_BLOB_SIZE: Final = 4 * 1024 * 1024
404409
```
405410

406411
- If you have a method that should not be overridden or a class that should not be subclassed, consider decorating with `@final`.
407412

408413
```python
409-
from typing_extensions import final
414+
from typing import final
410415

411416
class BlobClient:
412417
@final

doc/python_version_support_policy.md

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,18 @@ This page describes the Python version support policy for the Azure SDK for Pyth
44

55
End of support means, in the SDK context, that new features will not be supported for those unsupported Python versions. It will still be possible to install older SDK versions from PyPI as necessary.
66

7+
> **Note:** The "SDKs End Of Support" date is inclusive — the listed day is the last supported day, and the next day is the first unsupported day.
8+
79
| Python Version | PSF End of Support | SDKs End Of Support |
810
|----------------|--------------------|---------------------|
911
| 2.7 ([PEP 373](https://peps.python.org/pep-0373/)) | April 2020 | January 2022 |
1012
| 3.6 ([PEP 494](https://www.python.org/dev/peps/pep-0494/#lifespan)) | December 2021 | August 2022 |
1113
| 3.7 ([PEP 537](https://www.python.org/dev/peps/pep-0537/#lifespan)) | June 2023 | December 2023 |
1214
| 3.8 ([PEP 569](https://www.python.org/dev/peps/pep-0569/#lifespan)) | October 2024 | April 2025 |
13-
| 3.9 ([PEP 596](https://www.python.org/dev/peps/pep-0596/#lifespan)) | October 2025 | April 2026 |
14-
| 3.10 ([PEP 619](https://www.python.org/dev/peps/pep-0619/#lifespan)) | October 2026 | April 2027 |
15-
| 3.11 ([PEP 664](https://www.python.org/dev/peps/pep-0664/#lifespan)) | October 2027 | April 2028 |
16-
| 3.12 ([PEP 693](https://www.python.org/dev/peps/pep-0693/#lifespan)) | October 2028 | April 2029 |
17-
| 3.13 ([PEP 719](https://www.python.org/dev/peps/pep-0719/#lifespan)) | October 2029 | April 2030 |
18-
| 3.14 ([PEP 745](https://www.python.org/dev/peps/pep-0745/#lifespan)) | October 2030 | April 2031 |
19-
| 3.15 ([PEP 790](https://www.python.org/dev/peps/pep-0790/#lifespan)) | October 2031 | April 2032 |
15+
| 3.9 ([PEP 596](https://www.python.org/dev/peps/pep-0596/#lifespan)) | October 2025 | April 30, 2026 |
16+
| 3.10 ([PEP 619](https://www.python.org/dev/peps/pep-0619/#lifespan)) | October 2026 | April 30, 2027 |
17+
| 3.11 ([PEP 664](https://www.python.org/dev/peps/pep-0664/#lifespan)) | October 2027 | April 30, 2028 |
18+
| 3.12 ([PEP 693](https://www.python.org/dev/peps/pep-0693/#lifespan)) | October 2028 | April 30, 2029 |
19+
| 3.13 ([PEP 719](https://www.python.org/dev/peps/pep-0719/#lifespan)) | October 2029 | April 30, 2030 |
20+
| 3.14 ([PEP 745](https://www.python.org/dev/peps/pep-0745/#lifespan)) | October 2030 | April 30, 2031 |
21+
| 3.15 ([PEP 790](https://www.python.org/dev/peps/pep-0790/#lifespan)) | October 2031 | April 30, 2032 |

0 commit comments

Comments
 (0)