Skip to content

Commit 9fd9f43

Browse files
authored
Merge branch 'master' into issue-12120/isolate-order-dependent-text-toc-tests
2 parents efd64d9 + 4319c16 commit 9fd9f43

File tree

8 files changed

+114
-7
lines changed

8 files changed

+114
-7
lines changed

.github/workflows/lint.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,26 @@ jobs:
8383
- name: Type check with mypy
8484
run: mypy
8585

86+
pyright:
87+
runs-on: ubuntu-latest
88+
89+
steps:
90+
- uses: actions/checkout@v4
91+
- name: Set up Python
92+
uses: actions/setup-python@v5
93+
with:
94+
python-version: "3"
95+
- name: Install uv
96+
run: >
97+
curl --no-progress-meter --location --fail
98+
--proto '=https' --tlsv1.2
99+
"https://astral.sh/uv/install.sh"
100+
| sh
101+
- name: Install dependencies
102+
run: uv pip install ".[lint,test]"
103+
- name: Type check with pyright
104+
run: pyright
105+
86106
docs-lint:
87107
runs-on: ubuntu-latest
88108

CHANGES.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ Incompatible changes
1717
Code-blokcs are unchanged as FreeMono is now loaded with ``Scale=0.9``.
1818
An adjustement to existing projects is needed only if they used a custom
1919
:ref:`fontpkg` configuration and did not set :ref:`fvset`.
20+
* #12875: Disable smartquotes for languages: ``zh_CN`` and ``zh_TW`` by default.
2021

2122
Deprecated
2223
----------

pyproject.toml

Lines changed: 61 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ docs = [
8181
]
8282
lint = [
8383
"flake8>=6.0",
84-
"ruff==0.6.7",
84+
"ruff==0.6.8",
8585
"mypy==1.11.1",
8686
"sphinx-lint>=0.9",
8787
"types-colorama==0.4.15.20240311",
@@ -92,6 +92,7 @@ lint = [
9292
"types-requests==2.32.0.20240914", # align with requests
9393
"types-urllib3==1.26.25.14",
9494
"tomli>=2", # for mypy (Python<=3.10)
95+
"pyright==1.1.382.post0",
9596
"pytest>=6.0",
9697
]
9798
test = [
@@ -303,3 +304,62 @@ exclude_lines = [
303304
'if __name__ == .__main__.:',
304305
]
305306
ignore_errors = true
307+
308+
[tool.pyright]
309+
typeCheckingMode = "strict"
310+
include = [
311+
"doc/conf.py",
312+
"utils",
313+
"sphinx",
314+
"tests",
315+
]
316+
317+
reportArgumentType = "none"
318+
reportAssignmentType = "none"
319+
reportAttributeAccessIssue = "none"
320+
reportCallIssue = "none"
321+
reportConstantRedefinition = "none"
322+
reportDeprecated = "none"
323+
reportGeneralTypeIssues = "none"
324+
reportIncompatibleMethodOverride = "none"
325+
reportIncompatibleVariableOverride = "none"
326+
reportInconsistentOverload = "none"
327+
reportIndexIssue = "none"
328+
reportInvalidTypeArguments = "none"
329+
reportInvalidTypeForm = "none"
330+
reportInvalidTypeVarUse = "none"
331+
reportMissingImports = "none"
332+
reportMissingModuleSource = "none"
333+
reportMissingParameterType = "none"
334+
reportMissingTypeArgument = "none"
335+
reportMissingTypeStubs = "none"
336+
reportOperatorIssue = "none"
337+
reportOptionalIterable = "none"
338+
reportOptionalMemberAccess = "none"
339+
reportOptionalOperand = "none"
340+
reportOptionalSubscript = "none"
341+
reportPossiblyUnboundVariable = "none"
342+
reportPrivateUsage = "none"
343+
reportRedeclaration = "none"
344+
reportReturnType = "none"
345+
reportSelfClsParameterName = "none"
346+
reportTypeCommentUsage = "none"
347+
reportTypedDictNotRequiredAccess = "none"
348+
reportUndefinedVariable = "none"
349+
reportUnknownArgumentType = "none"
350+
reportUnknownLambdaType = "none"
351+
reportUnknownMemberType = "none"
352+
reportUnknownParameterType = "none"
353+
reportUnknownVariableType = "none"
354+
reportUnnecessaryComparison = "none"
355+
reportUnnecessaryContains = "none"
356+
reportUnnecessaryIsInstance = "none"
357+
reportUnsupportedDunderAll = "none"
358+
reportUntypedBaseClass = "none"
359+
reportUntypedFunctionDecorator = "none"
360+
reportUntypedNamedTuple = "none"
361+
reportUnusedClass = "none"
362+
reportUnusedFunction = "none"
363+
reportUnusedImport = "none"
364+
reportUnusedVariable = "none"
365+
reportWildcardImportFromLibrary = "none"

sphinx/config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ class Config:
271271
'smartquotes': _Opt(True, 'env', ()),
272272
'smartquotes_action': _Opt('qDe', 'env', ()),
273273
'smartquotes_excludes': _Opt(
274-
{'languages': ['ja'], 'builders': ['man', 'text']}, 'env', ()),
274+
{'languages': ['ja', 'zh_CN', 'zh_TW'], 'builders': ['man', 'text']}, 'env', ()),
275275
'option_emphasise_placeholders': _Opt(False, 'env', ()),
276276
}
277277

sphinx/transforms/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ class ApplySourceWorkaround(SphinxTransform):
247247
default_priority = 10
248248

249249
def apply(self, **kwargs: Any) -> None:
250-
for node in self.document.findall(): # type: Node
250+
for node in self.document.findall():
251251
if isinstance(node, nodes.TextElement | nodes.image | nodes.topic):
252252
apply_source_workaround(node)
253253

sphinx/util/docfields.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def _is_single_paragraph(node: nodes.field_body) -> bool:
3131
if len(node) == 0:
3232
return False
3333
elif len(node) > 1:
34-
for subnode in node[1:]: # type: Node
34+
for subnode in node[1:]:
3535
if not isinstance(subnode, nodes.system_message):
3636
return False
3737
return isinstance(node[0], nodes.paragraph)

tests/test_markup/test_smartquotes.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,32 @@ def test_ja_html_builder(app):
8686
assert '<p>-- &quot;Sphinx&quot; is a tool that makes it easy ...</p>' in content
8787

8888

89+
@pytest.mark.sphinx(
90+
'html',
91+
testroot='smartquotes',
92+
freshenv=True,
93+
confoverrides={'language': 'zh_CN'},
94+
)
95+
def test_zh_cn_html_builder(app):
96+
app.build()
97+
98+
content = (app.outdir / 'index.html').read_text(encoding='utf8')
99+
assert '<p>-- &quot;Sphinx&quot; is a tool that makes it easy ...</p>' in content
100+
101+
102+
@pytest.mark.sphinx(
103+
'html',
104+
testroot='smartquotes',
105+
freshenv=True,
106+
confoverrides={'language': 'zh_TW'},
107+
)
108+
def test_zh_tw_html_builder(app):
109+
app.build()
110+
111+
content = (app.outdir / 'index.html').read_text(encoding='utf8')
112+
assert '<p>-- &quot;Sphinx&quot; is a tool that makes it easy ...</p>' in content
113+
114+
89115
@pytest.mark.sphinx(
90116
'html',
91117
testroot='smartquotes',

tox.ini

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,10 @@ extras =
3636
# If you update any of these commands, don't forget to update the equivalent
3737
# GitHub Workflow step
3838
commands =
39-
ruff . --diff --format github
39+
ruff check . --output-format github
4040
flake8 .
41-
isort --check-only --diff .
42-
mypy sphinx/
41+
mypy
42+
pyright
4343

4444
[testenv:docs]
4545
description =

0 commit comments

Comments
 (0)