pdoc 14.6.0__tar.gz → 14.7.0__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 (74) hide show
  1. {pdoc-14.6.0 → pdoc-14.7.0}/CHANGELOG.md +21 -0
  2. {pdoc-14.6.0/pdoc.egg-info → pdoc-14.7.0}/PKG-INFO +2 -1
  3. {pdoc-14.6.0 → pdoc-14.7.0}/pdoc/__init__.py +1 -1
  4. {pdoc-14.6.0 → pdoc-14.7.0}/pdoc/_compat.py +11 -0
  5. {pdoc-14.6.0 → pdoc-14.7.0}/pdoc/doc.py +31 -12
  6. {pdoc-14.6.0 → pdoc-14.7.0}/pdoc/doc_ast.py +8 -8
  7. {pdoc-14.6.0 → pdoc-14.7.0}/pdoc/doc_pyi.py +22 -6
  8. {pdoc-14.6.0 → pdoc-14.7.0}/pdoc/render_helpers.py +15 -6
  9. {pdoc-14.6.0 → pdoc-14.7.0}/pdoc/templates/default/module.html.jinja2 +2 -2
  10. {pdoc-14.6.0 → pdoc-14.7.0/pdoc.egg-info}/PKG-INFO +2 -1
  11. {pdoc-14.6.0 → pdoc-14.7.0}/pyproject.toml +1 -0
  12. {pdoc-14.6.0 → pdoc-14.7.0}/test/test_doc.py +8 -7
  13. {pdoc-14.6.0 → pdoc-14.7.0}/test/test_doc_types.py +6 -2
  14. {pdoc-14.6.0 → pdoc-14.7.0}/test/test_snapshot.py +7 -11
  15. {pdoc-14.6.0 → pdoc-14.7.0}/LICENSE +0 -0
  16. {pdoc-14.6.0 → pdoc-14.7.0}/MANIFEST.in +0 -0
  17. {pdoc-14.6.0 → pdoc-14.7.0}/README.md +0 -0
  18. {pdoc-14.6.0 → pdoc-14.7.0}/pdoc/__main__.py +0 -0
  19. {pdoc-14.6.0 → pdoc-14.7.0}/pdoc/doc_types.py +0 -0
  20. {pdoc-14.6.0 → pdoc-14.7.0}/pdoc/docstrings.py +0 -0
  21. {pdoc-14.6.0 → pdoc-14.7.0}/pdoc/extract.py +0 -0
  22. {pdoc-14.6.0 → pdoc-14.7.0}/pdoc/markdown2/LICENSE +0 -0
  23. {pdoc-14.6.0 → pdoc-14.7.0}/pdoc/markdown2/README.md +0 -0
  24. {pdoc-14.6.0 → pdoc-14.7.0}/pdoc/markdown2/__init__.py +0 -0
  25. {pdoc-14.6.0 → pdoc-14.7.0}/pdoc/py.typed +0 -0
  26. {pdoc-14.6.0 → pdoc-14.7.0}/pdoc/render.py +0 -0
  27. {pdoc-14.6.0 → pdoc-14.7.0}/pdoc/search.py +0 -0
  28. {pdoc-14.6.0 → pdoc-14.7.0}/pdoc/templates/README.md +0 -0
  29. {pdoc-14.6.0 → pdoc-14.7.0}/pdoc/templates/build-search-index.js +0 -0
  30. {pdoc-14.6.0 → pdoc-14.7.0}/pdoc/templates/content.css +0 -0
  31. {pdoc-14.6.0 → pdoc-14.7.0}/pdoc/templates/custom.css +0 -0
  32. {pdoc-14.6.0 → pdoc-14.7.0}/pdoc/templates/default/error.html.jinja2 +0 -0
  33. {pdoc-14.6.0 → pdoc-14.7.0}/pdoc/templates/default/frame.html.jinja2 +0 -0
  34. {pdoc-14.6.0 → pdoc-14.7.0}/pdoc/templates/default/index.html.jinja2 +0 -0
  35. {pdoc-14.6.0 → pdoc-14.7.0}/pdoc/templates/deprecated/README.md +0 -0
  36. {pdoc-14.6.0 → pdoc-14.7.0}/pdoc/templates/deprecated/bootstrap-reboot.min.css +0 -0
  37. {pdoc-14.6.0 → pdoc-14.7.0}/pdoc/templates/deprecated/box-arrow-in-left.svg +0 -0
  38. {pdoc-14.6.0 → pdoc-14.7.0}/pdoc/templates/deprecated/elasticlunr.min.js +0 -0
  39. {pdoc-14.6.0 → pdoc-14.7.0}/pdoc/templates/deprecated/favicon.svg +0 -0
  40. {pdoc-14.6.0 → pdoc-14.7.0}/pdoc/templates/deprecated/navtoggle.svg +0 -0
  41. {pdoc-14.6.0 → pdoc-14.7.0}/pdoc/templates/deprecated/pdoc-logo.svg +0 -0
  42. {pdoc-14.6.0 → pdoc-14.7.0}/pdoc/templates/deprecated/resources/favicon.svg +0 -0
  43. {pdoc-14.6.0 → pdoc-14.7.0}/pdoc/templates/layout.css +0 -0
  44. {pdoc-14.6.0 → pdoc-14.7.0}/pdoc/templates/livereload.html.jinja2 +0 -0
  45. {pdoc-14.6.0 → pdoc-14.7.0}/pdoc/templates/math.html.jinja2 +0 -0
  46. {pdoc-14.6.0 → pdoc-14.7.0}/pdoc/templates/mermaid.html.jinja2 +0 -0
  47. {pdoc-14.6.0 → pdoc-14.7.0}/pdoc/templates/resources/bootstrap-reboot.min.css +0 -0
  48. {pdoc-14.6.0 → pdoc-14.7.0}/pdoc/templates/resources/box-arrow-in-left.svg +0 -0
  49. {pdoc-14.6.0 → pdoc-14.7.0}/pdoc/templates/resources/elasticlunr.min.js +0 -0
  50. {pdoc-14.6.0 → pdoc-14.7.0}/pdoc/templates/resources/exclamation-triangle-fill.svg +0 -0
  51. {pdoc-14.6.0 → pdoc-14.7.0}/pdoc/templates/resources/info-circle-fill.svg +0 -0
  52. {pdoc-14.6.0 → pdoc-14.7.0}/pdoc/templates/resources/lightning-fill.svg +0 -0
  53. {pdoc-14.6.0 → pdoc-14.7.0}/pdoc/templates/resources/navtoggle.svg +0 -0
  54. {pdoc-14.6.0 → pdoc-14.7.0}/pdoc/templates/resources/pdoc-logo.svg +0 -0
  55. {pdoc-14.6.0 → pdoc-14.7.0}/pdoc/templates/search.html.jinja2 +0 -0
  56. {pdoc-14.6.0 → pdoc-14.7.0}/pdoc/templates/search.js.jinja2 +0 -0
  57. {pdoc-14.6.0 → pdoc-14.7.0}/pdoc/templates/syntax-highlighting.css +0 -0
  58. {pdoc-14.6.0 → pdoc-14.7.0}/pdoc/templates/theme.css +0 -0
  59. {pdoc-14.6.0 → pdoc-14.7.0}/pdoc/web.py +0 -0
  60. {pdoc-14.6.0 → pdoc-14.7.0}/pdoc.egg-info/SOURCES.txt +0 -0
  61. {pdoc-14.6.0 → pdoc-14.7.0}/pdoc.egg-info/dependency_links.txt +0 -0
  62. {pdoc-14.6.0 → pdoc-14.7.0}/pdoc.egg-info/entry_points.txt +0 -0
  63. {pdoc-14.6.0 → pdoc-14.7.0}/pdoc.egg-info/requires.txt +0 -0
  64. {pdoc-14.6.0 → pdoc-14.7.0}/pdoc.egg-info/top_level.txt +0 -0
  65. {pdoc-14.6.0 → pdoc-14.7.0}/setup.cfg +0 -0
  66. {pdoc-14.6.0 → pdoc-14.7.0}/test/test_doc_ast.py +0 -0
  67. {pdoc-14.6.0 → pdoc-14.7.0}/test/test_doc_pyi.py +0 -0
  68. {pdoc-14.6.0 → pdoc-14.7.0}/test/test_docstrings.py +0 -0
  69. {pdoc-14.6.0 → pdoc-14.7.0}/test/test_extract.py +0 -0
  70. {pdoc-14.6.0 → pdoc-14.7.0}/test/test_main.py +0 -0
  71. {pdoc-14.6.0 → pdoc-14.7.0}/test/test_render_helpers.py +0 -0
  72. {pdoc-14.6.0 → pdoc-14.7.0}/test/test_search.py +0 -0
  73. {pdoc-14.6.0 → pdoc-14.7.0}/test/test_smoke.py +0 -0
  74. {pdoc-14.6.0 → pdoc-14.7.0}/test/test_web.py +0 -0
