asyncer 0.0.7.dev1__tar.gz → 0.0.8__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. {asyncer-0.0.7.dev1 → asyncer-0.0.8}/PKG-INFO +13 -11
  2. {asyncer-0.0.7.dev1 → asyncer-0.0.8}/README.md +8 -8
  3. {asyncer-0.0.7.dev1 → asyncer-0.0.8}/asyncer/__init__.py +1 -1
  4. asyncer-0.0.8/asyncer/_compat.py +37 -0
  5. {asyncer-0.0.7.dev1 → asyncer-0.0.8}/asyncer/_main.py +20 -3
  6. {asyncer-0.0.7.dev1 → asyncer-0.0.8}/pyproject.toml +12 -3
  7. asyncer-0.0.8/requirements-docs-insiders.txt +3 -0
  8. {asyncer-0.0.7.dev1 → asyncer-0.0.8}/requirements-docs.txt +9 -8
  9. asyncer-0.0.8/requirements-github-actions.txt +4 -0
  10. {asyncer-0.0.7.dev1 → asyncer-0.0.8}/requirements-tests.txt +2 -2
  11. asyncer-0.0.8/scripts/deploy_docs_status.py +89 -0
  12. asyncer-0.0.8/scripts/docs.py +135 -0
  13. asyncer-0.0.8/scripts/mkdocs_hooks.py +38 -0
  14. {asyncer-0.0.7.dev1 → asyncer-0.0.8}/scripts/test.sh +1 -1
  15. asyncer-0.0.8/tests/test_param_cancellable.py +37 -0
  16. asyncer-0.0.7.dev1/scripts/docs-live.sh +0 -7
  17. asyncer-0.0.7.dev1/scripts/test-files.sh +0 -7
  18. {asyncer-0.0.7.dev1 → asyncer-0.0.8}/LICENSE +0 -0
  19. {asyncer-0.0.7.dev1 → asyncer-0.0.8}/asyncer/py.typed +0 -0
  20. {asyncer-0.0.7.dev1 → asyncer-0.0.8}/docs_src/__init__.py +0 -0
  21. {asyncer-0.0.7.dev1 → asyncer-0.0.8}/docs_src/tutorial/__init__.py +0 -0
  22. {asyncer-0.0.7.dev1 → asyncer-0.0.8}/docs_src/tutorial/asyncify/__init__.py +0 -0
  23. {asyncer-0.0.7.dev1 → asyncer-0.0.8}/docs_src/tutorial/asyncify/tutorial001.py +0 -0
  24. {asyncer-0.0.7.dev1 → asyncer-0.0.8}/docs_src/tutorial/asyncify/tutorial002.py +0 -0
  25. {asyncer-0.0.7.dev1 → asyncer-0.0.8}/docs_src/tutorial/first_steps/__init__.py +0 -0
  26. {asyncer-0.0.7.dev1 → asyncer-0.0.8}/docs_src/tutorial/first_steps/tutorial001.py +0 -0
  27. {asyncer-0.0.7.dev1 → asyncer-0.0.8}/docs_src/tutorial/runnify/__init__.py +0 -0
  28. {asyncer-0.0.7.dev1 → asyncer-0.0.8}/docs_src/tutorial/runnify/tutorial001.py +0 -0
  29. {asyncer-0.0.7.dev1 → asyncer-0.0.8}/docs_src/tutorial/soonify/__init__.py +0 -0
  30. {asyncer-0.0.7.dev1 → asyncer-0.0.8}/docs_src/tutorial/soonify/tutorial001.py +0 -0
  31. {asyncer-0.0.7.dev1 → asyncer-0.0.8}/docs_src/tutorial/soonify/tutorial002.py +0 -0
  32. {asyncer-0.0.7.dev1 → asyncer-0.0.8}/docs_src/tutorial/soonify_return/__init__.py +0 -0
  33. {asyncer-0.0.7.dev1 → asyncer-0.0.8}/docs_src/tutorial/soonify_return/tutorial001.py +0 -0
  34. {asyncer-0.0.7.dev1 → asyncer-0.0.8}/docs_src/tutorial/soonify_return/tutorial002.py +0 -0
  35. {asyncer-0.0.7.dev1 → asyncer-0.0.8}/docs_src/tutorial/soonify_return/tutorial003.py +0 -0
  36. {asyncer-0.0.7.dev1 → asyncer-0.0.8}/docs_src/tutorial/syncify/__init__.py +0 -0
  37. {asyncer-0.0.7.dev1 → asyncer-0.0.8}/docs_src/tutorial/syncify/tutorial001.py +0 -0
  38. {asyncer-0.0.7.dev1 → asyncer-0.0.8}/docs_src/tutorial/syncify_no_raise/__init__.py +0 -0
  39. {asyncer-0.0.7.dev1 → asyncer-0.0.8}/docs_src/tutorial/syncify_no_raise/tutorial001.py +0 -0
  40. {asyncer-0.0.7.dev1 → asyncer-0.0.8}/pdm_build.py +0 -0
  41. {asyncer-0.0.7.dev1 → asyncer-0.0.8}/requirements.txt +0 -0
  42. {asyncer-0.0.7.dev1 → asyncer-0.0.8}/scripts/format.sh +0 -0
  43. {asyncer-0.0.7.dev1 → asyncer-0.0.8}/scripts/lint.sh +0 -0
  44. {asyncer-0.0.7.dev1 → asyncer-0.0.8}/tests/__init__.py +0 -0
  45. {asyncer-0.0.7.dev1 → asyncer-0.0.8}/tests/conftest.py +0 -0
  46. {asyncer-0.0.7.dev1 → asyncer-0.0.8}/tests/test_others.py +0 -0
  47. {asyncer-0.0.7.dev1 → asyncer-0.0.8}/tests/test_syncify_no_raise.py +0 -0
  48. {asyncer-0.0.7.dev1 → asyncer-0.0.8}/tests/test_tutorial/__init__.py +0 -0
  49. {asyncer-0.0.7.dev1 → asyncer-0.0.8}/tests/test_tutorial/test_asyncify/__init__.py +0 -0
  50. {asyncer-0.0.7.dev1 → asyncer-0.0.8}/tests/test_tutorial/test_asyncify/test_tutorial001.py +0 -0
  51. {asyncer-0.0.7.dev1 → asyncer-0.0.8}/tests/test_tutorial/test_asyncify/test_tutorial002.py +0 -0
  52. {asyncer-0.0.7.dev1 → asyncer-0.0.8}/tests/test_tutorial/test_first_steps/__init__.py +0 -0
  53. {asyncer-0.0.7.dev1 → asyncer-0.0.8}/tests/test_tutorial/test_first_steps/test_tutorial001.py +0 -0
  54. {asyncer-0.0.7.dev1 → asyncer-0.0.8}/tests/test_tutorial/test_runnify/__init__.py +0 -0
  55. {asyncer-0.0.7.dev1 → asyncer-0.0.8}/tests/test_tutorial/test_runnify/test_tutorial001.py +0 -0
  56. {asyncer-0.0.7.dev1 → asyncer-0.0.8}/tests/test_tutorial/test_soonify/__init__.py +0 -0
  57. {asyncer-0.0.7.dev1 → asyncer-0.0.8}/tests/test_tutorial/test_soonify/test_tutorial001.py +0 -0
  58. {asyncer-0.0.7.dev1 → asyncer-0.0.8}/tests/test_tutorial/test_soonify/test_tutorial002.py +0 -0
  59. {asyncer-0.0.7.dev1 → asyncer-0.0.8}/tests/test_tutorial/test_soonify_return/__init__.py +0 -0
  60. {asyncer-0.0.7.dev1 → asyncer-0.0.8}/tests/test_tutorial/test_soonify_return/test_tutorial001.py +0 -0
  61. {asyncer-0.0.7.dev1 → asyncer-0.0.8}/tests/test_tutorial/test_soonify_return/test_tutorial002.py +0 -0
  62. {asyncer-0.0.7.dev1 → asyncer-0.0.8}/tests/test_tutorial/test_soonify_return/test_tutorial003.py +0 -0
  63. {asyncer-0.0.7.dev1 → asyncer-0.0.8}/tests/test_tutorial/test_syncify/__init__.py +0 -0
  64. {asyncer-0.0.7.dev1 → asyncer-0.0.8}/tests/test_tutorial/test_syncify/test_tutorial001.py +0 -0
  65. {asyncer-0.0.7.dev1 → asyncer-0.0.8}/tests/test_tutorial/test_syncify_no_raise/__init__.py +0 -0
  66. {asyncer-0.0.7.dev1 → asyncer-0.0.8}/tests/test_tutorial/test_syncify_no_raise/test_tutorial001.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: asyncer
3
- Version: 0.0.7.dev1
3
+ Version: 0.0.8
4
4
  Summary: Asyncer, async and await, focused on developer experience.
5
5
  Author-Email: =?utf-8?q?Sebasti=C3=A1n_Ram=C3=ADrez?= <tiangolo@gmail.com>
6
6
  Classifier: Development Status :: 4 - Beta
@@ -20,9 +20,11 @@ Classifier: Programming Language :: Python :: 3.11
20
20
  Classifier: Programming Language :: Python :: 3.12
21
21
  Classifier: Topic :: Internet
22
22
  Classifier: Typing :: Typed
23
- Project-URL: Homepage, https://github.com/tiangolo/asyncer
23
+ Project-URL: Homepage, https://github.com/fastapi/asyncer
24
24
  Project-URL: Documentation, https://asyncer.tiangolo.com
25
- Project-URL: Repository, https://github.com/tiangolo/asyncer
25
+ Project-URL: Repository, https://github.com/fastapi/asyncer
26
+ Project-URL: Issues, https://github.com/fastapi/asyncer/issues
27
+ Project-URL: Changelog, https://asyncer.tiangolo.com/release-notes/
26
28
  Requires-Python: >=3.8
27
29
  Requires-Dist: anyio<5.0,>=3.4.0
28
30
  Requires-Dist: typing_extensions>=4.8.0; python_version < "3.10"
@@ -35,14 +37,14 @@ Description-Content-Type: text/markdown
35
37
  <em>Asyncer, async and await, focused on developer experience.</em>
36
38
  </p>
37
39
  <p align="center">
38
- <a href="https://github.com/tiangolo/asyncer/actions?query=workflow%3ATest" target="_blank">
39
- <img src="https://github.com/tiangolo/asyncer/workflows/Test/badge.svg" alt="Test">
40
+ <a href="https://github.com/fastapi/asyncer/actions?query=workflow%3ATest" target="_blank">
41
+ <img src="https://github.com/fastapi/asyncer/workflows/Test/badge.svg" alt="Test">
40
42
  </a>
41
- <a href="https://github.com/tiangolo/asyncer/actions?query=workflow%3APublish" target="_blank">
42
- <img src="https://github.com/tiangolo/asyncer/workflows/Publish/badge.svg" alt="Publish">
43
+ <a href="https://github.com/fastapi/asyncer/actions?query=workflow%3APublish" target="_blank">
44
+ <img src="https://github.com/fastapi/asyncer/workflows/Publish/badge.svg" alt="Publish">
43
45
  </a>
44
- <a href="https://coverage-badge.samuelcolvin.workers.dev/redirect/tiangolo/asyncer" target="_blank">
45
- <img src="https://coverage-badge.samuelcolvin.workers.dev/tiangolo/asyncer.svg" alt="Coverage">
46
+ <a href="https://coverage-badge.samuelcolvin.workers.dev/redirect/fastapi/asyncer" target="_blank">
47
+ <img src="https://coverage-badge.samuelcolvin.workers.dev/fastapi/asyncer.svg" alt="Coverage">
46
48
  <a href="https://pypi.org/project/asyncer" target="_blank">
47
49
  <img src="https://img.shields.io/pypi/v/asyncer?color=%2334D058&label=pypi%20package" alt="Package version">
48
50
  </a>
@@ -52,7 +54,7 @@ Description-Content-Type: text/markdown
52
54
 
53
55
  **Documentation**: <a href="https://asyncer.tiangolo.com" target="_blank">https://asyncer.tiangolo.com</a>
54
56
 
55
- **Source Code**: <a href="https://github.com/tiangolo/asyncer" target="_blank">https://github.com/tiangolo/asyncer</a>
57
+ **Source Code**: <a href="https://github.com/fastapi/asyncer" target="_blank">https://github.com/fastapi/asyncer</a>
56
58
 
57
59
  ---
58
60
 
@@ -152,4 +154,4 @@ Everything in **Asyncer** is designed to get the best **developer experience** p
152
154
 
153
155
  ## License
154
156
 
155
- This project is licensed under the terms of the [MIT license](https://github.com/tiangolo/asyncer/blob/main/LICENSE).
157
+ This project is licensed under the terms of the [MIT license](https://github.com/fastapi/asyncer/blob/main/LICENSE).
@@ -5,14 +5,14 @@
5
5
  <em>Asyncer, async and await, focused on developer experience.</em>
6
6
  </p>
7
7
  <p align="center">
8
- <a href="https://github.com/tiangolo/asyncer/actions?query=workflow%3ATest" target="_blank">
9
- <img src="https://github.com/tiangolo/asyncer/workflows/Test/badge.svg" alt="Test">
8
+ <a href="https://github.com/fastapi/asyncer/actions?query=workflow%3ATest" target="_blank">
9
+ <img src="https://github.com/fastapi/asyncer/workflows/Test/badge.svg" alt="Test">
10
10
  </a>
11
- <a href="https://github.com/tiangolo/asyncer/actions?query=workflow%3APublish" target="_blank">
12
- <img src="https://github.com/tiangolo/asyncer/workflows/Publish/badge.svg" alt="Publish">
11
+ <a href="https://github.com/fastapi/asyncer/actions?query=workflow%3APublish" target="_blank">
12
+ <img src="https://github.com/fastapi/asyncer/workflows/Publish/badge.svg" alt="Publish">
13
13
  </a>
14
- <a href="https://coverage-badge.samuelcolvin.workers.dev/redirect/tiangolo/asyncer" target="_blank">
15
- <img src="https://coverage-badge.samuelcolvin.workers.dev/tiangolo/asyncer.svg" alt="Coverage">
14
+ <a href="https://coverage-badge.samuelcolvin.workers.dev/redirect/fastapi/asyncer" target="_blank">
15
+ <img src="https://coverage-badge.samuelcolvin.workers.dev/fastapi/asyncer.svg" alt="Coverage">
16
16
  <a href="https://pypi.org/project/asyncer" target="_blank">
17
17
  <img src="https://img.shields.io/pypi/v/asyncer?color=%2334D058&label=pypi%20package" alt="Package version">
18
18
  </a>
@@ -22,7 +22,7 @@
22
22
 
23
23
  **Documentation**: <a href="https://asyncer.tiangolo.com" target="_blank">https://asyncer.tiangolo.com</a>
24
24
 
25
- **Source Code**: <a href="https://github.com/tiangolo/asyncer" target="_blank">https://github.com/tiangolo/asyncer</a>
25
+ **Source Code**: <a href="https://github.com/fastapi/asyncer" target="_blank">https://github.com/fastapi/asyncer</a>
26
26
 
27
27
  ---
28
28
 
@@ -122,4 +122,4 @@ Everything in **Asyncer** is designed to get the best **developer experience** p
122
122
 
123
123
  ## License
124
124
 
125
- This project is licensed under the terms of the [MIT license](https://github.com/tiangolo/asyncer/blob/main/LICENSE).
125
+ This project is licensed under the terms of the [MIT license](https://github.com/fastapi/asyncer/blob/main/LICENSE).
@@ -1,4 +1,4 @@
1
- __version__ = "0.0.7.dev1"
1
+ __version__ = "0.0.8"
2
2
 
3
3
  from ._main import PendingValueException as PendingValueException
4
4
  from ._main import SoonValue as SoonValue
@@ -0,0 +1,37 @@
1
+ # AnyIO 4.1.0 renamed cancellable to abandon_on_cancel
2
+ import importlib
3
+ import importlib.metadata
4
+ from typing import Callable, TypeVar, Union
5
+
6
+ import anyio
7
+ import anyio.to_thread
8
+ from anyio import CapacityLimiter
9
+ from typing_extensions import TypeVarTuple, Unpack
10
+
11
+ ANYIO_VERSION = importlib.metadata.version("anyio")
12
+
13
+ T_Retval = TypeVar("T_Retval")
14
+ PosArgsT = TypeVarTuple("PosArgsT")
15
+
16
+ if ANYIO_VERSION >= "4.1.0":
17
+
18
+ async def run_sync(
19
+ func: Callable[[Unpack[PosArgsT]], T_Retval],
20
+ *args: Unpack[PosArgsT],
21
+ abandon_on_cancel: bool = False,
22
+ limiter: Union[CapacityLimiter, None] = None,
23
+ ) -> T_Retval:
24
+ return await anyio.to_thread.run_sync(
25
+ func, *args, abandon_on_cancel=abandon_on_cancel, limiter=limiter
26
+ )
27
+ else:
28
+
29
+ async def run_sync(
30
+ func: Callable[[Unpack[PosArgsT]], T_Retval],
31
+ *args: Unpack[PosArgsT],
32
+ abandon_on_cancel: bool = False,
33
+ limiter: Union[CapacityLimiter, None] = None,
34
+ ) -> T_Retval:
35
+ return await anyio.to_thread.run_sync(
36
+ func, *args, cancellable=abandon_on_cancel, limiter=limiter
37
+ )
@@ -12,6 +12,9 @@ from typing import (
12
12
  TypeVar,
13
13
  Union,
14
14
  )
15
+ from warnings import warn
16
+
17
+ from asyncer._compat import run_sync
15
18
 
16
19
  if sys.version_info >= (3, 10):
17
20
  from typing import ParamSpec
@@ -19,6 +22,8 @@ else:
19
22
  from typing_extensions import ParamSpec
20
23
 
21
24
  import anyio
25
+ import anyio.from_thread
26
+ import anyio.to_thread
22
27
  import sniffio
23
28
  from anyio._core._eventloop import threadlocals
24
29
  from anyio.abc import TaskGroup as _TaskGroup
@@ -317,7 +322,8 @@ def syncify(
317
322
  def asyncify(
318
323
  function: Callable[T_ParamSpec, T_Retval],
319
324
  *,
320
- cancellable: bool = False,
325
+ abandon_on_cancel: bool = False,
326
+ cancellable: Union[bool, None] = None,
321
327
  limiter: Optional[anyio.CapacityLimiter] = None,
322
328
  ) -> Callable[T_ParamSpec, Awaitable[T_Retval]]:
323
329
  """
@@ -357,13 +363,24 @@ def asyncify(
357
363
  original one, that when called runs the same original function in a thread worker
358
364
  and returns the result.
359
365
  """
366
+ if cancellable is not None:
367
+ abandon_on_cancel = cancellable
368
+ warn(
369
+ "The `cancellable=` keyword argument to `asyncer.asyncify()` is "
370
+ "deprecated since Asyncer 0.0.8, following AnyIO 4.1.0. "
371
+ "Use `abandon_on_cancel=` instead.",
372
+ DeprecationWarning,
373
+ stacklevel=2,
374
+ )
360
375
 
376
+ @functools.wraps(function)
361
377
  async def wrapper(
362
378
  *args: T_ParamSpec.args, **kwargs: T_ParamSpec.kwargs
363
379
  ) -> T_Retval:
364
380
  partial_f = functools.partial(function, *args, **kwargs)
365
- return await anyio.to_thread.run_sync(
366
- partial_f, cancellable=cancellable, limiter=limiter
381
+
382
+ return await run_sync(
383
+ partial_f, abandon_on_cancel=abandon_on_cancel, limiter=limiter
367
384
  )
368
385
 
369
386
  return wrapper
@@ -36,12 +36,14 @@ dependencies = [
36
36
  "anyio >=3.4.0,<5.0",
37
37
  "typing_extensions >=4.8.0; python_version < '3.10'",
38
38
  ]
39
- version = "0.0.7.dev1"
39
+ version = "0.0.8"
40
40
 
41
41
  [project.urls]
42
- Homepage = "https://github.com/tiangolo/asyncer"
42
+ Homepage = "https://github.com/fastapi/asyncer"
43
43
  Documentation = "https://asyncer.tiangolo.com"
44
- Repository = "https://github.com/tiangolo/asyncer"
44
+ Repository = "https://github.com/fastapi/asyncer"
45
+ Issues = "https://github.com/fastapi/asyncer/issues"
46
+ Changelog = "https://asyncer.tiangolo.com/release-notes/"
45
47
 
46
48
  [project.optional-dependencies]
47
49
 
@@ -67,18 +69,25 @@ name = "asyncer-slim"
67
69
 
68
70
  [tool.coverage.run]
69
71
  parallel = true
72
+ data_file = "coverage/.coverage"
70
73
  source = [
71
74
  "docs_src",
72
75
  "tests",
73
76
  "asyncer",
74
77
  ]
75
78
  context = "${CONTEXT}"
79
+ dynamic_context = "test_function"
76
80
 
77
81
  [tool.coverage.report]
82
+ show_missing = true
83
+ sort = "-Cover"
78
84
  omit = [
79
85
  "docs_src/tutorial/soonify_return/tutorial002.py",
80
86
  ]
81
87
 
88
+ [tool.coverage.html]
89
+ show_contexts = true
90
+
82
91
  [tool.mypy]
83
92
  strict = true
84
93
 
@@ -0,0 +1,3 @@
1
+ git+https://${TOKEN}@github.com/squidfunk/mkdocs-material-insiders.git@9.5.30-insiders-4.53.11
2
+ git+https://${TOKEN}@github.com/pawamoy-insiders/griffe-typing-deprecated.git
3
+ git+https://${TOKEN}@github.com/pawamoy-insiders/mkdocstrings-python.git
@@ -1,17 +1,18 @@
1
1
  -e .
2
2
 
3
- mkdocs-material==9.4.7
3
+ mkdocs-material==9.5.18
4
4
  mdx-include >=1.4.1,<2.0.0
5
- mkdocs-markdownextradata-plugin >=0.1.7,<0.3.0
6
5
  mkdocs-redirects>=1.2.1,<1.3.0
7
6
  pyyaml >=5.3.1,<7.0.0
8
7
  # For Material for MkDocs, Chinese search
9
- jieba==0.42.1
8
+ # jieba==0.42.1
10
9
  # For image processing by Material for MkDocs
11
- pillow==10.1.0
10
+ pillow==10.4.0
12
11
  # For image processing by Material for MkDocs
13
- cairosvg==2.7.0
14
- mkdocstrings[python]==0.23.0
15
- griffe-typingdoc==0.2.2
12
+ cairosvg==2.7.1
13
+ # mkdocstrings[python]==0.25.1
14
+ # Enable griffe-typingdoc once dropping Python 3.7 and upgrading typing-extensions
15
+ # griffe-typingdoc==0.2.5
16
16
  # For griffe, it formats with black
17
- black==23.3.0
17
+ typer == 0.12.3
18
+ mkdocs-macros-plugin==1.0.5
@@ -0,0 +1,4 @@
1
+ PyGithub>=2.3.0,<3.0.0
2
+ pydantic>=2.5.3,<3.0.0
3
+ pydantic-settings>=2.1.0,<3.0.0
4
+ httpx>=0.27.0,<0.28.0
@@ -2,5 +2,5 @@
2
2
 
3
3
  pytest >=7.0.1,<8.0.0
4
4
  coverage[toml] >=6.2,<8.0
5
- mypy ==1.4.1
6
- ruff ==0.2.0
5
+ mypy ==1.11.1
6
+ ruff ==0.6.2
@@ -0,0 +1,89 @@
1
+ import logging
2
+ import re
3
+
4
+ from github import Github
5
+ from pydantic import SecretStr
6
+ from pydantic_settings import BaseSettings
7
+
8
+
9
+ class Settings(BaseSettings):
10
+ github_repository: str
11
+ github_token: SecretStr
12
+ deploy_url: str | None = None
13
+ commit_sha: str
14
+ run_id: int
15
+ is_done: bool = False
16
+
17
+
18
+ def main():
19
+ logging.basicConfig(level=logging.INFO)
20
+ settings = Settings()
21
+
22
+ logging.info(f"Using config: {settings.model_dump_json()}")
23
+ g = Github(settings.github_token.get_secret_value())
24
+ repo = g.get_repo(settings.github_repository)
25
+ use_pr = next(
26
+ (pr for pr in repo.get_pulls() if pr.head.sha == settings.commit_sha), None
27
+ )
28
+ if not use_pr:
29
+ logging.error(f"No PR found for hash: {settings.commit_sha}")
30
+ return
31
+ commits = list(use_pr.get_commits())
32
+ current_commit = [c for c in commits if c.sha == settings.commit_sha][0]
33
+ run_url = f"https://github.com/{settings.github_repository}/actions/runs/{settings.run_id}"
34
+ if settings.is_done and not settings.deploy_url:
35
+ current_commit.create_status(
36
+ state="success",
37
+ description="No Docs Changes",
38
+ context="deploy-docs",
39
+ target_url=run_url,
40
+ )
41
+ logging.info("No docs changes found")
42
+ return
43
+ if not settings.deploy_url:
44
+ current_commit.create_status(
45
+ state="pending",
46
+ description="Deploying Docs",
47
+ context="deploy-docs",
48
+ target_url=run_url,
49
+ )
50
+ logging.info("No deploy URL available yet")
51
+ return
52
+ current_commit.create_status(
53
+ state="success",
54
+ description="Docs Deployed",
55
+ context="deploy-docs",
56
+ target_url=run_url,
57
+ )
58
+
59
+ files = list(use_pr.get_files())
60
+ docs_files = [f for f in files if f.filename.startswith("docs/")]
61
+
62
+ deploy_url = settings.deploy_url.rstrip("/")
63
+ links: list[str] = []
64
+ for f in docs_files:
65
+ match = re.match(r"docs/(.*)", f.filename)
66
+ assert match
67
+ path = match.group(1)
68
+ if path.endswith("index.md"):
69
+ path = path.replace("index.md", "")
70
+ else:
71
+ path = path.replace(".md", "/")
72
+ link = f"{deploy_url}/{path}"
73
+ links.append(link)
74
+ links.sort()
75
+
76
+ message = f"📝 Docs preview for commit {settings.commit_sha} at: {deploy_url}"
77
+
78
+ if links:
79
+ message += "\n\n### Modified Pages\n\n"
80
+ message += "\n".join([f"* {link}" for link in links])
81
+
82
+ print(message)
83
+ use_pr.as_issue().create_comment(message)
84
+
85
+ logging.info("Finished")
86
+
87
+
88
+ if __name__ == "__main__":
89
+ main()
@@ -0,0 +1,135 @@
1
+ import logging
2
+ import os
3
+ import re
4
+ import subprocess
5
+ from functools import lru_cache
6
+ from http.server import HTTPServer, SimpleHTTPRequestHandler
7
+ from importlib import metadata
8
+ from pathlib import Path
9
+
10
+ import typer
11
+
12
+ logging.basicConfig(level=logging.INFO)
13
+
14
+ mkdocs_name = "mkdocs.yml"
15
+ en_docs_path = Path("")
16
+
17
+ app = typer.Typer()
18
+
19
+
20
+ @lru_cache
21
+ def is_mkdocs_insiders() -> bool:
22
+ version = metadata.version("mkdocs-material")
23
+ return "insiders" in version
24
+
25
+
26
+ @app.callback()
27
+ def callback() -> None:
28
+ if is_mkdocs_insiders():
29
+ os.environ["INSIDERS_FILE"] = "./mkdocs.insiders.yml"
30
+ # For MacOS with insiders and Cairo
31
+ os.environ["DYLD_FALLBACK_LIBRARY_PATH"] = "/opt/homebrew/lib"
32
+
33
+
34
+ def generate_readme_content() -> str:
35
+ en_index = en_docs_path / "docs" / "index.md"
36
+ content = en_index.read_text("utf-8")
37
+ match_pre = re.search(r"</style>\n\n", content)
38
+ if not match_pre:
39
+ raise RuntimeError("Couldn't find pre section (<style>) in index.md")
40
+ frontmatter_end = match_pre.end()
41
+ new_content = content[frontmatter_end:]
42
+ # Remove content between <!-- only-mkdocs --> and <!-- /only-mkdocs -->
43
+ new_content = re.sub(
44
+ r"<!-- only-mkdocs -->.*?<!-- /only-mkdocs -->",
45
+ "",
46
+ new_content,
47
+ flags=re.DOTALL,
48
+ )
49
+ return new_content
50
+
51
+
52
+ @app.command()
53
+ def generate_readme() -> None:
54
+ """
55
+ Generate README.md content from main index.md
56
+ """
57
+ typer.echo("Generating README")
58
+ readme_path = Path("README.md")
59
+ new_content = generate_readme_content()
60
+ readme_path.write_text(new_content, encoding="utf-8")
61
+
62
+
63
+ @app.command()
64
+ def verify_readme() -> None:
65
+ """
66
+ Verify README.md content from main index.md
67
+ """
68
+ typer.echo("Verifying README")
69
+ readme_path = Path("README.md")
70
+ generated_content = generate_readme_content()
71
+ readme_content = readme_path.read_text("utf-8")
72
+ if generated_content != readme_content:
73
+ typer.secho(
74
+ "README.md outdated from the latest index.md", color=typer.colors.RED
75
+ )
76
+ raise typer.Abort()
77
+ typer.echo("Valid README ✅")
78
+
79
+
80
+ @app.command()
81
+ def live(dirty: bool = False) -> None:
82
+ """
83
+ Serve with livereload a docs site for a specific language.
84
+
85
+ This only shows the actual translated files, not the placeholders created with
86
+ build-all.
87
+
88
+ Takes an optional LANG argument with the name of the language to serve, by default
89
+ en.
90
+ """
91
+ # Enable line numbers during local development to make it easier to highlight
92
+ args = ["mkdocs", "serve", "--dev-addr", "127.0.0.1:8008"]
93
+ if dirty:
94
+ args.append("--dirty")
95
+ subprocess.run(args, env={**os.environ, "LINENUMS": "true"}, check=True)
96
+
97
+
98
+ @app.command()
99
+ def build() -> None:
100
+ """
101
+ Build the docs.
102
+ """
103
+ insiders_env_file = os.environ.get("INSIDERS_FILE")
104
+ print(f"Insiders file {insiders_env_file}")
105
+ if is_mkdocs_insiders():
106
+ print("Using insiders")
107
+ print("Building docs")
108
+ subprocess.run(["mkdocs", "build"], check=True)
109
+ typer.secho("Successfully built docs", color=typer.colors.GREEN)
110
+
111
+
112
+ @app.command()
113
+ def serve() -> None:
114
+ """
115
+ A quick server to preview a built site.
116
+
117
+ For development, prefer the command live (or just mkdocs serve).
118
+
119
+ This is here only to preview the documentation site.
120
+
121
+ Make sure you run the build command first.
122
+ """
123
+ typer.echo("Warning: this is a very simple server.")
124
+ typer.echo("For development, use the command live instead.")
125
+ typer.echo("This is here only to preview the documentation site.")
126
+ typer.echo("Make sure you run the build command first.")
127
+ os.chdir("site")
128
+ server_address = ("", 8008)
129
+ server = HTTPServer(server_address, SimpleHTTPRequestHandler)
130
+ typer.echo("Serving at: http://127.0.0.1:8008")
131
+ server.serve_forever()
132
+
133
+
134
+ if __name__ == "__main__":
135
+ app()
@@ -0,0 +1,38 @@
1
+ from typing import Any, List, Union
2
+
3
+ from mkdocs.config.defaults import MkDocsConfig
4
+ from mkdocs.structure.files import Files
5
+ from mkdocs.structure.nav import Link, Navigation, Section
6
+ from mkdocs.structure.pages import Page
7
+
8
+
9
+ def generate_renamed_section_items(
10
+ items: List[Union[Page, Section, Link]], *, config: MkDocsConfig
11
+ ) -> List[Union[Page, Section, Link]]:
12
+ new_items: List[Union[Page, Section, Link]] = []
13
+ for item in items:
14
+ if isinstance(item, Section):
15
+ new_title = item.title
16
+ new_children = generate_renamed_section_items(item.children, config=config)
17
+ first_child = new_children[0]
18
+ if isinstance(first_child, Page):
19
+ if first_child.file.src_path.endswith("index.md"):
20
+ # Read the source so that the title is parsed and available
21
+ first_child.read_source(config=config)
22
+ new_title = first_child.title or new_title
23
+ # Creating a new section makes it render it collapsed by default
24
+ # no idea why, so, let's just modify the existing one
25
+ # new_section = Section(title=new_title, children=new_children)
26
+ item.title = new_title
27
+ item.children = new_children
28
+ new_items.append(item)
29
+ else:
30
+ new_items.append(item)
31
+ return new_items
32
+
33
+
34
+ def on_nav(
35
+ nav: Navigation, *, config: MkDocsConfig, files: Files, **kwargs: Any
36
+ ) -> Navigation:
37
+ new_items = generate_renamed_section_items(nav.items, config=config)
38
+ return Navigation(items=new_items, pages=nav.pages)
@@ -5,5 +5,5 @@ set -x
5
5
 
6
6
  coverage run -m pytest tests
7
7
  coverage combine
8
- coverage report --show-missing
8
+ coverage report
9
9
  coverage html
@@ -0,0 +1,37 @@
1
+ import warnings
2
+
3
+ import anyio
4
+ import pytest
5
+ from asyncer import asyncify
6
+
7
+
8
+ def test_cancellable_warns():
9
+ def do_async_work():
10
+ return "Hello World!"
11
+
12
+ async def main():
13
+ result = await asyncify(do_async_work, cancellable=True)()
14
+ return result
15
+
16
+ with pytest.warns(DeprecationWarning) as record:
17
+ result = anyio.run(main)
18
+ assert isinstance(record[0].message, Warning)
19
+ assert (
20
+ "The `cancellable=` keyword argument to `asyncer.asyncify()` is "
21
+ "deprecated since Asyncer 0.0.8" in record[0].message.args[0]
22
+ )
23
+ assert result == "Hello World!"
24
+
25
+
26
+ def test_abandon_on_cancel_no():
27
+ def do_async_work():
28
+ return "Hello World!"
29
+
30
+ async def main():
31
+ result = await asyncify(do_async_work, abandon_on_cancel=True)()
32
+ return result
33
+
34
+ with warnings.catch_warnings():
35
+ warnings.simplefilter("error")
36
+ result = anyio.run(main)
37
+ assert result == "Hello World!"
@@ -1,7 +0,0 @@
1
- #!/usr/bin/env bash
2
-
3
- set -e
4
-
5
- export DYLD_FALLBACK_LIBRARY_PATH="/opt/homebrew/lib"
6
-
7
- mkdocs serve --config-file mkdocs.insiders.yml
@@ -1,7 +0,0 @@
1
- #!/usr/bin/env bash
2
-
3
- set -e
4
- set -x
5
-
6
- # Check README.md is up to date
7
- diff --brief docs/index.md README.md
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes