Skip to content

Commit 6956f53

Browse files
Merge branch 'master' into fix/napoleon-section-ordering
2 parents f97e19f + b062fa9 commit 6956f53

File tree

8 files changed

+43
-19
lines changed

8 files changed

+43
-19
lines changed

CHANGES.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,14 @@ Bugs fixed
2222

2323
* #14189: autodoc: Fix duplicate ``:no-index-entry:`` for modules.
2424
Patch by Adam Turner
25+
* #13713: Fix compatibility with MyST-Parser.
26+
Patch by Adam Turner
27+
* Fix tests for Python 3.15.
28+
Patch by Adam Turner
29+
* #14089: autodoc: Fix default option parsing.
30+
Patch by Adam Turner
31+
* Remove incorrect static typing assertions.
32+
Patch by Adam Turner
2533

2634
Testing
2735
-------

sphinx/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
if TYPE_CHECKING:
1212
from typing import Final
1313

14-
__version__: Final = '9.1.0'
14+
__version__: Final = '9.1.0rc1'
1515
__display_version__: Final = __version__ # used for command line version
1616

1717
#: Version info for better programmatic use.
@@ -22,12 +22,12 @@
2222
#:
2323
#: .. versionadded:: 1.2
2424
#: Before version 1.2, check the string ``sphinx.__version__``.
25-
version_info: Final = (9, 1, 0, 'beta', 1)
25+
version_info: Final = (9, 1, 0, 'candidate', 1)
2626

2727
package_dir: Final = _StrPath(__file__).resolve().parent
2828
del _StrPath
2929

30-
_in_development = True
30+
_in_development = False
3131
if _in_development:
3232
# Only import subprocess if needed
3333
import subprocess

sphinx/directives/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ def run(self) -> list[Node]:
215215
# note_source uses 0-based line numbers.
216216
if line is not None:
217217
line -= 1
218-
self.state.document.note_source(source, line)
218+
self.state.document.note_source(source, line) # type: ignore[arg-type]
219219
node['domain'] = self.domain
220220
# 'desctype' is a backwards compatible attribute
221221
node['objtype'] = node['desctype'] = self.objtype

sphinx/ext/autodoc/_directive_options.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,6 @@ def merge_members_option(options: dict[str, Any]) -> None:
275275
'private-members': members_option,
276276
'special-members': members_option,
277277
'member-order': member_order_option,
278-
'show-inheritance': bool_option,
279278
}
280279
_OPTION_SPEC_MODULE_SPECIFIC: Final[OptionSpec] = {
281280
'ignore-module-all': bool_option,
@@ -286,6 +285,7 @@ def merge_members_option(options: dict[str, Any]) -> None:
286285
}
287286
_OPTION_SPEC_CLASS_SPECIFIC: Final[OptionSpec] = {
288287
'class-doc-from': class_doc_from_option,
288+
'show-inheritance': bool_option,
289289
'inherited-members': inherited_members_option,
290290
}
291291
_OPTION_SPEC_ASSIGNMENT: Final[OptionSpec] = _OPTION_SPEC_COMMON | {
@@ -299,7 +299,9 @@ def merge_members_option(options: dict[str, Any]) -> None:
299299
_OPTION_SPECS: Final[Mapping[_AutodocObjType, OptionSpec]] = {
300300
'module': _OPTION_SPEC_HAS_MEMBERS
301301
| _OPTION_SPEC_MODULE_SPECIFIC
302+
| {'show-inheritance': bool_option} # special case
302303
| {'inherited-members': inherited_members_option} # special case
304+
| {'no-value': bool_option} # special case
303305
| _OPTION_SPEC_DEPRECATED,
304306
'class': _OPTION_SPEC_HAS_MEMBERS
305307
| _OPTION_SPEC_CLASS_SPECIFIC

sphinx/ext/autodoc/directive.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def __init__(
7171
env: BuildEnvironment,
7272
reporter: Reporter | None,
7373
options: Options,
74-
lineno: int,
74+
lineno: int | None,
7575
state: Any,
7676
) -> None:
7777
self.env = env

sphinx/io.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
warnings.warn('sphinx.io is deprecated', RemovedInSphinx10Warning, stacklevel=2)
3333

3434

35-
class SphinxBaseReader(standalone.Reader['Any']):
35+
class SphinxBaseReader(standalone.Reader): # type: ignore[type-arg]
3636
"""A base class of readers for Sphinx.
3737
3838
This replaces reporter by Sphinx's on generating document.

sphinx/util/docutils.py

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
import docutils
1414
import docutils.frontend
15+
import docutils.writers
1516
from docutils import nodes
1617
from docutils.io import FileOutput
1718
from docutils.parsers.rst import Directive, directives, roles
@@ -499,14 +500,12 @@ def config(self) -> Config:
499500
"""
500501
return self.env.config
501502

502-
def get_source_info(self) -> tuple[str, int]:
503+
def get_source_info(self) -> tuple[str | None, int | None]:
503504
"""Get source and line number.
504505
505506
.. versionadded:: 3.0
506507
"""
507508
source, line = self.state_machine.get_source_and_line(self.lineno)
508-
assert source is not None
509-
assert line is not None
510509
return source, line
511510

512511
def set_source_info(self, node: Node) -> None:
@@ -680,18 +679,20 @@ def config(self) -> Config:
680679
"""
681680
return self.env.config
682681

683-
def get_source_info(self, lineno: int | None = None) -> tuple[str, int]:
682+
def get_source_info(
683+
self, lineno: int | None = None
684+
) -> tuple[str | os.PathLike[str] | None, int | None]:
684685
# .. versionadded:: 3.0
685686
if lineno is None:
686687
lineno = self.lineno
687688
source, line = self.inliner.reporter.get_source_and_line(lineno)
688-
assert source is not None
689-
assert line is not None
690-
return str(source), line
689+
return source, line
691690

692691
def set_source_info(self, node: Node, lineno: int | None = None) -> None:
693692
# .. versionadded:: 2.0
694-
node.source, node.line = self.get_source_info(lineno)
693+
source, line = self.get_source_info(lineno)
694+
node.source = str(source) if source is not None else None
695+
node.line = line
695696

696697
def get_location(self) -> str:
697698
"""Get current location info for logging.
@@ -879,6 +880,8 @@ def _parse_str_to_doctree(
879880
transformer.add_transforms(_READER_TRANSFORMS)
880881
transformer.add_transforms(transforms)
881882
transformer.add_transforms(parser.get_transforms())
883+
# https://github.com/sphinx-doc/sphinx/issues/13713
884+
transformer.components['writer'] = _DummyWriter() # type: ignore[index]
882885

883886
if default_role:
884887
default_role_cm = rst.default_role(env.current_document.docname, default_role)
@@ -927,6 +930,11 @@ def _get_settings(
927930
return settings
928931

929932

933+
class _DummyWriter(docutils.writers.Writer): # type: ignore[type-arg]
934+
# compat for MyST-Parser
935+
supported = ('html',)
936+
937+
930938
if docutils.__version_info__[:2] < (0, 22):
931939
from docutils.parsers.rst import roles
932940

tests/test_ext_autosummary/test_ext_autosummary.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,12 @@
3232
if TYPE_CHECKING:
3333
from xml.etree.ElementTree import Element
3434

35+
if sys.version_info[:2] >= (3, 15):
36+
cached_dunder: tuple[str, ...] = ()
37+
else:
38+
cached_dunder = ('__cached__',)
39+
40+
3541
html_warnfile = StringIO()
3642

3743

@@ -268,7 +274,7 @@ def test_autosummary_generate_content_for_module(app):
268274
'_Exc',
269275
'__all__',
270276
'__builtins__',
271-
'__cached__',
277+
*cached_dunder,
272278
'__doc__',
273279
'__file__',
274280
'__name__',
@@ -377,7 +383,7 @@ def skip_member(app, what, name, obj, skip, options):
377383
'_Exc',
378384
'__all__',
379385
'__builtins__',
380-
'__cached__',
386+
*cached_dunder,
381387
'__doc__',
382388
'__file__',
383389
'__name__',
@@ -424,7 +430,7 @@ def test_autosummary_generate_content_for_module_imported_members(app):
424430
'_Exc',
425431
'__all__',
426432
'__builtins__',
427-
'__cached__',
433+
*cached_dunder,
428434
'__doc__',
429435
'__file__',
430436
'__loader__',
@@ -489,7 +495,7 @@ def test_autosummary_generate_content_for_module_imported_members_inherited_modu
489495
'InheritedAttrClass',
490496
'__all__',
491497
'__builtins__',
492-
'__cached__',
498+
*cached_dunder,
493499
'__doc__',
494500
'__file__',
495501
'__loader__',

0 commit comments

Comments
 (0)