@@ -4,6 +4,27 @@
4
4
 
5
5
  ## Unreleased: pdoc next
6
6
 
7
+
8
+ ## 11 September 2024: pdoc 14.7.0
9
+
10
+ - Do not shorten `current_module.func` to `func` in docstrings when linking.
11
+ This prevents logical errors in code examples with imports.
12
+ ([#740](https://github.com/mitmproxy/pdoc/pull/740), @mhils)
13
+ - Add support for Python 3.13.
14
+ ([#730](https://github.com/mitmproxy/pdoc/pull/730), @mhils)
15
+ - pdoc now strips `collections.abc.` from type annotations to make them more concise.
16
+ ([#736](https://github.com/mitmproxy/pdoc/pull/736), @mhils)
17
+
18
+ ## 2024-08-27: pdoc 14.6.1
19
+
20
+ - Fix a bug where entire modules would be excluded by `--no-include-undocumented`.
21
+ To exclude modules, see https://pdoc.dev/docs/pdoc.html#exclude-submodules-from-being-documented.
22
+ ([#728](https://github.com/mitmproxy/pdoc/pull/728), @mhils)
23
+ - Fix a bug where pdoc would crash when importing pyi files.
24
+ ([#732](https://github.com/mitmproxy/pdoc/pull/732), @mhils)
25
+ - Fix a bug where subclasses of TypedDict subclasses would not render correctly.
26
+ ([#729](https://github.com/mitmproxy/pdoc/pull/729), @mhils)
27
+
7
28
  ## 2024-07-24: pdoc 14.6.0
8
29
 
9
30
  - If `example.data.Data` is also exposed as `example.Data`, pdoc now links to `example.Data` in documentation.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pdoc
3
- Version: 14.6.0
3
+ Version: 14.7.0
4
4
  Summary: API Documentation for Python Projects
5
5
  Author-email: Maximilian Hils <pdoc@maximilianhils.com>
6
6
  License: MIT-0
@@ -21,6 +21,7 @@ Classifier: Programming Language :: Python :: 3.9
21
21
  Classifier: Programming Language :: Python :: 3.10
22
22
  Classifier: Programming Language :: Python :: 3.11
23
23
  Classifier: Programming Language :: Python :: 3.12
24
+ Classifier: Programming Language :: Python :: 3.13
24
25
  Classifier: Typing :: Typed
25
26
  Requires-Python: >=3.8
26
27
  Description-Content-Type: text/markdown
@@ -481,7 +481,7 @@ You can find an example in [`examples/library-usage`](https://github.com/mitmpro
481
481
  from __future__ import annotations
482
482
 
483
483
  __docformat__ = "markdown" # explicitly disable rST processing in the examples above.
484
- __version__ = "14.6.0" # this is read from setup.py
484
+ __version__ = "14.7.0" # this is read from setup.py
485
485
 
486
486
  from pathlib import Path
487
487
  from typing import overload
@@ -123,6 +123,16 @@ else: # pragma: no cover
123
123
  return ' | '.join(self.option_strings)
124
124
 
125
125
 
126
+ if sys.version_info >= (3, 10):
127
+ from typing import is_typeddict
128
+ else: # pragma: no cover
129
+ def is_typeddict(tp):
130
+ try:
131
+ return tp.__orig_bases__[-1].__name__ == "TypedDict"
132
+ except Exception:
133
+ return False
134
+
135
+
126
136
  __all__ = [
127
137
  "cache",
128
138
  "ast_unparse",
@@ -134,4 +144,5 @@ __all__ = [
134
144
  "removesuffix",
135
145
  "formatannotation",
136
146
  "BooleanOptionalAction",
147
+ "is_typeddict",
137
148
  ]
@@ -37,6 +37,7 @@ import types
37
37
  from typing import Any
38
38
  from typing import ClassVar
39
39
  from typing import Generic
40
+ from typing import TypedDict
40
41
  from typing import TypeVar
41
42
  from typing import Union
42
43
  from typing import get_origin
@@ -49,6 +50,7 @@ from pdoc._compat import TypeAlias
49
50
  from pdoc._compat import TypeAliasType
50
51
  from pdoc._compat import cache
51
52
  from pdoc._compat import formatannotation
53
+ from pdoc._compat import is_typeddict
52
54
  from pdoc.doc_types import GenericAlias
53
55
  from pdoc.doc_types import NonUserDefinedCallables
54
56
  from pdoc.doc_types import empty
@@ -655,14 +657,21 @@ class Class(Namespace[type]):
655
657
  @cached_property
656
658
  def _bases(self) -> tuple[type, ...]:
657
659
  orig_bases = _safe_getattr(self.obj, "__orig_bases__", ())
658
- old_python_typeddict_workaround = (
659
- sys.version_info < (3, 12)
660
- and orig_bases
661
- and _safe_getattr(orig_bases[-1], "__name__", None) == "TypedDict"
662
- )
663
- if old_python_typeddict_workaround: # pragma: no cover
664
- # TypedDicts on Python <3.12 have a botched __mro__. We need to fix it.
665
- return (self.obj, *orig_bases[:-1])
660
+
661
+ if is_typeddict(self.obj):
662
+ if sys.version_info < (3, 12): # pragma: no cover
663
+ # TypedDicts on Python <3.12 have a botched __mro__. We need to fix it.
664
+ return (self.obj, *orig_bases[:-1])
665
+ else:
666
+ # TypedDict on Python >=3.12 removes intermediate classes from __mro__,
667
+ # so we use orig_bases to recover the full mro.
668
+ while orig_bases and orig_bases[-1] is not TypedDict:
669
+ parent_bases = _safe_getattr(orig_bases[-1], "__orig_bases__", ())
670
+ if (
671
+ len(parent_bases) != 1 or parent_bases in orig_bases
672
+ ): # sanity check that things look right
673
+ break # pragma: no cover
674
+ orig_bases = (*orig_bases, parent_bases[0])
666
675
 
667
676
  # __mro__ and __orig_bases__ differ between Python versions and special cases like TypedDict/NamedTuple.
668
677
  # This here is a pragmatic approximation of what we want.
@@ -1123,9 +1132,11 @@ class Variable(Doc[None]):
1123
1132
  if self.default_value is empty:
1124
1133
  return ""
1125
1134
  if isinstance(self.default_value, TypeAliasType):
1126
- return formatannotation(self.default_value.__value__)
1135
+ formatted = formatannotation(self.default_value.__value__)
1136
+ return _remove_collections_abc(formatted)
1127
1137
  elif self.annotation == TypeAlias:
1128
- return formatannotation(self.default_value)
1138
+ formatted = formatannotation(self.default_value)
1139
+ return _remove_collections_abc(formatted)
1129
1140
 
1130
1141
  # This is not perfect, but a solid attempt at preventing accidental leakage of secrets.
1131
1142
  # If you have input on how to improve the heuristic, please send a pull request!
@@ -1157,7 +1168,8 @@ class Variable(Doc[None]):
1157
1168
  def annotation_str(self) -> str:
1158
1169
  """The variable's type annotation as a pretty-printed str."""
1159
1170
  if self.annotation is not empty:
1160
- return f": {formatannotation(self.annotation)}"
1171
+ formatted = formatannotation(self.annotation)
1172
+ return f": {_remove_collections_abc(formatted)}"
1161
1173
  else:
1162
1174
  return ""
1163
1175
 
@@ -1193,6 +1205,7 @@ class _PrettySignature(inspect.Signature):
1193
1205
  for param in self.parameters.values():
1194
1206
  formatted = str(param)
1195
1207
  formatted = _remove_memory_addresses(formatted)
1208
+ formatted = _remove_collections_abc(formatted)
1196
1209
 
1197
1210
  kind = param.kind
1198
1211
 
@@ -1229,7 +1242,8 @@ class _PrettySignature(inspect.Signature):
1229
1242
 
1230
1243
  def _return_annotation_str(self) -> str:
1231
1244
  if self.return_annotation is not empty:
1232
- return formatannotation(self.return_annotation)
1245
+ formatted = formatannotation(self.return_annotation)
1246
+ return _remove_collections_abc(formatted)
1233
1247
  else:
1234
1248
  return ""
1235
1249
 
@@ -1324,3 +1338,8 @@ _Enum_default_docstrings = tuple(
1324
1338
  def _remove_memory_addresses(x: str) -> str:
1325
1339
  """Remove memory addresses from repr() output"""
1326
1340
  return re.sub(r" at 0x[0-9a-fA-F]+(?=>)", "", x)
1341
+
1342
+
1343
+ def _remove_collections_abc(x: str) -> str:
1344
+ """Remove 'collections.abc' from type signatures."""
1345
+ return re.sub(r"(?!\.)\bcollections\.abc\.", "", x)
@@ -240,12 +240,11 @@ def _parse_class(source: str) -> ast.ClassDef:
240
240
  Returns an empty ast.ClassDef if source is empty.
241
241
  """
242
242
  tree = _parse(source)
243
- assert len(tree.body) <= 1
244
- if tree.body:
243
+ if tree.body and len(tree.body) == 1:
245
244
  t = tree.body[0]
246
- assert isinstance(t, ast.ClassDef)
247
- return t
248
- return ast.ClassDef(body=[], decorator_list=[])
245
+ if isinstance(t, ast.ClassDef):
246
+ return t
247
+ return ast.ClassDef(name="PdocStub", body=[], decorator_list=[]) # type: ignore
249
248
 
250
249
 
251
250
  @cache
@@ -256,8 +255,7 @@ def _parse_function(source: str) -> ast.FunctionDef | ast.AsyncFunctionDef:
256
255
  Returns an empty ast.FunctionDef if source is empty.
257
256
  """
258
257
  tree = _parse(source)
259
- assert len(tree.body) <= 1
260
- if tree.body:
258
+ if tree.body and len(tree.body) == 1:
261
259
  t = tree.body[0]
262
260
  if isinstance(t, (ast.FunctionDef, ast.AsyncFunctionDef)):
263
261
  return t
@@ -265,7 +263,9 @@ def _parse_function(source: str) -> ast.FunctionDef | ast.AsyncFunctionDef:
265
263
  # we have a lambda function,
266
264
  # to simplify the API return the ast.FunctionDef stub.
267
265
  pass
268
- return ast.FunctionDef(body=[], decorator_list=[])
266
+ return ast.FunctionDef(
267
+ name="pdoc_stub", args=ast.arguments(), body=[], decorator_list=[]
268
+ ) # type: ignore
269
269
 
270
270
 
271
271
  def _parse(
@@ -6,6 +6,7 @@ This makes it possible to add type hints for native modules such as modules writ
6
6
 
7
7
  from __future__ import annotations
8
8
 
9
+ import importlib.util
9
10
  from pathlib import Path
10
11
  import sys
11
12
  import traceback
@@ -45,13 +46,28 @@ def find_stub_file(module_name: str) -> Path | None:
45
46
 
46
47
 
47
48
  def _import_stub_file(module_name: str, stub_file: Path) -> types.ModuleType:
48
- """Import the type stub outside of the normal import machinery."""
49
- code = compile(stub_file.read_text(), str(stub_file), "exec")
50
- m = types.ModuleType(module_name)
51
- m.__file__ = str(stub_file)
52
- eval(code, m.__dict__, m.__dict__)
49
+ """
50
+ Import the type stub outside of the normal import machinery.
53
51
 
54
- return m
52
+ Note that currently, for objects imported by the stub file, the _original_ module
53
+ is used and not the corresponding stub file.
54
+ """
55
+ sys.path_hooks.append(
56
+ importlib.machinery.FileFinder.path_hook(
57
+ (importlib.machinery.SourceFileLoader, [".pyi"])
58
+ )
59
+ )
60
+ try:
61
+ loader = importlib.machinery.SourceFileLoader(module_name, str(stub_file))
62
+ spec = importlib.util.spec_from_file_location(
63
+ module_name, stub_file, loader=loader
64
+ )
65
+ assert spec is not None
66
+ m = importlib.util.module_from_spec(spec)
67
+ loader.exec_module(m)
68
+ return m
69
+ finally:
70
+ sys.path_hooks.pop()
55
71
 
56
72
 
57
73
  def _prepare_module(ns: doc.Namespace) -> None:
@@ -307,11 +307,17 @@ def module_candidates(identifier: str, current_module: str) -> Iterable[str]:
307
307
 
308
308
 
309
309
  @pass_context
310
- def linkify(context: Context, code: str, namespace: str = "") -> str:
310
+ def linkify(
311
+ context: Context, code: str, namespace: str = "", shorten: bool = True
312
+ ) -> str:
311
313
  """
312
314
  Link all identifiers in a block of text. Identifiers referencing unknown modules or modules that
313
315
  are not rendered at the moment will be ignored.
314
316
  A piece of text is considered to be an identifier if it either contains a `.` or is surrounded by `<code>` tags.
317
+
318
+ If `shorten` is True, replace identifiers with short forms where possible.
319
+ For example, replace "current_module.Foo" with "Foo". This is useful for annotations
320
+ (which are verbose), but undesired for docstrings (where we want to preserve intent).
315
321
  """
316
322
 
317
323
  def linkify_repl(m: re.Match):
@@ -381,12 +387,15 @@ def linkify(context: Context, code: str, namespace: str = "") -> str:
381
387
  and (target_object is doc.obj or target_object is None)
382
388
  and context["is_public"](doc).strip()
383
389
  ):
384
- if module == mod:
385
- url_text = qualname
390
+ if shorten:
391
+ if module == mod:
392
+ url_text = qualname
393
+ else:
394
+ url_text = doc.fullname
395
+ if plain_text.endswith("()"):
396
+ url_text += "()"
386
397
  else:
387
- url_text = doc.fullname
388
- if plain_text.endswith("()"):
389
- url_text += "()"
398
+ url_text = plain_text
390
399
  return f'<a href="{relative_link(context["module"].modulename, doc.modulename)}#{qualname}">{url_text}</a>'
391
400
 
392
401
  # No matches found.
@@ -209,7 +209,7 @@ See https://pdoc.dev/docs/pdoc/render_helpers.html#DefaultMacroExtension for an
209
209
  {% enddefaultmacro %}
210
210
  {% defaultmacro docstring(var) %}
211
211
  {% if var.docstring %}
212
- <div class="docstring">{{ var.docstring | replace("@public", "") | to_markdown | to_html | linkify(namespace=var.qualname) }}</div>
212
+ <div class="docstring">{{ var.docstring | replace("@public", "") | to_markdown | to_html | linkify(namespace=var.qualname, shorten=False) }}</div>
213
213
  {% endif %}
214
214
  {% enddefaultmacro %}
215
215
  {% defaultmacro nav_members(members) %}
@@ -244,7 +244,7 @@ See https://pdoc.dev/docs/pdoc/render_helpers.html#DefaultMacroExtension for an
244
244
  {% elif "@public" in doc.docstring %}
245
245
  {# show members explicitly marked as @public #}
246
246
  true
247
- {% elif not include_undocumented and not doc.docstring %}
247
+ {% elif not include_undocumented and not doc.docstring and doc.kind != "module" %}
248
248
  {# hide members that are undocumented if include_undocumented has been toggled off. #}
249
249
  {% elif doc.name == "__init__" and (doc.docstring or (doc.kind == "function" and doc.signature_without_self.parameters)) %}
250
250
  {# show constructors that have a docstring or at least one extra argument #}
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pdoc
3
- Version: 14.6.0
3
+ Version: 14.7.0
4
4
  Summary: API Documentation for Python Projects
5
5
  Author-email: Maximilian Hils <pdoc@maximilianhils.com>
6
6
  License: MIT-0
@@ -21,6 +21,7 @@ Classifier: Programming Language :: Python :: 3.9
21
21
  Classifier: Programming Language :: Python :: 3.10
22
22
  Classifier: Programming Language :: Python :: 3.11
23
23
  Classifier: Programming Language :: Python :: 3.12
24
+ Classifier: Programming Language :: Python :: 3.13
24
25
  Classifier: Typing :: Typed
25
26
  Requires-Python: >=3.8
26
27
  Description-Content-Type: text/markdown
@@ -28,6 +28,7 @@ classifiers = [
28
28
  "Programming Language :: Python :: 3.10",
29
29
  "Programming Language :: Python :: 3.11",
30
30
  "Programming Language :: Python :: 3.12",
31
+ "Programming Language :: Python :: 3.13",
31
32
  "Typing :: Typed",
32
33
  ]
33
34
 
@@ -1,7 +1,6 @@
1
1
  import builtins
2
2
  import dataclasses
3
3
  from pathlib import Path
4
- import sys
5
4
  import types
6
5
  from unittest.mock import patch
7
6
 
@@ -120,13 +119,15 @@ def test_builtin_source():
120
119
  assert m.source_lines is None
121
120
 
122
121
 
123
- @pytest.mark.skipif(sys.version_info < (3, 9), reason="3.9+ only")
124
122
  def test_raising_getdoc():
125
- class Foo:
126
- @classmethod
127
- @property
128
- def __doc__(self):
129
- raise RuntimeError
123
+ class FooMeta(type):
124
+ def __getattribute__(cls, name):
125
+ if name == "__doc__":
126
+ raise RuntimeError
127
+ return super().__getattribute__(name)
128
+
129
+ class Foo(metaclass=FooMeta):
130
+ pass
130
131
 
131
132
  x = Class(Foo.__module__, Foo.__qualname__, Foo, (Foo.__module__, Foo.__qualname__))
132
133
  with pytest.warns(UserWarning, match="inspect.getdoc(.+) raised an exception"):
@@ -50,7 +50,9 @@ def test_eval_fail_import_nonexistent(monkeypatch):
50
50
  lambda _: "import typing\nif typing.TYPE_CHECKING:\n\timport nonexistent_module",
51
51
  )
52
52
  a = types.ModuleType("a")
53
- with pytest.warns(UserWarning, match="No module named 'nonexistent_module'"):
53
+ with pytest.warns(
54
+ UserWarning, match="No module named 'nonexistent_module'|Import of xyz failed"
55
+ ):
54
56
  assert safe_eval_type("xyz", a.__dict__, None, a, "a") == "xyz"
55
57
 
56
58
 
@@ -79,5 +81,7 @@ def test_recurse(monkeypatch):
79
81
  monkeypatch.setitem(sys.modules, "a", a)
80
82
  monkeypatch.setitem(sys.modules, "b", b)
81
83
 
82
- with pytest.warns(UserWarning, match="Recursion error when importing a"):
84
+ with pytest.warns(
85
+ UserWarning, match="Recursion error when importing a|Import of xyz failed"
86
+ ):
83
87
  assert safe_eval_type("xyz", a.__dict__, None, a, "a") == "xyz"
@@ -96,8 +96,9 @@ class Snapshot:
96
96
 
97
97
  snapshots = [
98
98
  Snapshot("ast_parsing"),
99
+ Snapshot("collections_abc", min_version=(3, 9)),
99
100
  Snapshot("demo", min_version=(3, 9)),
100
- Snapshot("enums", min_version=(3, 12)),
101
+ Snapshot("enums", min_version=(3, 13)),
101
102
  Snapshot("flavors_google"),
102
103
  Snapshot("flavors_numpy"),
103
104
  Snapshot("flavors_rst"),
@@ -135,16 +136,10 @@ snapshots = [
135
136
  with_output_directory=True,
136
137
  ),
137
138
  Snapshot("misc"),
138
- Snapshot(
139
- "misc_py39",
140
- min_version=(3, 9),
141
- ),
139
+ Snapshot("misc_py39", min_version=(3, 9)),
142
140
  Snapshot("misc_py310", min_version=(3, 10)),
143
- Snapshot("misc_py311", min_version=(3, 11)),
144
- Snapshot(
145
- "misc_py312",
146
- min_version=(3, 12),
147
- ),
141
+ Snapshot("misc_py312", min_version=(3, 12)),
142
+ Snapshot("misc_py313", min_version=(3, 13)),
148
143
  Snapshot("math_demo", render_options={"math": True}),
149
144
  Snapshot("math_misc", render_options={"math": True}),
150
145
  Snapshot("mermaid_demo", render_options={"mermaid": True}, min_version=(3, 9)),
@@ -164,7 +159,8 @@ snapshots = [
164
159
  Snapshot("pyo3_sample_library", specs=["pdoc_pyo3_sample_library"]),
165
160
  Snapshot("top_level_reimports", ["top_level_reimports"]),
166
161
  Snapshot("type_checking_imports", ["type_checking_imports.main"]),
167
- Snapshot("type_stub", min_version=(3, 10)),
162
+ Snapshot("typed_dict", min_version=(3, 13)),
163
+ Snapshot("type_stubs", ["type_stubs"], min_version=(3, 10)),
168
164
  Snapshot(
169
165
  "visibility",
170
166
  render_options={
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes