Skip to content

Commit cbb8059

Browse files
Python: Drop 3.10 support and expand CI coverage through 3.14 (#14708)
### Motivation and Context <!-- Thank you for your contribution to the semantic-kernel repo! Please help reviewers and future users, providing the following information: 1. Why is this change required? 2. What problem does it solve? 3. What scenario does it contribute to? 4. If it fixes an open issue, please link to the issue here. --> Retire Python 3.10 support and its compatibility code. Align the SDK's supported versions, CI coverage, and developer setup with Python 3.11 through 3.14. Use Python 3.14 as the local development and integration-test default. This intentionally raises the minimum supported Python version from 3.10 to 3.11. Python 3.14 is the highest supported and tested version. Keep the existing minimum-only `requires-python = ">=3.11"` policy; do not add an installation upper bound. ### Description <!-- Describe your changes, the overall approach, the underlying design. These notes will help understanding how your code works. Thanks! --> - Require Python 3.11+, update package classifiers through Python 3.14, and remove Python 3.10-specific ONNX pins and lockfile branches while preserving upstream security updates and registry URLs. - Replace obsolete `Self` and `NotRequired` backports with standard-library imports. Remove the Python 3.10 `AnyType` shim, obsolete test skips, and the event-loop workaround. Apply Python 3.11 syntax upgrades, including built-in `TimeoutError` and `datetime.UTC`. Keep import guards still needed by Python 3.11. - Run Python 3.11–3.14 as required unit-test jobs across the existing OS/test-suite matrix: 22 jobs, preserving the Python 3.11/macOS exclusion. Move all six integration-test matrices to Python 3.14 and explicitly provision interpreters before uv. - Use uv 0.13 and per-environment `uv pip install` resolution in unit CI, integration CI, and local setup, including the development dependency group. Use `uv run --no-sync` for subsequent tools and VS Code tasks so the shared universal lock does not restore incompatible NumPy 1.x. MCP sample subprocesses also use `--no-sync`. - Add an AutoGen dependency marker excluding Python 3.14 and Windows/Python 3.13, including all-extras installs. Its NumPy <2 constraint forces old scientific and gRPC packages; NumPy 1.26.4 crashes during import on Windows/Python 3.13. Preserve AutoGen coverage on Python 3.11–3.12 and Linux/macOS Python 3.13. Local pytest collection and CI follow the same exclusion policy. - Keep all other extras and connector tests enabled across the supported matrix. Remove abandoned newer-version exclusions and native-build workarounds. Keep the separate Dapr suite and its dependencies. - Constrain `azure-ai-projects` to `>=1.0,<2.0`: SK's Azure AI agent implementation requires the classic APIs removed in Projects 2.x. Add a regression test that checks the actual installed client's agent, file, thread, and run operations without cloud calls. - Replace the unmaintained `nest-asyncio` dependency and imports with `nest-asyncio2>=1.7.4,<2`. The old patch breaks Python 3.14 task detection, causing OpenAI/sniffio, AnyIO/MCP, and notebook timeout failures. Update nested-loop MCP samples too. Add regression tests for nested template invocation, async-library detection, timeout handling, and restoration of the outer task context. - Disable matrix fail-fast so one failure does not cancel the remaining required jobs. Run pytest through Python with unbuffered output and faulthandler for native-crash diagnostics. - Fix typing reflection: do not recurse into Union origin classes when parsing function annotations, and read model annotations from the class when building schemas from instances. Add regression cases for optional dictionary annotations and inherited/optional model fields. - Default local development to Python 3.14. Update the Makefile interpreter installation list, VS Code choices, setup instructions, READMEs, and sample requirements. Document the CI dependency policy and runtime compatibility constraints. - Add regression coverage for `Any` return annotations in message and RPC handlers. **Validation** From `python/`, using an isolated stable Python 3.14.9 environment with `VIRTUAL_ENV`/`UV_PROJECT_ENVIRONMENT` pointing to its session-only directory: - `uv pip install --editable . --requirements pyproject.toml --all-extras --group dev --upgrade --prerelease=if-necessary-or-explicit` — passed; installed Azure Projects 1.0.0, nest-asyncio2 1.7.4, and the full supported extras/dev dependency set. - `uv run --no-sync pytest tests/unit --ignore=tests/unit/processes/dapr_runtime --disable-warnings -o addopts=-ra -q` — passed: 4,947 passed, 1 skipped, 5 xfailed. - `uv run --no-sync pytest tests/unit/prompt_template tests/unit/agents/azure_ai_agent --disable-warnings -o addopts=-ra -q` — passed before the stable-interpreter recheck: 328 tests. The full stable-interpreter run above includes these tests. From the repository root unless noted: - `cd python && .venv/bin/pytest tests/unit/prompt_template tests/unit/agents/azure_ai_agent --disable-warnings -o addopts=-ra -q` — passed on Python 3.11: 328 tests. - `python/.venv/bin/pre-commit run --all-files --config python/.pre-commit-config.yaml` — passed, including pyupgrade, Ruff, formatting, lockfile consistency, and Bandit. - `uv build --project python --out-dir "$BUILD_OUTPUT"` — passed, with `BUILD_OUTPUT` set to the session-only artifact directory; built the source distribution and wheel. uv reports the existing `if-necessary-or-explicit` deprecation warning. - `git diff --check` — passed. Also exercised the failing async paths on stable Python 3.14.9 after nested template rendering: an actual Azure OpenAI SDK request with an in-memory HTTP mock, stdio initialization/tool listing for both MCP sample servers, and execution of a Python 3.14 notebook cell using `asyncio.timeout`. All passed without cloud calls. The old nest-asyncio failure was independently reproduced without external services. Verified the support matrix, metadata, AutoGen marker/collection policy on all 12 OS/Python combinations, all six integration installers/runners, and preservation of existing locked package versions and registry/artifact URLs. Windows and Linux Python 3.14 installation resolution checks select NumPy/SciPy wheels without AutoGen. Previously verified rejection of Python 3.10 during wheel installation. Live service integration tests were not run locally. Regular PR checks skip those jobs for fork PRs; the merge queue must run them to establish the latest commit's live-service results. The latest fixes do not skip additional integration tests. ### Contribution Checklist <!-- Before submitting this PR, please make sure: --> - [ ] The code builds clean without any errors or warnings - [ ] The PR follows the [SK Contribution Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md) and the [pre-submission formatting script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts) raises no violations - [ ] All unit tests pass, and I have added new tests where possible - [ ] I didn't break anyone 😄
1 parent 9137b35 commit cbb8059

66 files changed

Lines changed: 408 additions & 1909 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.github/workflows/python-build.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
runs-on: ubuntu-latest
1616
environment: "integration"
1717
env:
18-
UV_PYTHON: "3.10"
18+
UV_PYTHON: "3.11"
1919
steps:
2020
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
2121
- name: Set up uv

‎.github/workflows/python-integration-tests.yml‎

Lines changed: 61 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ jobs:
5555
max-parallel: 1
5656
fail-fast: false
5757
matrix:
58-
python-version: ["3.11"]
58+
python-version: ["3.14"]
5959
os: [ubuntu-latest]
6060
defaults:
6161
run:
@@ -67,16 +67,21 @@ jobs:
6767
COMPLETIONS_CONCEPT_SAMPLE: "true"
6868
steps:
6969
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
70+
- name: Set up Python
71+
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
72+
with:
73+
python-version: ${{ matrix.python-version }}
7074
- name: Set up uv
7175
uses: astral-sh/setup-uv@d0cc045d04ccac9d8b7881df0226f9e82c39688e # v6.8.0
7276
with:
73-
version: "0.5.x"
77+
version: "0.13.x"
7478
enable-cache: true
7579
cache-suffix: ${{ runner.os }}-${{ matrix.python-version }}
7680
cache-dependency-glob: "**/uv.lock"
7781
- name: Install dependencies
7882
run: |
79-
uv sync --all-extras --dev
83+
uv venv
84+
uv pip install --editable . --requirements pyproject.toml --all-extras --group dev --upgrade --prerelease=if-necessary-or-explicit
8085
- name: Google auth
8186
uses: google-github-actions/auth@7c6bc770dae815cd3e89ee6cdf493a5fab2cc093 # v3.0.0
8287
with:
@@ -158,7 +163,7 @@ jobs:
158163
BEDROCK_AGENT_FOUNDATION_MODEL: ${{ vars.BEDROCK_AGENT_FOUNDATION_MODEL }}
159164
shell: bash
160165
run: |
161-
uv run pytest -v --log-cli-level=INFO --durations=20 -n logical --dist loadfile --dist worksteal -m "not ollama" -k "not bedrock" ./tests/integration/completions ./tests/integration/embeddings ./tests/samples ./tests/integration/cross_language
166+
uv run --no-sync pytest -v --log-cli-level=INFO --durations=20 -n logical --dist loadfile --dist worksteal -m "not ollama" -k "not bedrock" ./tests/integration/completions ./tests/integration/embeddings ./tests/samples ./tests/integration/cross_language
162167
163168
python-merge-gate-multi-modality:
164169
name: Python Pre-Merge Integration Tests - Multi-Modality
@@ -171,7 +176,7 @@ jobs:
171176
max-parallel: 1
172177
fail-fast: false
173178
matrix:
174-
python-version: ["3.11"]
179+
python-version: ["3.14"]
175180
os: [ubuntu-latest]
176181
defaults:
177182
run:
@@ -182,15 +187,20 @@ jobs:
182187
UV_PYTHON: ${{ matrix.python-version }}
183188
steps:
184189
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
190+
- name: Set up Python
191+
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
192+
with:
193+
python-version: ${{ matrix.python-version }}
185194
- name: Set up uv
186195
uses: astral-sh/setup-uv@d0cc045d04ccac9d8b7881df0226f9e82c39688e # v6.8.0
187196
with:
188-
version: "0.5.x"
197+
version: "0.13.x"
189198
enable-cache: true
190199
cache-suffix: ${{ runner.os }}-${{ matrix.python-version }}
191200
- name: Install dependencies
192201
run: |
193-
uv sync --all-extras --dev
202+
uv venv
203+
uv pip install --editable . --requirements pyproject.toml --all-extras --group dev --upgrade --prerelease=if-necessary-or-explicit
194204
- name: Azure CLI Login
195205
uses: azure/login@7184910d9eb2b1c5e48f7073824a90609bb9b6d6 # v2.3.1
196206
with:
@@ -202,7 +212,7 @@ jobs:
202212
env: *integration-env
203213
shell: bash
204214
run: |
205-
uv run pytest -v --log-cli-level=INFO --durations=20 -n logical --dist loadfile --dist worksteal ./tests/integration/audio_to_text ./tests/integration/text_to_audio ./tests/integration/text_to_image
215+
uv run --no-sync pytest -v --log-cli-level=INFO --durations=20 -n logical --dist loadfile --dist worksteal ./tests/integration/audio_to_text ./tests/integration/text_to_audio ./tests/integration/text_to_image
206216
207217
python-merge-gate-agents:
208218
name: Python Pre-Merge Integration Tests - Agents
@@ -215,7 +225,7 @@ jobs:
215225
max-parallel: 1
216226
fail-fast: false
217227
matrix:
218-
python-version: ["3.11"]
228+
python-version: ["3.14"]
219229
os: [ubuntu-latest]
220230
defaults:
221231
run:
@@ -226,15 +236,20 @@ jobs:
226236
UV_PYTHON: ${{ matrix.python-version }}
227237
steps:
228238
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
239+
- name: Set up Python
240+
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
241+
with:
242+
python-version: ${{ matrix.python-version }}
229243
- name: Set up uv
230244
uses: astral-sh/setup-uv@d0cc045d04ccac9d8b7881df0226f9e82c39688e # v6.8.0
231245
with:
232-
version: "0.5.x"
246+
version: "0.13.x"
233247
enable-cache: true
234248
cache-suffix: ${{ runner.os }}-${{ matrix.python-version }}
235249
- name: Install dependencies
236250
run: |
237-
uv sync --all-extras --dev
251+
uv venv
252+
uv pip install --editable . --requirements pyproject.toml --all-extras --group dev --upgrade --prerelease=if-necessary-or-explicit
238253
- name: Configure AWS Credentials
239254
# Bedrock tests are disabled while the integration credentials are invalid.
240255
if: false
@@ -254,7 +269,7 @@ jobs:
254269
env: *integration-env
255270
shell: bash
256271
run: |
257-
uv run pytest -v --log-cli-level=INFO --durations=20 -n logical --dist loadfile --dist worksteal -k "not bedrock" ./tests/integration/agents
272+
uv run --no-sync pytest -v --log-cli-level=INFO --durations=20 -n logical --dist loadfile --dist worksteal -k "not bedrock" ./tests/integration/agents
258273
259274
python-merge-gate-ollama:
260275
name: Python Pre-Merge Integration Tests - Ollama
@@ -265,7 +280,7 @@ jobs:
265280
max-parallel: 1
266281
fail-fast: false
267282
matrix:
268-
python-version: ["3.11"]
283+
python-version: ["3.14"]
269284
os: [ubuntu-latest]
270285
defaults:
271286
run:
@@ -277,16 +292,21 @@ jobs:
277292
COMPLETIONS_CONCEPT_SAMPLE: "true"
278293
steps:
279294
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
295+
- name: Set up Python
296+
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
297+
with:
298+
python-version: ${{ matrix.python-version }}
280299
- name: Set up uv
281300
uses: astral-sh/setup-uv@d0cc045d04ccac9d8b7881df0226f9e82c39688e # v6.8.0
282301
with:
283-
version: "0.5.x"
302+
version: "0.13.x"
284303
enable-cache: true
285304
cache-suffix: ${{ runner.os }}-${{ matrix.python-version }}
286305
cache-dependency-glob: "**/uv.lock"
287306
- name: Install dependencies
288307
run: |
289-
uv sync --all-extras --dev
308+
uv venv
309+
uv pip install --editable . --requirements pyproject.toml --all-extras --group dev --upgrade --prerelease=if-necessary-or-explicit
290310
- name: Install Ollama
291311
if: matrix.os == 'ubuntu-latest'
292312
run: |
@@ -307,7 +327,7 @@ jobs:
307327
shell: bash
308328
env: *integration-env
309329
run: |
310-
uv run pytest -v --log-cli-level=INFO --durations=0 -n logical --dist loadfile --dist worksteal -m ollama --timeout=300 ./tests/integration/completions ./tests/integration/embeddings
330+
uv run --no-sync pytest -v --log-cli-level=INFO --durations=0 -n logical --dist loadfile --dist worksteal -m ollama --timeout=300 ./tests/integration/completions ./tests/integration/embeddings
311331
312332
python-merge-gate-memory:
313333
name: Python Pre-Merge Integration Tests - Memory (incl samples using those)
@@ -320,7 +340,7 @@ jobs:
320340
max-parallel: 1
321341
fail-fast: false
322342
matrix:
323-
python-version: ["3.11"]
343+
python-version: ["3.14"]
324344
os: [ubuntu-latest]
325345
defaults:
326346
run:
@@ -346,16 +366,21 @@ jobs:
346366
- 50051:50051
347367
steps:
348368
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
369+
- name: Set up Python
370+
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
371+
with:
372+
python-version: ${{ matrix.python-version }}
349373
- name: Set up uv
350374
uses: astral-sh/setup-uv@d0cc045d04ccac9d8b7881df0226f9e82c39688e # v6.8.0
351375
with:
352-
version: "0.5.x"
376+
version: "0.13.x"
353377
enable-cache: true
354378
cache-suffix: ${{ runner.os }}-${{ matrix.python-version }}
355379
cache-dependency-glob: "**/uv.lock"
356380
- name: Install dependencies
357381
run: |
358-
uv sync --all-extras --dev
382+
uv venv
383+
uv pip install --editable . --requirements pyproject.toml --all-extras --group dev --upgrade --prerelease=if-necessary-or-explicit
359384
- name: Azure CLI Login
360385
uses: azure/login@7184910d9eb2b1c5e48f7073824a90609bb9b6d6 # v2.3.1
361386
with:
@@ -368,7 +393,7 @@ jobs:
368393
timeout-minutes: 15
369394
shell: bash
370395
run: |
371-
uv run pytest -v --log-cli-level=INFO --durations=20 -n logical --dist loadfile --dist worksteal ./tests/integration/memory ./tests/samples
396+
uv run --no-sync pytest -v --log-cli-level=INFO --durations=20 -n logical --dist loadfile --dist worksteal ./tests/integration/memory ./tests/samples
372397
373398
python-integration-tests:
374399
name: Python Integration Tests - Scheduled run
@@ -381,7 +406,7 @@ jobs:
381406
max-parallel: 1
382407
fail-fast: false
383408
matrix:
384-
python-version: ["3.10", "3.11", "3.12"]
409+
python-version: ["3.14"]
385410
os: [ubuntu-latest, windows-latest, macos-latest]
386411
defaults:
387412
run:
@@ -407,16 +432,21 @@ jobs:
407432
- 50051:50051
408433
steps:
409434
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
435+
- name: Set up Python
436+
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
437+
with:
438+
python-version: ${{ matrix.python-version }}
410439
- name: Set up uv
411440
uses: astral-sh/setup-uv@d0cc045d04ccac9d8b7881df0226f9e82c39688e # v6.8.0
412441
with:
413-
version: "0.5.x"
442+
version: "0.13.x"
414443
enable-cache: true
415444
cache-suffix: ${{ runner.os }}-${{ matrix.python-version }}
416445
cache-dependency-glob: "**/uv.lock"
417446
- name: Install dependencies
418447
run: |
419-
uv sync --all-extras --dev
448+
uv venv
449+
uv pip install --editable . --requirements pyproject.toml --all-extras --group dev --upgrade --prerelease=if-necessary-or-explicit
420450
- name: Install Ollama
421451
if: matrix.os == 'ubuntu-latest'
422452
run: |
@@ -467,57 +497,57 @@ jobs:
467497
shell: bash
468498
# Ollama tests are very unstable at the moment. It often fails to pull models from the Ollama server. Thus, Ollama is disabled for now.
469499
run: |
470-
uv run pytest -v -n logical --dist loadfile --dist worksteal -m "not ollama" -k "not bedrock" ./tests/integration/completions
500+
uv run --no-sync pytest -v -n logical --dist loadfile --dist worksteal -m "not ollama" -k "not bedrock" ./tests/integration/completions
471501
- name: Run Integration Tests - Embeddings
472502
id: run_tests_embeddings
473503
env: *integration-env
474504
timeout-minutes: 5
475505
shell: bash
476506
# Ollama tests are very unstable at the moment. It often fails to pull models from the Ollama server. Thus, Ollama is disabled for now.
477507
run: |
478-
uv run pytest -v -n logical --dist loadfile --dist worksteal -m "not ollama" -k "not bedrock" ./tests/integration/embeddings
508+
uv run --no-sync pytest -v -n logical --dist loadfile --dist worksteal -m "not ollama" -k "not bedrock" ./tests/integration/embeddings
479509
- name: Run Integration Tests - Memory
480510
id: run_tests_memory
481511
timeout-minutes: 5
482512
env: *integration-env
483513
shell: bash
484514
run: |
485-
uv run pytest -v -n logical --dist loadfile --dist worksteal ./tests/integration/memory
515+
uv run --no-sync pytest -v -n logical --dist loadfile --dist worksteal ./tests/integration/memory
486516
- name: Run Integration Tests - Cross Language
487517
id: run_tests_cross_language
488518
env: *integration-env
489519
timeout-minutes: 5
490520
shell: bash
491521
run: |
492-
uv run pytest -v -n logical --dist loadfile --dist worksteal ./tests/integration/cross_language
522+
uv run --no-sync pytest -v -n logical --dist loadfile --dist worksteal ./tests/integration/cross_language
493523
- name: Run Integration Tests - Planning
494524
id: run_tests_planning
495525
env: *integration-env
496526
timeout-minutes: 5
497527
shell: bash
498528
run: |
499-
uv run pytest -v -n logical --dist loadfile --dist worksteal ./tests/integration/planning
529+
uv run --no-sync pytest -v -n logical --dist loadfile --dist worksteal ./tests/integration/planning
500530
- name: Run Integration Tests - Samples
501531
id: run_tests_samples
502532
env: *integration-env
503533
timeout-minutes: 5
504534
shell: bash
505535
run: |
506-
uv run pytest -v -n logical --dist loadfile --dist worksteal ./tests/samples
536+
uv run --no-sync pytest -v -n logical --dist loadfile --dist worksteal ./tests/samples
507537
- name: Run Integration Tests - Agents
508538
id: run_tests_agents
509539
timeout-minutes: 10
510540
env: *integration-env
511541
shell: bash
512542
run: |
513-
uv run pytest -v -n logical --dist loadfile --dist worksteal -k "not bedrock" ./tests/integration/agents
543+
uv run --no-sync pytest -v -n logical --dist loadfile --dist worksteal -k "not bedrock" ./tests/integration/agents
514544
- name: Run Integration Tests - Multi-Modality
515545
id: run_tests_multi_modality
516546
timeout-minutes: 5
517547
env: *integration-env
518548
shell: bash
519549
run: |
520-
uv run pytest -v -n logical --dist loadfile --dist worksteal ./tests/integration/audio_to_text ./tests/integration/text_to_audio ./tests/integration/text_to_image
550+
uv run --no-sync pytest -v -n logical --dist loadfile --dist worksteal ./tests/integration/audio_to_text ./tests/integration/text_to_audio ./tests/integration/text_to_image
521551
522552
# This final job is required to satisfy the merge queue. It must only run (or succeed) if no tests failed
523553
python-integration-tests-check:

‎.github/workflows/python-lint.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
strategy:
1313
fail-fast: false
1414
matrix:
15-
python-version: ["3.10"]
15+
python-version: ["3.11"]
1616
runs-on: ubuntu-latest
1717
continue-on-error: true
1818
defaults:

‎.github/workflows/python-test-coverage.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
run:
1919
working-directory: python
2020
env:
21-
UV_PYTHON: "3.10"
21+
UV_PYTHON: "3.11"
2222
steps:
2323
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
2424
- name: Set up uv

0 commit comments

Comments
 (0)