Skip to content

Commit 3dd562a

Browse files
committed
Merge branch '4.x' into 9487_typehint_for_cached_property
2 parents 65c089b + 05cce83 commit 3dd562a

File tree

6 files changed

+31
-21
lines changed

6 files changed

+31
-21
lines changed

CHANGES

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ Dependencies
3434
Incompatible changes
3535
--------------------
3636

37+
* #9435: linkcheck: Disable checking automatically generated anchors on
38+
github.com (ex. anchors in reST/Markdown documents)
39+
3740
Deprecated
3841
----------
3942

@@ -43,6 +46,12 @@ Features added
4346
Bugs fixed
4447
----------
4548

49+
* #9489: autodoc: Custom types using ``typing.NewType`` are not displayed well
50+
with the HEAD of 3.10
51+
* #9490: autodoc: Some objects under ``typing`` module are not displayed well
52+
with the HEAD of 3.10
53+
* #9435: linkcheck: Failed to check anchors in github.com
54+
4655
Testing
4756
--------
4857

sphinx/builders/linkcheck.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -714,7 +714,10 @@ def setup(app: Sphinx) -> Dict[str, Any]:
714714
app.add_event('linkcheck-process-uri')
715715

716716
app.connect('config-inited', compile_linkcheck_allowed_redirects, priority=800)
717-
app.connect('linkcheck-process-uri', rewrite_github_anchor)
717+
718+
# FIXME: Disable URL rewrite handler for github.com temporarily.
719+
# ref: https://github.com/sphinx-doc/sphinx/issues/9435
720+
# app.connect('linkcheck-process-uri', rewrite_github_anchor)
718721

719722
return {
720723
'version': 'builtin',

sphinx/util/inspect.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -211,12 +211,15 @@ def getslots(obj: Any) -> Optional[Dict]:
211211

212212
def isNewType(obj: Any) -> bool:
213213
"""Check the if object is a kind of NewType."""
214-
__module__ = safe_getattr(obj, '__module__', None)
215-
__qualname__ = safe_getattr(obj, '__qualname__', None)
216-
if __module__ == 'typing' and __qualname__ == 'NewType.<locals>.new_type':
217-
return True
214+
if sys.version_info >= (3, 10):
215+
return isinstance(obj, typing.NewType)
218216
else:
219-
return False
217+
__module__ = safe_getattr(obj, '__module__', None)
218+
__qualname__ = safe_getattr(obj, '__qualname__', None)
219+
if __module__ == 'typing' and __qualname__ == 'NewType.<locals>.new_type':
220+
return True
221+
else:
222+
return False
220223

221224

222225
def isenumclass(x: Any) -> bool:

sphinx/util/typing.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -171,17 +171,17 @@ def _restify_py37(cls: Optional[Type]) -> str:
171171
text += r"\ [%s]" % ", ".join(restify(a) for a in cls.__args__)
172172

173173
return text
174-
elif hasattr(cls, '__qualname__'):
175-
if cls.__module__ == 'typing':
176-
return ':class:`~%s.%s`' % (cls.__module__, cls.__qualname__)
177-
else:
178-
return ':class:`%s.%s`' % (cls.__module__, cls.__qualname__)
179174
elif hasattr(cls, '_name'):
180175
# SpecialForm
181176
if cls.__module__ == 'typing':
182177
return ':obj:`~%s.%s`' % (cls.__module__, cls._name)
183178
else:
184179
return ':obj:`%s.%s`' % (cls.__module__, cls._name)
180+
elif hasattr(cls, '__qualname__'):
181+
if cls.__module__ == 'typing':
182+
return ':class:`~%s.%s`' % (cls.__module__, cls.__qualname__)
183+
else:
184+
return ':class:`%s.%s`' % (cls.__module__, cls.__qualname__)
185185
elif isinstance(cls, ForwardRef):
186186
return ':class:`%s`' % cls.__forward_arg__
187187
else:
@@ -309,7 +309,7 @@ def stringify(annotation: Any) -> str:
309309
elif annotation in INVALID_BUILTIN_CLASSES:
310310
return INVALID_BUILTIN_CLASSES[annotation]
311311
elif (getattr(annotation, '__module__', None) == 'builtins' and
312-
hasattr(annotation, '__qualname__')):
312+
getattr(annotation, '__qualname__', None)):
313313
if hasattr(annotation, '__args__'): # PEP 585 generic
314314
return repr(annotation)
315315
else:

tests/roots/test-linkcheck/links.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@ Some additional anchors to exercise ignore code
1313
* `Complete nonsense <https://localhost:7777/doesnotexist>`_
1414
* `Example valid local file <conf.py>`_
1515
* `Example invalid local file <path/to/notfound>`_
16-
* https://github.com/sphinx-doc/sphinx#documentation
17-
* https://github.com/sphinx-doc/sphinx#user-content-testing
16+
* https://github.com/sphinx-doc/sphinx/blob/4.x/sphinx/__init__.py#L2
1817

1918
.. image:: https://www.google.com/image.png
2019
.. figure:: https://www.google.com/image2.png

tests/test_build_linkcheck.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ def test_defaults_json(app):
6666
"info"]:
6767
assert attr in row
6868

69-
assert len(content.splitlines()) == 12
70-
assert len(rows) == 12
69+
assert len(content.splitlines()) == 11
70+
assert len(rows) == 11
7171
# the output order of the rows is not stable
7272
# due to possible variance in network latency
7373
rowsby = {row["uri"]: row for row in rows}
@@ -88,7 +88,7 @@ def test_defaults_json(app):
8888
assert dnerow['uri'] == 'https://localhost:7777/doesnotexist'
8989
assert rowsby['https://www.google.com/image2.png'] == {
9090
'filename': 'links.txt',
91-
'lineno': 20,
91+
'lineno': 19,
9292
'status': 'broken',
9393
'code': 0,
9494
'uri': 'https://www.google.com/image2.png',
@@ -102,10 +102,6 @@ def test_defaults_json(app):
102102
# images should fail
103103
assert "Not Found for url: https://www.google.com/image.png" in \
104104
rowsby["https://www.google.com/image.png"]["info"]
105-
# The anchor of the URI for github.com is automatically modified
106-
assert 'https://github.com/sphinx-doc/sphinx#documentation' not in rowsby
107-
assert 'https://github.com/sphinx-doc/sphinx#user-content-documentation' in rowsby
108-
assert 'https://github.com/sphinx-doc/sphinx#user-content-testing' in rowsby
109105

110106

111107
@pytest.mark.sphinx(

0 commit comments

Comments
 (0)