Sphinx 8.1.2__py3-none-any.whl → 8.2.0__py3-none-any.whl

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.

Potentially problematic release.


This version of Sphinx might be problematic. Click here for more details.

Files changed (328) hide show
  1. sphinx/__init__.py +8 -4
  2. sphinx/__main__.py +2 -0
  3. sphinx/_cli/__init__.py +2 -5
  4. sphinx/_cli/util/colour.py +34 -11
  5. sphinx/_cli/util/errors.py +128 -61
  6. sphinx/addnodes.py +51 -35
  7. sphinx/application.py +362 -230
  8. sphinx/builders/__init__.py +87 -64
  9. sphinx/builders/_epub_base.py +65 -56
  10. sphinx/builders/changes.py +17 -23
  11. sphinx/builders/dirhtml.py +8 -13
  12. sphinx/builders/epub3.py +70 -38
  13. sphinx/builders/gettext.py +93 -73
  14. sphinx/builders/html/__init__.py +240 -186
  15. sphinx/builders/html/_assets.py +9 -2
  16. sphinx/builders/html/_build_info.py +3 -0
  17. sphinx/builders/latex/__init__.py +64 -54
  18. sphinx/builders/latex/constants.py +14 -11
  19. sphinx/builders/latex/nodes.py +2 -0
  20. sphinx/builders/latex/theming.py +8 -9
  21. sphinx/builders/latex/transforms.py +7 -5
  22. sphinx/builders/linkcheck.py +193 -149
  23. sphinx/builders/manpage.py +17 -17
  24. sphinx/builders/singlehtml.py +28 -16
  25. sphinx/builders/texinfo.py +28 -21
  26. sphinx/builders/text.py +10 -15
  27. sphinx/builders/xml.py +10 -19
  28. sphinx/cmd/build.py +49 -119
  29. sphinx/cmd/make_mode.py +35 -31
  30. sphinx/cmd/quickstart.py +78 -62
  31. sphinx/config.py +265 -163
  32. sphinx/directives/__init__.py +51 -54
  33. sphinx/directives/admonitions.py +107 -0
  34. sphinx/directives/code.py +24 -19
  35. sphinx/directives/other.py +21 -42
  36. sphinx/directives/patches.py +28 -16
  37. sphinx/domains/__init__.py +54 -31
  38. sphinx/domains/_domains_container.py +22 -17
  39. sphinx/domains/_index.py +5 -8
  40. sphinx/domains/c/__init__.py +366 -245
  41. sphinx/domains/c/_ast.py +378 -256
  42. sphinx/domains/c/_ids.py +89 -31
  43. sphinx/domains/c/_parser.py +283 -214
  44. sphinx/domains/c/_symbol.py +269 -198
  45. sphinx/domains/changeset.py +39 -24
  46. sphinx/domains/citation.py +54 -24
  47. sphinx/domains/cpp/__init__.py +517 -362
  48. sphinx/domains/cpp/_ast.py +999 -682
  49. sphinx/domains/cpp/_ids.py +133 -65
  50. sphinx/domains/cpp/_parser.py +746 -588
  51. sphinx/domains/cpp/_symbol.py +692 -489
  52. sphinx/domains/index.py +10 -8
  53. sphinx/domains/javascript.py +152 -74
  54. sphinx/domains/math.py +50 -40
  55. sphinx/domains/python/__init__.py +402 -211
  56. sphinx/domains/python/_annotations.py +134 -61
  57. sphinx/domains/python/_object.py +155 -68
  58. sphinx/domains/rst.py +94 -49
  59. sphinx/domains/std/__init__.py +510 -249
  60. sphinx/environment/__init__.py +345 -61
  61. sphinx/environment/adapters/asset.py +7 -1
  62. sphinx/environment/adapters/indexentries.py +15 -20
  63. sphinx/environment/adapters/toctree.py +19 -9
  64. sphinx/environment/collectors/__init__.py +3 -1
  65. sphinx/environment/collectors/asset.py +18 -15
  66. sphinx/environment/collectors/dependencies.py +8 -10
  67. sphinx/environment/collectors/metadata.py +6 -4
  68. sphinx/environment/collectors/title.py +3 -1
  69. sphinx/environment/collectors/toctree.py +4 -4
  70. sphinx/errors.py +1 -3
  71. sphinx/events.py +4 -4
  72. sphinx/ext/apidoc/__init__.py +66 -0
  73. sphinx/ext/apidoc/__main__.py +9 -0
  74. sphinx/ext/apidoc/_cli.py +356 -0
  75. sphinx/ext/apidoc/_extension.py +262 -0
  76. sphinx/ext/apidoc/_generate.py +356 -0
  77. sphinx/ext/apidoc/_shared.py +99 -0
  78. sphinx/ext/autodoc/__init__.py +837 -483
  79. sphinx/ext/autodoc/directive.py +57 -21
  80. sphinx/ext/autodoc/importer.py +184 -67
  81. sphinx/ext/autodoc/mock.py +25 -10
  82. sphinx/ext/autodoc/preserve_defaults.py +17 -9
  83. sphinx/ext/autodoc/type_comment.py +56 -29
  84. sphinx/ext/autodoc/typehints.py +49 -26
  85. sphinx/ext/autosectionlabel.py +28 -11
  86. sphinx/ext/autosummary/__init__.py +281 -142
  87. sphinx/ext/autosummary/generate.py +121 -51
  88. sphinx/ext/coverage.py +152 -91
  89. sphinx/ext/doctest.py +169 -101
  90. sphinx/ext/duration.py +12 -6
  91. sphinx/ext/extlinks.py +33 -21
  92. sphinx/ext/githubpages.py +8 -8
  93. sphinx/ext/graphviz.py +175 -109
  94. sphinx/ext/ifconfig.py +11 -6
  95. sphinx/ext/imgconverter.py +48 -25
  96. sphinx/ext/imgmath.py +127 -97
  97. sphinx/ext/inheritance_diagram.py +177 -103
  98. sphinx/ext/intersphinx/__init__.py +22 -13
  99. sphinx/ext/intersphinx/__main__.py +3 -1
  100. sphinx/ext/intersphinx/_cli.py +18 -14
  101. sphinx/ext/intersphinx/_load.py +91 -82
  102. sphinx/ext/intersphinx/_resolve.py +108 -74
  103. sphinx/ext/intersphinx/_shared.py +2 -2
  104. sphinx/ext/linkcode.py +28 -12
  105. sphinx/ext/mathjax.py +60 -29
  106. sphinx/ext/napoleon/__init__.py +19 -7
  107. sphinx/ext/napoleon/docstring.py +229 -231
  108. sphinx/ext/todo.py +44 -49
  109. sphinx/ext/viewcode.py +105 -57
  110. sphinx/extension.py +3 -1
  111. sphinx/highlighting.py +13 -7
  112. sphinx/io.py +9 -13
  113. sphinx/jinja2glue.py +29 -26
  114. sphinx/locale/__init__.py +8 -9
  115. sphinx/locale/ar/LC_MESSAGES/sphinx.mo +0 -0
  116. sphinx/locale/ar/LC_MESSAGES/sphinx.po +2155 -2050
  117. sphinx/locale/bg/LC_MESSAGES/sphinx.mo +0 -0
  118. sphinx/locale/bg/LC_MESSAGES/sphinx.po +2045 -1940
  119. sphinx/locale/bn/LC_MESSAGES/sphinx.mo +0 -0
  120. sphinx/locale/bn/LC_MESSAGES/sphinx.po +2175 -2070
  121. sphinx/locale/ca/LC_MESSAGES/sphinx.js +3 -3
  122. sphinx/locale/ca/LC_MESSAGES/sphinx.mo +0 -0
  123. sphinx/locale/ca/LC_MESSAGES/sphinx.po +2690 -2585
  124. sphinx/locale/ca@valencia/LC_MESSAGES/sphinx.js +63 -0
  125. sphinx/locale/ca@valencia/LC_MESSAGES/sphinx.mo +0 -0
  126. sphinx/locale/ca@valencia/LC_MESSAGES/sphinx.po +4216 -0
  127. sphinx/locale/cak/LC_MESSAGES/sphinx.mo +0 -0
  128. sphinx/locale/cak/LC_MESSAGES/sphinx.po +2096 -1991
  129. sphinx/locale/cs/LC_MESSAGES/sphinx.mo +0 -0
  130. sphinx/locale/cs/LC_MESSAGES/sphinx.po +2248 -2143
  131. sphinx/locale/cy/LC_MESSAGES/sphinx.mo +0 -0
  132. sphinx/locale/cy/LC_MESSAGES/sphinx.po +2201 -2096
  133. sphinx/locale/da/LC_MESSAGES/sphinx.mo +0 -0
  134. sphinx/locale/da/LC_MESSAGES/sphinx.po +2282 -2177
  135. sphinx/locale/de/LC_MESSAGES/sphinx.mo +0 -0
  136. sphinx/locale/de/LC_MESSAGES/sphinx.po +2261 -2156
  137. sphinx/locale/de_DE/LC_MESSAGES/sphinx.mo +0 -0
  138. sphinx/locale/de_DE/LC_MESSAGES/sphinx.po +2045 -1940
  139. sphinx/locale/el/LC_MESSAGES/sphinx.mo +0 -0
  140. sphinx/locale/el/LC_MESSAGES/sphinx.po +2604 -2499
  141. sphinx/locale/en_DE/LC_MESSAGES/sphinx.mo +0 -0
  142. sphinx/locale/en_DE/LC_MESSAGES/sphinx.po +2045 -1940
  143. sphinx/locale/en_FR/LC_MESSAGES/sphinx.mo +0 -0
  144. sphinx/locale/en_FR/LC_MESSAGES/sphinx.po +2045 -1940
  145. sphinx/locale/en_GB/LC_MESSAGES/sphinx.mo +0 -0
  146. sphinx/locale/en_GB/LC_MESSAGES/sphinx.po +2631 -2526
  147. sphinx/locale/en_HK/LC_MESSAGES/sphinx.mo +0 -0
  148. sphinx/locale/en_HK/LC_MESSAGES/sphinx.po +2045 -1940
  149. sphinx/locale/eo/LC_MESSAGES/sphinx.mo +0 -0
  150. sphinx/locale/eo/LC_MESSAGES/sphinx.po +2078 -1973
  151. sphinx/locale/es/LC_MESSAGES/sphinx.mo +0 -0
  152. sphinx/locale/es/LC_MESSAGES/sphinx.po +2633 -2528
  153. sphinx/locale/es_CO/LC_MESSAGES/sphinx.mo +0 -0
  154. sphinx/locale/es_CO/LC_MESSAGES/sphinx.po +2045 -1940
  155. sphinx/locale/et/LC_MESSAGES/sphinx.mo +0 -0
  156. sphinx/locale/et/LC_MESSAGES/sphinx.po +2449 -2344
  157. sphinx/locale/eu/LC_MESSAGES/sphinx.mo +0 -0
  158. sphinx/locale/eu/LC_MESSAGES/sphinx.po +2241 -2136
  159. sphinx/locale/fa/LC_MESSAGES/sphinx.mo +0 -0
  160. sphinx/locale/fa/LC_MESSAGES/sphinx.po +504 -500
  161. sphinx/locale/fi/LC_MESSAGES/sphinx.mo +0 -0
  162. sphinx/locale/fi/LC_MESSAGES/sphinx.po +499 -495
  163. sphinx/locale/fr/LC_MESSAGES/sphinx.mo +0 -0
  164. sphinx/locale/fr/LC_MESSAGES/sphinx.po +513 -509
  165. sphinx/locale/fr_FR/LC_MESSAGES/sphinx.mo +0 -0
  166. sphinx/locale/fr_FR/LC_MESSAGES/sphinx.po +499 -495
  167. sphinx/locale/gl/LC_MESSAGES/sphinx.mo +0 -0
  168. sphinx/locale/gl/LC_MESSAGES/sphinx.po +2644 -2539
  169. sphinx/locale/he/LC_MESSAGES/sphinx.mo +0 -0
  170. sphinx/locale/he/LC_MESSAGES/sphinx.po +499 -495
  171. sphinx/locale/hi/LC_MESSAGES/sphinx.mo +0 -0
  172. sphinx/locale/hi/LC_MESSAGES/sphinx.po +504 -500
  173. sphinx/locale/hi_IN/LC_MESSAGES/sphinx.mo +0 -0
  174. sphinx/locale/hi_IN/LC_MESSAGES/sphinx.po +499 -495
  175. sphinx/locale/hr/LC_MESSAGES/sphinx.mo +0 -0
  176. sphinx/locale/hr/LC_MESSAGES/sphinx.po +501 -497
  177. sphinx/locale/hu/LC_MESSAGES/sphinx.mo +0 -0
  178. sphinx/locale/hu/LC_MESSAGES/sphinx.po +499 -495
  179. sphinx/locale/id/LC_MESSAGES/sphinx.mo +0 -0
  180. sphinx/locale/id/LC_MESSAGES/sphinx.po +2609 -2504
  181. sphinx/locale/is/LC_MESSAGES/sphinx.mo +0 -0
  182. sphinx/locale/is/LC_MESSAGES/sphinx.po +499 -495
  183. sphinx/locale/it/LC_MESSAGES/sphinx.mo +0 -0
  184. sphinx/locale/it/LC_MESSAGES/sphinx.po +2265 -2160
  185. sphinx/locale/ja/LC_MESSAGES/sphinx.mo +0 -0
  186. sphinx/locale/ja/LC_MESSAGES/sphinx.po +2621 -2516
  187. sphinx/locale/ka/LC_MESSAGES/sphinx.mo +0 -0
  188. sphinx/locale/ka/LC_MESSAGES/sphinx.po +2567 -2462
  189. sphinx/locale/ko/LC_MESSAGES/sphinx.mo +0 -0
  190. sphinx/locale/ko/LC_MESSAGES/sphinx.po +2631 -2526
  191. sphinx/locale/lt/LC_MESSAGES/sphinx.mo +0 -0
  192. sphinx/locale/lt/LC_MESSAGES/sphinx.po +2214 -2109
  193. sphinx/locale/lv/LC_MESSAGES/sphinx.mo +0 -0
  194. sphinx/locale/lv/LC_MESSAGES/sphinx.po +2218 -2113
  195. sphinx/locale/mk/LC_MESSAGES/sphinx.mo +0 -0
  196. sphinx/locale/mk/LC_MESSAGES/sphinx.po +2088 -1983
  197. sphinx/locale/nb_NO/LC_MESSAGES/sphinx.mo +0 -0
  198. sphinx/locale/nb_NO/LC_MESSAGES/sphinx.po +2247 -2142
  199. sphinx/locale/ne/LC_MESSAGES/sphinx.mo +0 -0
  200. sphinx/locale/ne/LC_MESSAGES/sphinx.po +2227 -2122
  201. sphinx/locale/nl/LC_MESSAGES/sphinx.mo +0 -0
  202. sphinx/locale/nl/LC_MESSAGES/sphinx.po +2316 -2211
  203. sphinx/locale/pl/LC_MESSAGES/sphinx.js +2 -2
  204. sphinx/locale/pl/LC_MESSAGES/sphinx.mo +0 -0
  205. sphinx/locale/pl/LC_MESSAGES/sphinx.po +2442 -2336
  206. sphinx/locale/pt/LC_MESSAGES/sphinx.mo +0 -0
  207. sphinx/locale/pt/LC_MESSAGES/sphinx.po +2045 -1940
  208. sphinx/locale/pt_BR/LC_MESSAGES/sphinx.mo +0 -0
  209. sphinx/locale/pt_BR/LC_MESSAGES/sphinx.po +2657 -2552
  210. sphinx/locale/pt_PT/LC_MESSAGES/sphinx.mo +0 -0
  211. sphinx/locale/pt_PT/LC_MESSAGES/sphinx.po +2243 -2138
  212. sphinx/locale/ro/LC_MESSAGES/sphinx.mo +0 -0
  213. sphinx/locale/ro/LC_MESSAGES/sphinx.po +2244 -2139
  214. sphinx/locale/ru/LC_MESSAGES/sphinx.js +1 -1
  215. sphinx/locale/ru/LC_MESSAGES/sphinx.mo +0 -0
  216. sphinx/locale/ru/LC_MESSAGES/sphinx.po +2660 -2555
  217. sphinx/locale/si/LC_MESSAGES/sphinx.mo +0 -0
  218. sphinx/locale/si/LC_MESSAGES/sphinx.po +2134 -2029
  219. sphinx/locale/sk/LC_MESSAGES/sphinx.mo +0 -0
  220. sphinx/locale/sk/LC_MESSAGES/sphinx.po +2614 -2509
  221. sphinx/locale/sl/LC_MESSAGES/sphinx.mo +0 -0
  222. sphinx/locale/sl/LC_MESSAGES/sphinx.po +2167 -2062
  223. sphinx/locale/sphinx.pot +2069 -1964
  224. sphinx/locale/sq/LC_MESSAGES/sphinx.mo +0 -0
  225. sphinx/locale/sq/LC_MESSAGES/sphinx.po +2661 -2556
  226. sphinx/locale/sr/LC_MESSAGES/sphinx.mo +0 -0
  227. sphinx/locale/sr/LC_MESSAGES/sphinx.po +2213 -2108
  228. sphinx/locale/sv/LC_MESSAGES/sphinx.mo +0 -0
  229. sphinx/locale/sv/LC_MESSAGES/sphinx.po +2229 -2124
  230. sphinx/locale/te/LC_MESSAGES/sphinx.mo +0 -0
  231. sphinx/locale/te/LC_MESSAGES/sphinx.po +2045 -1940
  232. sphinx/locale/tr/LC_MESSAGES/sphinx.mo +0 -0
  233. sphinx/locale/tr/LC_MESSAGES/sphinx.po +2608 -2503
  234. sphinx/locale/uk_UA/LC_MESSAGES/sphinx.mo +0 -0
  235. sphinx/locale/uk_UA/LC_MESSAGES/sphinx.po +2167 -2062
  236. sphinx/locale/ur/LC_MESSAGES/sphinx.mo +0 -0
  237. sphinx/locale/ur/LC_MESSAGES/sphinx.po +2045 -1940
  238. sphinx/locale/vi/LC_MESSAGES/sphinx.mo +0 -0
  239. sphinx/locale/vi/LC_MESSAGES/sphinx.po +2204 -2099
  240. sphinx/locale/yue/LC_MESSAGES/sphinx.mo +0 -0
  241. sphinx/locale/yue/LC_MESSAGES/sphinx.po +2045 -1940
  242. sphinx/locale/zh_HK/LC_MESSAGES/sphinx.mo +0 -0
  243. sphinx/locale/zh_HK/LC_MESSAGES/sphinx.po +2045 -1940
  244. sphinx/locale/zh_TW/LC_MESSAGES/sphinx.mo +0 -0
  245. sphinx/locale/zh_TW/LC_MESSAGES/sphinx.po +2659 -2554
  246. sphinx/locale/zh_TW.Big5/LC_MESSAGES/sphinx.mo +0 -0
  247. sphinx/locale/zh_TW.Big5/LC_MESSAGES/sphinx.po +2045 -1940
  248. sphinx/parsers.py +8 -7
  249. sphinx/project.py +2 -2
  250. sphinx/pycode/__init__.py +31 -21
  251. sphinx/pycode/ast.py +6 -3
  252. sphinx/pycode/parser.py +14 -8
  253. sphinx/pygments_styles.py +4 -5
  254. sphinx/registry.py +192 -92
  255. sphinx/roles.py +58 -7
  256. sphinx/search/__init__.py +75 -54
  257. sphinx/search/en.py +11 -13
  258. sphinx/search/fi.py +1 -1
  259. sphinx/search/ja.py +8 -6
  260. sphinx/search/nl.py +1 -1
  261. sphinx/search/zh.py +19 -21
  262. sphinx/testing/fixtures.py +26 -29
  263. sphinx/testing/path.py +26 -62
  264. sphinx/testing/restructuredtext.py +14 -8
  265. sphinx/testing/util.py +21 -19
  266. sphinx/texinputs/make.bat.jinja +50 -50
  267. sphinx/texinputs/sphinx.sty +4 -3
  268. sphinx/texinputs/sphinxlatexadmonitions.sty +1 -1
  269. sphinx/texinputs/sphinxlatexobjects.sty +29 -10
  270. sphinx/themes/basic/static/searchtools.js +8 -5
  271. sphinx/theming.py +49 -61
  272. sphinx/transforms/__init__.py +17 -38
  273. sphinx/transforms/compact_bullet_list.py +5 -3
  274. sphinx/transforms/i18n.py +8 -21
  275. sphinx/transforms/post_transforms/__init__.py +142 -93
  276. sphinx/transforms/post_transforms/code.py +5 -5
  277. sphinx/transforms/post_transforms/images.py +28 -24
  278. sphinx/transforms/references.py +3 -1
  279. sphinx/util/__init__.py +109 -60
  280. sphinx/util/_files.py +39 -23
  281. sphinx/util/_importer.py +4 -1
  282. sphinx/util/_inventory_file_reader.py +76 -0
  283. sphinx/util/_io.py +2 -2
  284. sphinx/util/_lines.py +6 -3
  285. sphinx/util/_pathlib.py +40 -2
  286. sphinx/util/build_phase.py +2 -0
  287. sphinx/util/cfamily.py +19 -14
  288. sphinx/util/console.py +44 -179
  289. sphinx/util/display.py +9 -10
  290. sphinx/util/docfields.py +140 -122
  291. sphinx/util/docstrings.py +1 -1
  292. sphinx/util/docutils.py +118 -77
  293. sphinx/util/fileutil.py +25 -26
  294. sphinx/util/http_date.py +2 -0
  295. sphinx/util/i18n.py +77 -64
  296. sphinx/util/images.py +8 -6
  297. sphinx/util/inspect.py +147 -38
  298. sphinx/util/inventory.py +215 -116
  299. sphinx/util/logging.py +33 -33
  300. sphinx/util/matching.py +12 -4
  301. sphinx/util/nodes.py +18 -13
  302. sphinx/util/osutil.py +38 -39
  303. sphinx/util/parallel.py +22 -13
  304. sphinx/util/parsing.py +2 -1
  305. sphinx/util/png.py +6 -2
  306. sphinx/util/requests.py +33 -2
  307. sphinx/util/rst.py +3 -2
  308. sphinx/util/tags.py +1 -1
  309. sphinx/util/template.py +18 -10
  310. sphinx/util/texescape.py +8 -6
  311. sphinx/util/typing.py +148 -122
  312. sphinx/versioning.py +3 -3
  313. sphinx/writers/html.py +3 -1
  314. sphinx/writers/html5.py +63 -52
  315. sphinx/writers/latex.py +83 -67
  316. sphinx/writers/manpage.py +19 -38
  317. sphinx/writers/texinfo.py +47 -47
  318. sphinx/writers/text.py +50 -32
  319. sphinx/writers/xml.py +11 -8
  320. {sphinx-8.1.2.dist-info → sphinx-8.2.0.dist-info}/LICENSE.rst +1 -1
  321. {sphinx-8.1.2.dist-info → sphinx-8.2.0.dist-info}/METADATA +25 -15
  322. sphinx-8.2.0.dist-info/RECORD +606 -0
  323. {sphinx-8.1.2.dist-info → sphinx-8.2.0.dist-info}/WHEEL +1 -1
  324. sphinx/builders/html/transforms.py +0 -90
  325. sphinx/ext/apidoc.py +0 -721
  326. sphinx/util/exceptions.py +0 -74
  327. sphinx-8.1.2.dist-info/RECORD +0 -598
  328. {sphinx-8.1.2.dist-info → sphinx-8.2.0.dist-info}/entry_points.txt +0 -0
@@ -1,10 +1,9 @@
1
1
  from __future__ import annotations
2
2
 
3
- from typing import TYPE_CHECKING, Any
3
+ from typing import TYPE_CHECKING
4
4
 
5
5
  from sphinx.domains.c._ast import (
6
6
  ASTDeclaration,
7
- ASTIdentifier,
8
7
  ASTNestedName,
9
8
  )
10
9
  from sphinx.locale import __
@@ -12,9 +11,11 @@ from sphinx.util import logging
12
11
 
13
12
  if TYPE_CHECKING:
14
13
  from collections.abc import Callable, Iterable, Iterator, Sequence
14
+ from typing import Any, Self
15
15
 
16
- from typing_extensions import Self
17
-
16
+ from sphinx.domains.c._ast import (
17
+ ASTIdentifier,
18
+ )
18
19
  from sphinx.environment import BuildEnvironment
19
20
 
20
21
  logger = logging.getLogger(__name__)
@@ -28,29 +29,47 @@ class _DuplicateSymbolError(Exception):
28
29
  self.declaration = declaration
29
30
 
30
31
  def __str__(self) -> str:
31
- return "Internal C duplicate symbol error:\n%s" % self.symbol.dump(0)
32
+ return 'Internal C duplicate symbol error:\n%s' % self.symbol.dump(0)
32
33
 
