Skip to content

Commit 73d2a27

Browse files
authored
Merge branch 'main' into andystaples-fix-v1-show-history
2 parents e882381 + 9cad4de commit 73d2a27

7 files changed

Lines changed: 113 additions & 0 deletions

File tree

.github/workflows/typecheck.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,3 +53,6 @@ jobs:
5353
5454
- name: Run pyright (strict, Python 3.13)
5555
run: nox -s typecheck_functions
56+
57+
- name: Check packaged types (strict, Python 3.13)
58+
run: nox -s typecheck_functions_package

azure-functions-durable/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99

1010
ADDED
1111

12+
- Added PEP 561 type information so strict type checkers recognize
13+
`azure.durable_functions` as a typed package.
1214
- Added `azure.durable_functions.testing.execute_entity()` for unit testing
1315
function-style and class-based entities without a Functions host or Durable Task
1416
backend. The helper returns the operation result, resulting state, and typed

azure-functions-durable/azure/durable_functions/py.typed

Whitespace-only changes.

azure-functions-durable/pyproject.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,5 +39,8 @@ changelog = "https://github.com/microsoft/durabletask-python/blob/main/azure-fun
3939
[tool.setuptools.packages.find]
4040
include = ["azure.durable_functions", "azure.durable_functions.*"]
4141

42+
[tool.setuptools.package-data]
43+
"azure.durable_functions" = ["py.typed"]
44+
4245
[tool.pytest.ini_options]
4346
minversion = "6.0"

noxfile.py

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
1313
nox -s lint
1414
nox -s typecheck_core
15+
nox -s typecheck_functions_package
1516
nox -s core_tests-3.10
1617
nox -s azuremanaged_tests-3.10
1718
nox -s functions_unit-3.13
@@ -27,8 +28,10 @@
2728
import shutil
2829
import socket
2930
import subprocess
31+
import tarfile
3032
import time
3133
import uuid
34+
import zipfile
3235
from pathlib import Path
3336
from typing import Sequence
3437

@@ -323,6 +326,79 @@ def typecheck_functions(session: nox.Session) -> None:
323326
)
324327

325328

329+
@nox.session(python=["3.13"])
330+
def typecheck_functions_package(session: nox.Session) -> None:
331+
"""Check the installed Functions and core wheels with strict Pyright."""
332+
session.install("build", "pyright")
333+
temp_dir = Path(session.create_tmp())
334+
artifact_dir = temp_dir / "functions-dist"
335+
core_artifact_dir = temp_dir / "core-dist"
336+
if artifact_dir.exists():
337+
shutil.rmtree(artifact_dir)
338+
if core_artifact_dir.exists():
339+
shutil.rmtree(core_artifact_dir)
340+
session.run(
341+
"python",
342+
"-m",
343+
"build",
344+
"--outdir",
345+
str(artifact_dir),
346+
str(AZURE_FUNCTIONS_DURABLE),
347+
)
348+
session.run(
349+
"python",
350+
"-m",
351+
"build",
352+
"--wheel",
353+
"--outdir",
354+
str(core_artifact_dir),
355+
str(REPO_ROOT),
356+
)
357+
358+
wheels = list(artifact_dir.glob("azure_functions_durable-*.whl"))
359+
sdists = list(artifact_dir.glob("azure_functions_durable-*.tar.gz"))
360+
core_wheels = list(core_artifact_dir.glob("durabletask-*.whl"))
361+
if len(wheels) != 1 or len(sdists) != 1 or len(core_wheels) != 1:
362+
session.error(
363+
"Expected one provider wheel, provider source distribution, "
364+
"and core wheel")
365+
wheel = wheels[0]
366+
sdist = sdists[0]
367+
core_wheel = core_wheels[0]
368+
marker = "azure/durable_functions/py.typed"
369+
with zipfile.ZipFile(wheel) as archive:
370+
if marker not in archive.namelist():
371+
session.error(f"{marker} is missing from {wheel.name}")
372+
with tarfile.open(sdist, "r:gz") as archive:
373+
if not any(name.endswith(f"/{marker}") for name in archive.getnames()):
374+
session.error(f"{marker} is missing from {sdist.name}")
375+
376+
session.install(str(core_wheel), str(wheel))
377+
session.run(
378+
"python",
379+
"-m",
380+
"pip",
381+
"install",
382+
"--force-reinstall",
383+
"--no-deps",
384+
str(core_wheel),
385+
str(wheel),
386+
)
387+
python_path = session.run(
388+
"python",
389+
"-c",
390+
"import sys; print(sys.executable)",
391+
silent=True,
392+
).strip()
393+
session.run(
394+
"pyright",
395+
"--pythonpath",
396+
python_path,
397+
"-p",
398+
"tests/azure-functions-durable/typing/pyrightconfig.json",
399+
)
400+
401+
326402
@nox.session(python=PYTHON_VERSIONS)
327403
def core_tests(session: nox.Session) -> None:
328404
"""Run core SDK tests against an automatically started Blob Azurite."""
@@ -459,6 +535,7 @@ def ci(session: nox.Session) -> None:
459535
session.notify("lint", ())
460536
session.notify("typecheck_core", ())
461537
session.notify("typecheck_functions", ())
538+
session.notify("typecheck_functions_package", ())
462539
session.notify(f"core_tests-{python_version}", ())
463540
session.notify(f"azuremanaged_tests-{python_version}", ())
464541
session.notify("functions_unit-3.13", ())
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Copyright (c) Microsoft Corporation.
2+
# Licensed under the MIT License.
3+
4+
from datetime import timedelta
5+
6+
import azure.durable_functions as df
7+
8+
9+
def create_app() -> df.DFApp:
10+
return df.DFApp()
11+
12+
13+
def create_retry_policy() -> df.RetryPolicy:
14+
return df.RetryPolicy(
15+
first_retry_interval=timedelta(seconds=1),
16+
max_number_of_attempts=3,
17+
)
18+
19+
20+
def activity_is_complete(context: df.DurableOrchestrationContext) -> bool:
21+
return context.call_activity("activity").is_complete
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"include": [
3+
"import_package.py"
4+
],
5+
"pythonVersion": "3.13",
6+
"typeCheckingMode": "strict"
7+
}

0 commit comments

Comments
 (0)