33
34
 
34
35
  class SymbolLookupResult:
35
- def __init__(self, symbols: Sequence[Symbol], parentSymbol: Symbol,
36
- ident: ASTIdentifier) -> None:
36
+ __slots__ = 'symbols', 'parent_symbol', 'ident'
37
+
38
+ symbols: Iterable[Symbol]
39
+ parent_symbol: Symbol
40
+ ident_or_op: ASTIdentifier
41
+
42
+ def __init__(
43
+ self, symbols: Iterable[Symbol], parent_symbol: Symbol, ident: ASTIdentifier
44
+ ) -> None:
37
45
  self.symbols = symbols
38
- self.parentSymbol = parentSymbol
46
+ self.parent_symbol = parent_symbol
39
47
  self.ident = ident
40
48
 
49
+ @property
50
+ def parentSymbol(self) -> Symbol:
51
+ return self.parent_symbol
52
+
41
53
 
42
54
  class LookupKey:
43
- def __init__(self, data: list[tuple[ASTIdentifier, str]]) -> None:
55
+ __slots__ = ('data',)
56
+
57
+ data: Sequence[tuple[ASTIdentifier, str]]
58
+
59
+ def __init__(self, data: Sequence[tuple[ASTIdentifier, str]], /) -> None:
44
60
  self.data = data
45
61
 
62
+ def __repr__(self) -> str:
63
+ return f'LookupKey({self.data!r})'
64
+
46
65
  def __str__(self) -> str:
47
- inner = ', '.join(f"({ident}, {id_})" for ident, id_ in self.data)
66
+ inner = ', '.join(f'({ident}, {id_})' for ident, id_ in self.data)
48
67
  return f'[{inner}]'
49
68
 
50
69
 
51
70
  class Symbol:
52
71
  debug_indent = 0
53
- debug_indent_string = " "
72
+ debug_indent_string = ' '
54
73
  debug_lookup = False
55
74
  debug_show_tree = False
56
75
 
@@ -66,7 +85,7 @@ class Symbol:
66
85
  @staticmethod
67
86
  def debug_print(*args: Any) -> None:
68
87
  msg = Symbol.debug_indent_string * Symbol.debug_indent
69
- msg += "".join(str(e) for e in args)
88
+ msg += ''.join(str(e) for e in args)
70
89
  logger.debug(msg)
71
90
 
72
91
  def _assert_invariants(self) -> None:
@@ -79,7 +98,7 @@ class Symbol:
79
98
  assert self.docname
80
99
 
81
100
  def __setattr__(self, key: str, value: Any) -> None:
82
- if key == "children":
101
+ if key == 'children':
83
102
  raise AssertionError
84
103
  return super().__setattr__(key, value)
85
104
 
@@ -136,7 +155,8 @@ class Symbol:
136
155
  def _remove_child(self, child: Symbol) -> None:
137
156
  name = child.ident.name
138
157
  self._children_by_name.pop(name, None)
139
- self._children_by_docname.get(child.docname, {}).pop(name, None)
158
+ if children := self._children_by_docname.get(child.docname):
159
+ children.pop(name, None)
140
160
  if child.ident.is_anonymous:
141
161
  self._anon_children.discard(child)
142
162
 
@@ -159,12 +179,15 @@ class Symbol:
159
179
  def _add_function_params(self) -> None:
160
180
  if Symbol.debug_lookup:
161
181
  Symbol.debug_indent += 1
162
- Symbol.debug_print("_add_function_params:")
182
+ Symbol.debug_print('_add_function_params:')
163
183
  # Note: we may be called from _fill_empty, so the symbols we want
164
184
  # to add may actually already be present (as empty symbols).
165
185
 
166
186
  # add symbols for function parameters, if any
167
- if self.declaration is not None and self.declaration.function_params is not None:
187
+ if (
188
+ self.declaration is not None
189
+ and self.declaration.function_params is not None
190
+ ):
168
191
  for p in self.declaration.function_params:
169
192
  if p.arg is None:
170
193
  continue
@@ -205,8 +228,8 @@ class Symbol:
205
228
 
206
229
  def get_all_symbols(self) -> Iterator[Symbol]:
207
230
  yield self
208
- for sChild in self._children:
209
- yield from sChild.get_all_symbols()
231
+ for s_child in self._children:
232
+ yield from s_child.get_all_symbols()
210
233
 
211
234
  @property
212
235
  def children(self) -> Iterator[Symbol]:
@@ -222,14 +245,11 @@ class Symbol:
222
245
  while s.parent:
223
246
  symbols.append(s)
224
247
  s = s.parent
225
- symbols.reverse()
226
- key = []
227
- for s in symbols:
228
- if s.declaration is not None:
229
- # TODO: do we need the ID?
230
- key.append((s.ident, s.declaration.get_newest_id()))
231
- else:
232
- key.append((s.ident, None))
248
+ key = [
249
+ # TODO: do we need the ID?
250
+ (s.ident, None if s.declaration is None else s.declaration.get_newest_id())
251
+ for s in reversed(symbols)
252
+ ]
233
253
  return LookupKey(key)
234
254
 
235
255
  def get_full_nested_name(self) -> ASTNestedName:
@@ -244,70 +264,74 @@ class Symbol:
244
264
 
245
265
  def _symbol_lookup(
246
266
  self,
247
- nestedName: ASTNestedName,
248
- onMissingQualifiedSymbol: Callable[[Symbol, ASTIdentifier], Symbol | None],
249
- ancestorLookupType: str | None,
250
- matchSelf: bool,
251
- recurseInAnon: bool,
252
- searchInSiblings: bool,
267
+ nested_name: ASTNestedName,
268
+ on_missing_qualified_symbol: Callable[[Symbol, ASTIdentifier], Symbol | None],
269
+ ancestor_lookup_type: str | None,
270
+ match_self: bool,
271
+ recurse_in_anon: bool,
272
+ search_in_siblings: bool,
253
273
  ) -> SymbolLookupResult | None:
254
274
  # TODO: further simplification from C++ to C
255
- # ancestorLookupType: if not None, specifies the target type of the lookup
275
+ # ancestor_lookup_type: if not None, specifies the target type of the lookup
256
276
  if Symbol.debug_lookup:
257
277
  Symbol.debug_indent += 1
258
- Symbol.debug_print("_symbol_lookup:")
278
+ Symbol.debug_print('_symbol_lookup:')
259
279
  Symbol.debug_indent += 1
260
- Symbol.debug_print("self:")
280
+ Symbol.debug_print('self:')
261
281
  logger.debug(self.to_string(Symbol.debug_indent + 1, addEndNewline=False))
262
- Symbol.debug_print("nestedName: ", nestedName)
263
- Symbol.debug_print("ancestorLookupType:", ancestorLookupType)
264
- Symbol.debug_print("matchSelf: ", matchSelf)
265
- Symbol.debug_print("recurseInAnon: ", recurseInAnon)
266
- Symbol.debug_print("searchInSiblings: ", searchInSiblings)
282
+ Symbol.debug_print('nested_name: ', nested_name)
283
+ Symbol.debug_print('ancestor_lookup_type:', ancestor_lookup_type)
284
+ Symbol.debug_print('match_self: ', match_self)
285
+ Symbol.debug_print('recurse_in_anon: ', recurse_in_anon)
286
+ Symbol.debug_print('search_in_siblings: ', search_in_siblings)
267
287
 
268
- names = nestedName.names
288
+ names = nested_name.names
269
289
 
270
290
  # find the right starting point for lookup
271
- parentSymbol = self
272
- if nestedName.rooted:
273
- while parentSymbol.parent is not None:
274
- parentSymbol = parentSymbol.parent
291
+ parent_symbol = self
292
+ if nested_name.rooted:
293
+ while parent_symbol.parent is not None:
294
+ parent_symbol = parent_symbol.parent
275
295
 
276
- if ancestorLookupType is not None:
296
+ if ancestor_lookup_type is not None:
277
297
  # walk up until we find the first identifier
278
- firstName = names[0]
279
- while parentSymbol.parent:
280
- if firstName.name in parentSymbol._children_by_name:
298
+ first_name = names[0]
299
+ while parent_symbol.parent:
300
+ if first_name.name in parent_symbol._children_by_name:
281
301
  break
282
- parentSymbol = parentSymbol.parent
302
+ parent_symbol = parent_symbol.parent
283
303
 
284
304
  if Symbol.debug_lookup:
285
- Symbol.debug_print("starting point:")
286
- logger.debug(parentSymbol.to_string(Symbol.debug_indent + 1, addEndNewline=False))
305
+ Symbol.debug_print('starting point:')
306
+ logger.debug(
307
+ parent_symbol.to_string(Symbol.debug_indent + 1, addEndNewline=False)
308
+ )
287
309
 
288
310
  # and now the actual lookup
289
311
  for ident in names[:-1]:
290
312
  name = ident.name
291
- if name in parentSymbol._children_by_name:
292
- symbol = parentSymbol._children_by_name[name]
313
+ if name in parent_symbol._children_by_name:
314
+ symbol = parent_symbol._children_by_name[name]
293
315
  else:
294
- symbol = onMissingQualifiedSymbol(parentSymbol, ident)
316
+ symbol = on_missing_qualified_symbol(parent_symbol, ident)
295
317
  if symbol is None:
296
318
  if Symbol.debug_lookup:
297
319
  Symbol.debug_indent -= 2
298
320
  return None
299
- parentSymbol = symbol
321
+ parent_symbol = symbol
300
322
 
301
323
  if Symbol.debug_lookup:
302
- Symbol.debug_print("handle last name from:")
303
- logger.debug(parentSymbol.to_string(Symbol.debug_indent + 1, addEndNewline=False))
324
+ Symbol.debug_print('handle last name from:')
325
+ logger.debug(
326
+ parent_symbol.to_string(Symbol.debug_indent + 1, addEndNewline=False)
327
+ )
304
328
 
305
329
  # handle the last name
306
330
  ident = names[-1]
307
331
  name = ident.name
308
- symbol = parentSymbol._children_by_name.get(name)
309
- if not symbol and recurseInAnon:
310
- for child in parentSymbol._anon_children:
332
+ symbol = parent_symbol._children_by_name.get(name)
333
+ if not symbol and recurse_in_anon:
334
+ for child in parent_symbol._anon_children:
311
335
  if name in child._children_by_name:
312
336
  symbol = child._children_by_name[name]
313
337
  break
@@ -316,11 +340,11 @@ class Symbol:
316
340
  Symbol.debug_indent -= 2
317
341
 
318
342
  result = [symbol] if symbol else []
319
- return SymbolLookupResult(result, parentSymbol, ident)
343
+ return SymbolLookupResult(result, parent_symbol, ident)
320
344
 
321
345
  def _add_symbols(
322
346
  self,
323
- nestedName: ASTNestedName,
347
+ nested_name: ASTNestedName,
324
348
  declaration: ASTDeclaration | None,
325
349
  docname: str | None,
326
350
  line: int | None,
@@ -331,152 +355,172 @@ class Symbol:
331
355
 
332
356
  if Symbol.debug_lookup:
333
357
  Symbol.debug_indent += 1
334
- Symbol.debug_print("_add_symbols:")
358
+ Symbol.debug_print('_add_symbols:')
335
359
  Symbol.debug_indent += 1
336
- Symbol.debug_print("nn: ", nestedName)
337
- Symbol.debug_print("decl: ", declaration)
338
- Symbol.debug_print(f"location: {docname}:{line}")
360
+ Symbol.debug_print('nn: ', nested_name)
361
+ Symbol.debug_print('decl: ', declaration)
362
+ Symbol.debug_print(f'location: {docname}:{line}')
339
363
 
340
- def onMissingQualifiedSymbol(parentSymbol: Symbol, ident: ASTIdentifier) -> Symbol:
364
+ def on_missing_qualified_symbol(
365
+ parent_symbol: Symbol, ident: ASTIdentifier
366
+ ) -> Symbol:
341
367
  if Symbol.debug_lookup:
342
368
  Symbol.debug_indent += 1
343
- Symbol.debug_print("_add_symbols, onMissingQualifiedSymbol:")
369
+ Symbol.debug_print('_add_symbols, on_missing_qualified_symbol:')
344
370
  Symbol.debug_indent += 1
345
- Symbol.debug_print("ident: ", ident)
371
+ Symbol.debug_print('ident: ', ident)
346
372
  Symbol.debug_indent -= 2
347
- return Symbol(parent=parentSymbol, ident=ident,
348
- declaration=None, docname=None, line=None)
349
-
350
- lookupResult = self._symbol_lookup(nestedName,
351
- onMissingQualifiedSymbol,
352
- ancestorLookupType=None,
353
- matchSelf=False,
354
- recurseInAnon=False,
355
- searchInSiblings=False)
356
- assert lookupResult is not None # we create symbols all the way, so that can't happen
357
- symbols = list(lookupResult.symbols)
373
+ return Symbol(
374
+ parent=parent_symbol,
375
+ ident=ident,
376
+ declaration=None,
377
+ docname=None,
378
+ line=None,
379
+ )
380
+
381
+ lookup_result = self._symbol_lookup(
382
+ nested_name,
383
+ on_missing_qualified_symbol,
384
+ ancestor_lookup_type=None,
385
+ match_self=False,
386
+ recurse_in_anon=False,
387
+ search_in_siblings=False,
388
+ )
389
+ # we create symbols all the way, so that can't happen
390
+ assert lookup_result is not None
391
+ symbols = list(lookup_result.symbols)
358
392
  if len(symbols) == 0:
359
393
  if Symbol.debug_lookup:
360
- Symbol.debug_print("_add_symbols, result, no symbol:")
394
+ Symbol.debug_print('_add_symbols, result, no symbol:')
361
395
  Symbol.debug_indent += 1
362
- Symbol.debug_print("ident: ", lookupResult.ident)
363
- Symbol.debug_print("declaration: ", declaration)
364
- Symbol.debug_print(f"location: {docname}:{line}")
396
+ Symbol.debug_print('ident: ', lookup_result.ident)
397
+ Symbol.debug_print('declaration: ', declaration)
398
+ Symbol.debug_print(f'location: {docname}:{line}')
365
399
  Symbol.debug_indent -= 1
366
- symbol = Symbol(parent=lookupResult.parentSymbol,
367
- ident=lookupResult.ident,
368
- declaration=declaration,
369
- docname=docname, line=line)
400
+ symbol = Symbol(
401
+ parent=lookup_result.parent_symbol,
402
+ ident=lookup_result.ident,
403
+ declaration=declaration,
404
+ docname=docname,
405
+ line=line,
406
+ )
370
407
  if Symbol.debug_lookup:
371
408
  Symbol.debug_indent -= 2
372
409
  return symbol
373
410
 
374
411
  if Symbol.debug_lookup:
375
- Symbol.debug_print("_add_symbols, result, symbols:")
412
+ Symbol.debug_print('_add_symbols, result, symbols:')
376
413
  Symbol.debug_indent += 1
377
- Symbol.debug_print("number symbols:", len(symbols))
414
+ Symbol.debug_print('number symbols:', len(symbols))
378
415
  Symbol.debug_indent -= 1
379
416
 
380
417
  if not declaration:
381
418
  if Symbol.debug_lookup:
382
- Symbol.debug_print("no declaration")
419
+ Symbol.debug_print('no declaration')
383
420
  Symbol.debug_indent -= 2
384
421
  # good, just a scope creation
385
422
  # TODO: what if we have more than one symbol?
386
423
  return symbols[0]
387
424
 
388
- noDecl = []
389
- withDecl = []
390
- dupDecl = []
425
+ no_decl = []
426
+ with_decl = []
427
+ dup_decl = []
391
428
  for s in symbols:
392
429
  if s.declaration is None:
393
- noDecl.append(s)
430
+ no_decl.append(s)
394
431
  elif s.isRedeclaration:
395
- dupDecl.append(s)
432
+ dup_decl.append(s)
396
433
  else:
397
- withDecl.append(s)
434
+ with_decl.append(s)
398
435
  if Symbol.debug_lookup:
399
- Symbol.debug_print("#noDecl: ", len(noDecl))
400
- Symbol.debug_print("#withDecl:", len(withDecl))
401
- Symbol.debug_print("#dupDecl: ", len(dupDecl))
436
+ Symbol.debug_print('#no_decl: ', len(no_decl))
437
+ Symbol.debug_print('#with_decl:', len(with_decl))
438
+ Symbol.debug_print('#dup_decl: ', len(dup_decl))
402
439
 
403
440
  # With partial builds we may start with a large symbol tree stripped of declarations.
404
- # Essentially any combination of noDecl, withDecl, and dupDecls seems possible.
441
+ # Essentially any combination of no_decl, with_decl, and dup_decls seems possible.
405
442
  # TODO: make partial builds fully work. What should happen when the primary symbol gets
406
443
  # deleted, and other duplicates exist? The full document should probably be rebuild.
407
444
 
408
445
  # First check if one of those with a declaration matches.
409
446
  # If it's a function, we need to compare IDs,
410
447
  # otherwise there should be only one symbol with a declaration.
411
- def makeCandSymbol() -> Symbol:
448
+ def make_cand_symbol() -> Symbol:
412
449
  if Symbol.debug_lookup:
413
- Symbol.debug_print("begin: creating candidate symbol")
414
- symbol = Symbol(parent=lookupResult.parentSymbol,
415
- ident=lookupResult.ident,
416
- declaration=declaration,
417
- docname=docname, line=line)
450
+ Symbol.debug_print('begin: creating candidate symbol')
451
+ symbol = Symbol(
452
+ parent=lookup_result.parent_symbol,
453
+ ident=lookup_result.ident,
454
+ declaration=declaration,
455
+ docname=docname,
456
+ line=line,
457
+ )
418
458
  if Symbol.debug_lookup:
419
- Symbol.debug_print("end: creating candidate symbol")
459
+ Symbol.debug_print('end: creating candidate symbol')
420
460
  return symbol
421
461
 
422
- if len(withDecl) == 0:
423
- candSymbol = None
462
+ if len(with_decl) == 0:
463
+ cand_symbol = None
424
464
  else:
425
- candSymbol = makeCandSymbol()
465
+ cand_symbol = make_cand_symbol()
426
466
 
427
- def handleDuplicateDeclaration(symbol: Symbol, candSymbol: Symbol) -> None:
467
+ def handle_duplicate_declaration(
468
+ symbol: Symbol, cand_symbol: Symbol
469
+ ) -> None:
428
470
  if Symbol.debug_lookup:
429
471
  Symbol.debug_indent += 1
430
- Symbol.debug_print("redeclaration")
472
+ Symbol.debug_print('redeclaration')
431
473
  Symbol.debug_indent -= 1
432
474
  Symbol.debug_indent -= 2
433
475
  # Redeclaration of the same symbol.
434
476
  # Let the new one be there, but raise an error to the client
435
477
  # so it can use the real symbol as subscope.
436
478
  # This will probably result in a duplicate id warning.
437
- candSymbol.isRedeclaration = True
479
+ cand_symbol.isRedeclaration = True
438
480
  raise _DuplicateSymbolError(symbol, declaration)
439
481
 
440
- if declaration.objectType != "function":
441
- assert len(withDecl) <= 1
442
- handleDuplicateDeclaration(withDecl[0], candSymbol)
482
+ if declaration.objectType != 'function':
483
+ assert len(with_decl) <= 1
484
+ handle_duplicate_declaration(with_decl[0], cand_symbol)
443
485
  # (not reachable)
444
486
 
445
487
  # a function, so compare IDs
446
- candId = declaration.get_newest_id()
488
+ cand_id = declaration.get_newest_id()
447
489
  if Symbol.debug_lookup:
448
- Symbol.debug_print("candId:", candId)
449
- for symbol in withDecl:
450
- oldId = symbol.declaration.get_newest_id()
490
+ Symbol.debug_print('cand_id:', cand_id)
491
+ for symbol in with_decl:
492
+ old_id = symbol.declaration.get_newest_id()
451
493
  if Symbol.debug_lookup:
452
- Symbol.debug_print("oldId: ", oldId)
453
- if candId == oldId:
454
- handleDuplicateDeclaration(symbol, candSymbol)
494
+ Symbol.debug_print('old_id: ', old_id)
495
+ if cand_id == old_id:
496
+ handle_duplicate_declaration(symbol, cand_symbol)
455
497
  # (not reachable)
456
498
  # no candidate symbol found with matching ID
457
499
  # if there is an empty symbol, fill that one
458
- if len(noDecl) == 0:
500
+ if len(no_decl) == 0:
459
501
  if Symbol.debug_lookup:
460
502
  Symbol.debug_print(
461
- "no match, no empty, candSybmol is not None?:", candSymbol is not None,
503
+ 'no match, no empty, cand_sybmol is not None?:',
504
+ cand_symbol is not None,
462
505
  )
463
506
  Symbol.debug_indent -= 2
464
- if candSymbol is not None:
465
- return candSymbol
507
+ if cand_symbol is not None:
508
+ return cand_symbol
466
509
  else:
467
- return makeCandSymbol()
510
+ return make_cand_symbol()
468
511
  else:
469
512
  if Symbol.debug_lookup:
470
513
  Symbol.debug_print(
471
- "no match, but fill an empty declaration, candSybmol is not None?:",
472
- candSymbol is not None)
514
+ 'no match, but fill an empty declaration, cand_sybmol is not None?:',
515
+ cand_symbol is not None,
516
+ )
473
517
  Symbol.debug_indent -= 2
474
- if candSymbol is not None:
475
- candSymbol.remove()
476
- # assert len(noDecl) == 1
518
+ if cand_symbol is not None:
519
+ cand_symbol.remove()
520
+ # assert len(no_decl) == 1
477
521
  # TODO: enable assertion when we at some point find out how to do cleanup
478
522
  # for now, just take the first one, it should work fine ... right?
479
- symbol = noDecl[0]
523
+ symbol = no_decl[0]
480
524
  # If someone first opened the scope, and then later
481
525
  # declares it, e.g,
482
526
  # .. namespace:: Test
@@ -485,39 +529,50 @@ class Symbol:
485
529
  symbol._fill_empty(declaration, docname, line)
486
530
  return symbol
487
531
 
488
- def merge_with(self, other: Symbol, docnames: list[str],
489
- env: BuildEnvironment) -> None:
532
+ def merge_with(
533
+ self, other: Symbol, docnames: list[str], env: BuildEnvironment
534
+ ) -> None:
490
535
  if Symbol.debug_lookup:
491
536
  Symbol.debug_indent += 1
492
- Symbol.debug_print("merge_with:")
537
+ Symbol.debug_print('merge_with:')
493
538
 
494
539
  assert other is not None
495
- for otherChild in other._children:
496
- otherName = otherChild.ident.name
497
- if otherName not in self._children_by_name:
540
+ for other_child in other._children:
541
+ other_name = other_child.ident.name
542
+ if other_name not in self._children_by_name:
498
543
  # TODO: hmm, should we prune by docnames?
499
- otherChild.parent = self
500
- self._add_child(otherChild)
501
- otherChild._assert_invariants()
544
+ other_child.parent = self
545
+ self._add_child(other_child)
546
+ other_child._assert_invariants()
502
547
  continue
503
- ourChild = self._children_by_name[otherName]
504
- if otherChild.declaration and otherChild.docname in docnames:
505
- if not ourChild.declaration:
506
- ourChild._fill_empty(otherChild.declaration,
507
- otherChild.docname, otherChild.line)
508
- elif ourChild.docname != otherChild.docname:
509
- name = str(ourChild.declaration)
510
- msg = __("Duplicate C declaration, also defined at %s:%s.\n"
511
- "Declaration is '.. c:%s:: %s'.")
512
- msg = msg % (ourChild.docname, ourChild.line,
513
- ourChild.declaration.directiveType, name)
514
- logger.warning(msg, location=(otherChild.docname, otherChild.line))
548
+ our_child = self._children_by_name[other_name]
549
+ if other_child.declaration and other_child.docname in docnames:
550
+ if not our_child.declaration:
551
+ our_child._fill_empty(
552
+ other_child.declaration, other_child.docname, other_child.line
553
+ )
554
+ elif our_child.docname != other_child.docname:
555
+ name = str(our_child.declaration)
556
+ msg = __(
557
+ 'Duplicate C declaration, also defined at %s:%s.\n'
558
+ "Declaration is '.. c:%s:: %s'."
559
+ )
560
+ logger.warning(
561
+ msg,
562
+ our_child.docname,
563
+ our_child.line,
564
+ our_child.declaration.directiveType,
565
+ name,
566
+ location=(other_child.docname, other_child.line),
567
+ type='duplicate_declaration',
568
+ subtype='c',
569
+ )
515
570
  else:
516
571
  # Both have declarations, and in the same docname.
517
572
  # This can apparently happen, it should be safe to
518
573
  # just ignore it, right?
519
574
  pass
520
- ourChild.merge_with(otherChild, docnames, env)
575
+ our_child.merge_with(other_child, docnames, env)
521
576
 
522
577
  if Symbol.debug_lookup:
523
578
  Symbol.debug_indent -= 1
@@ -525,45 +580,52 @@ class Symbol:
525
580
  def add_name(self, nestedName: ASTNestedName) -> Symbol:
526
581
  if Symbol.debug_lookup:
527
582
  Symbol.debug_indent += 1
528
- Symbol.debug_print("add_name:")
583
+ Symbol.debug_print('add_name:')
529
584
  res = self._add_symbols(nestedName, declaration=None, docname=None, line=None)
530
585
  if Symbol.debug_lookup:
531
586
  Symbol.debug_indent -= 1
532
587
  return res
533
588
 
534
- def add_declaration(self, declaration: ASTDeclaration,
535
- docname: str, line: int) -> Symbol:
589
+ def add_declaration(
590
+ self, declaration: ASTDeclaration, docname: str, line: int
591
+ ) -> Symbol:
536
592
  if Symbol.debug_lookup:
537
593
  Symbol.debug_indent += 1
538
- Symbol.debug_print("add_declaration:")
594
+ Symbol.debug_print('add_declaration:')
539
595
  assert declaration is not None
540
596
  assert docname is not None
541
597
  assert line is not None
542
- nestedName = declaration.name
543
- res = self._add_symbols(nestedName, declaration, docname, line)
598
+ nested_name = declaration.name
599
+ res = self._add_symbols(nested_name, declaration, docname, line)
544
600
  if Symbol.debug_lookup:
545
601
  Symbol.debug_indent -= 1
546
602
  return res
547
603
 
548
- def find_identifier(self, ident: ASTIdentifier,
549
- matchSelf: bool, recurseInAnon: bool, searchInSiblings: bool,
550
- ) -> Symbol | None:
604
+ def find_identifier(
605
+ self,
606
+ ident: ASTIdentifier,
607
+ matchSelf: bool,
608
+ recurseInAnon: bool,
609
+ searchInSiblings: bool,
610
+ ) -> Symbol | None:
551
611
  if Symbol.debug_lookup:
552
612
  Symbol.debug_indent += 1
553
- Symbol.debug_print("find_identifier:")
613
+ Symbol.debug_print('find_identifier:')
554
614
  Symbol.debug_indent += 1
555
- Symbol.debug_print("ident: ", ident)
556
- Symbol.debug_print("matchSelf: ", matchSelf)
557
- Symbol.debug_print("recurseInAnon: ", recurseInAnon)
558
- Symbol.debug_print("searchInSiblings:", searchInSiblings)
615
+ Symbol.debug_print('ident: ', ident)
616
+ Symbol.debug_print('matchSelf: ', matchSelf)
617
+ Symbol.debug_print('recurseInAnon: ', recurseInAnon)
618
+ Symbol.debug_print('searchInSiblings:', searchInSiblings)
559
619
  logger.debug(self.to_string(Symbol.debug_indent + 1, addEndNewline=False))
560
620
  Symbol.debug_indent -= 2
561
621
  current = self
562
622
  while current is not None:
563
623
  if Symbol.debug_lookup:
564
624
  Symbol.debug_indent += 2
565
- Symbol.debug_print("trying:")
566
- logger.debug(current.to_string(Symbol.debug_indent + 1, addEndNewline=False))
625
+ Symbol.debug_print('trying:')
626
+ logger.debug(
627
+ current.to_string(Symbol.debug_indent + 1, addEndNewline=False)
628
+ )
567
629
  Symbol.debug_indent -= 2
568
630
  if matchSelf and current.ident == ident:
569
631
  return current
@@ -582,49 +644,53 @@ class Symbol:
582
644
  def direct_lookup(self, key: LookupKey) -> Symbol | None:
583
645
  if Symbol.debug_lookup:
584
646
  Symbol.debug_indent += 1
585
- Symbol.debug_print("direct_lookup:")
647
+ Symbol.debug_print('direct_lookup:')
586
648
  Symbol.debug_indent += 1
587
649
  s = self
588
650
  for ident, id_ in key.data:
589
651
  s = s._children_by_name.get(ident.name)
590
652
  if Symbol.debug_lookup:
591
- Symbol.debug_print("name: ", ident.name)
592
- Symbol.debug_print("id: ", id_)
653
+ Symbol.debug_print('name: ', ident.name)
654
+ Symbol.debug_print('id: ', id_)
593
655
  if s is not None:
594
- logger.debug(s.to_string(Symbol.debug_indent + 1, addEndNewline=False))
656
+ logger.debug(
657
+ s.to_string(Symbol.debug_indent + 1, addEndNewline=False)
658
+ )
595
659
  else:
596
- Symbol.debug_print("not found")
660
+ Symbol.debug_print('not found')
597
661
  if s is None:
598
662
  break
599
663
  if Symbol.debug_lookup:
600
664
  Symbol.debug_indent -= 2
601
665
  return s
602
666
 
603
- def find_declaration(self, nestedName: ASTNestedName, typ: str,
604
- matchSelf: bool, recurseInAnon: bool) -> Symbol | None:
667
+ def find_declaration(
668
+ self, nestedName: ASTNestedName, typ: str, matchSelf: bool, recurseInAnon: bool
669
+ ) -> Symbol | None:
605
670
  # templateShorthand: missing template parameter lists for templates is ok
606
671
  if Symbol.debug_lookup:
607
672
  Symbol.debug_indent += 1
608
- Symbol.debug_print("find_declaration:")
673
+ Symbol.debug_print('find_declaration:')
609
674
 
610
- def onMissingQualifiedSymbol(
611
- parentSymbol: Symbol,
612
- ident: ASTIdentifier,
675
+ def on_missing_qualified_symbol(
676
+ parent_symbol: Symbol, ident: ASTIdentifier
613
677
  ) -> Symbol | None:
614
678
  return None
615
679
 
616
- lookupResult = self._symbol_lookup(nestedName,
617
- onMissingQualifiedSymbol,
618
- ancestorLookupType=typ,
619
- matchSelf=matchSelf,
620
- recurseInAnon=recurseInAnon,
621
- searchInSiblings=False)
680
+ lookup_result = self._symbol_lookup(
681
+ nestedName,
682
+ on_missing_qualified_symbol,
683
+ ancestor_lookup_type=typ,
684
+ match_self=matchSelf,
685
+ recurse_in_anon=recurseInAnon,
686
+ search_in_siblings=False,
687
+ )
622
688
  if Symbol.debug_lookup:
623
689
  Symbol.debug_indent -= 1
624
- if lookupResult is None:
690
+ if lookup_result is None:
625
691
  return None
626
692
 
627
- symbols = list(lookupResult.symbols)
693
+ symbols = list(lookup_result.symbols)
628
694
  if len(symbols) == 0:
629
695
  return None
630
696
  return symbols[0]
@@ -639,17 +705,22 @@ class Symbol:
639
705
  else:
640
706
  res.append(str(self.declaration))
641
707
  if self.declaration:
642
- res.append(": ")
708
+ res.append(': ')
643
709
  if self.isRedeclaration:
644
710
  res.append('!!duplicate!! ')
645
711
  res.append(str(self.declaration))
646
712
  if self.docname:
647
- res.append('\t(')
648
- res.append(self.docname)
649
- res.append(')')
713
+ res.extend((
714
+ '\t(',
715
+ self.docname,
716
+ ')',
717
+ ))
650
718
  if addEndNewline:
651
719
  res.append('\n')
652
720
  return ''.join(res)
653
721
 
654
722
  def dump(self, indent: int) -> str:
655
- return ''.join([self.to_string(indent), *(c.dump(indent + 1) for c in self._children)])
723
+ return ''.join([
724
+ self.to_string(indent),
725
+ *(c.dump(indent + 1) for c in self._children),
726
+ ])