python-constricter 0.4.5__tar.gz → 0.4.6__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 (202) hide show
  1. {python_constricter-0.4.5 → python_constricter-0.4.6}/PKG-INFO +4 -2
  2. {python_constricter-0.4.5 → python_constricter-0.4.6}/README.md +3 -1
  3. {python_constricter-0.4.5 → python_constricter-0.4.6}/constricter/_version.py +1 -1
  4. {python_constricter-0.4.5 → python_constricter-0.4.6}/constricter/cli/lsp/hints.py +8 -6
  5. {python_constricter-0.4.5 → python_constricter-0.4.6}/constricter/cli/lsp/stored.py +5 -1
  6. {python_constricter-0.4.5 → python_constricter-0.4.6}/constricter/cli/paths.py +3 -3
  7. {python_constricter-0.4.5 → python_constricter-0.4.6}/constricter/cli/rounds.py +11 -2
  8. {python_constricter-0.4.5 → python_constricter-0.4.6}/constricter/cli/workers.py +4 -4
  9. {python_constricter-0.4.5 → python_constricter-0.4.6}/constricter/fix/core/known.py +13 -1
  10. {python_constricter-0.4.5 → python_constricter-0.4.6}/constricter/fix/index/crossed.py +33 -10
  11. {python_constricter-0.4.5 → python_constricter-0.4.6}/constricter/fix/index/modules.py +55 -13
  12. {python_constricter-0.4.5 → python_constricter-0.4.6}/constricter/fix/index/offers.py +154 -15
  13. {python_constricter-0.4.5 → python_constricter-0.4.6}/constricter/fix/index/spelling.py +4 -3
  14. {python_constricter-0.4.5 → python_constricter-0.4.6}/constricter/fix/index/stubs/installed.py +10 -4
  15. python_constricter-0.4.6/constricter/fix/index/stubs/lone.py +100 -0
  16. {python_constricter-0.4.5 → python_constricter-0.4.6}/constricter/fix/tables/source.json +1 -1
  17. python_constricter-0.4.6/constricter/fix/values/echoed.py +67 -0
  18. {python_constricter-0.4.5 → python_constricter-0.4.6}/constricter/fix/values/guesses.py +7 -2
  19. {python_constricter-0.4.5 → python_constricter-0.4.6}/constricter/fix/values/inference.py +3 -1
  20. {python_constricter-0.4.5 → python_constricter-0.4.6}/constricter/fix/values/returned.py +72 -3
  21. {python_constricter-0.4.5 → python_constricter-0.4.6}/constricter/offences.py +1 -0
  22. {python_constricter-0.4.5 → python_constricter-0.4.6}/constricter/recording.py +14 -10
  23. {python_constricter-0.4.5 → python_constricter-0.4.6}/constricter/rules/checker.py +5 -1
  24. {python_constricter-0.4.5 → python_constricter-0.4.6}/constricter/source/declarations.py +27 -15
  25. {python_constricter-0.4.5 → python_constricter-0.4.6}/constricter/source/syntax.py +21 -0
  26. {python_constricter-0.4.5 → python_constricter-0.4.6}/constricter/source/walked.py +4 -2
  27. {python_constricter-0.4.5 → python_constricter-0.4.6}/constricter/trace.py +92 -23
  28. python_constricter-0.4.6/constricter/witness.py +636 -0
  29. {python_constricter-0.4.5 → python_constricter-0.4.6}/pyproject.toml +11 -5
  30. {python_constricter-0.4.5 → python_constricter-0.4.6}/.gitignore +0 -0
  31. {python_constricter-0.4.5 → python_constricter-0.4.6}/LICENSE.md +0 -0
  32. {python_constricter-0.4.5 → python_constricter-0.4.6}/constricter/__init__.py +0 -0
  33. {python_constricter-0.4.5 → python_constricter-0.4.6}/constricter/__main__.py +0 -0
  34. {python_constricter-0.4.5 → python_constricter-0.4.6}/constricter/cli/__init__.py +0 -0
  35. {python_constricter-0.4.5 → python_constricter-0.4.6}/constricter/cli/baseline.py +0 -0
  36. {python_constricter-0.4.5 → python_constricter-0.4.6}/constricter/cli/collecting.py +0 -0
  37. {python_constricter-0.4.5 → python_constricter-0.4.6}/constricter/cli/command.py +0 -0
  38. {python_constricter-0.4.5 → python_constricter-0.4.6}/constricter/cli/config.py +0 -0
  39. {python_constricter-0.4.5 → python_constricter-0.4.6}/constricter/cli/explain.py +0 -0
  40. {python_constricter-0.4.5 → python_constricter-0.4.6}/constricter/cli/lsp/__init__.py +0 -0
  41. {python_constricter-0.4.5 → python_constricter-0.4.6}/constricter/cli/lsp/connection.py +0 -0
  42. {python_constricter-0.4.5 → python_constricter-0.4.6}/constricter/cli/lsp/edits.py +0 -0
  43. {python_constricter-0.4.5 → python_constricter-0.4.6}/constricter/cli/lsp/guard.py +0 -0
  44. {python_constricter-0.4.5 → python_constricter-0.4.6}/constricter/cli/lsp/protocol.py +0 -0
  45. {python_constricter-0.4.5 → python_constricter-0.4.6}/constricter/cli/lsp/remembered.py +0 -0
  46. {python_constricter-0.4.5 → python_constricter-0.4.6}/constricter/cli/options.py +0 -0
  47. {python_constricter-0.4.5 → python_constricter-0.4.6}/constricter/cli/reading.py +0 -0
  48. {python_constricter-0.4.5 → python_constricter-0.4.6}/constricter/cli/report.py +0 -0
  49. {python_constricter-0.4.5 → python_constricter-0.4.6}/constricter/cli/runs.py +0 -0
  50. {python_constricter-0.4.5 → python_constricter-0.4.6}/constricter/cli/schedule.py +0 -0
  51. {python_constricter-0.4.5 → python_constricter-0.4.6}/constricter/empty.py +0 -0
  52. {python_constricter-0.4.5 → python_constricter-0.4.6}/constricter/fix/__init__.py +0 -0
  53. {python_constricter-0.4.5 → python_constricter-0.4.6}/constricter/fix/core/__init__.py +0 -0
  54. {python_constricter-0.4.5 → python_constricter-0.4.6}/constricter/fix/core/asked.py +0 -0
  55. {python_constricter-0.4.5 → python_constricter-0.4.6}/constricter/fix/core/fixes.py +0 -0
  56. {python_constricter-0.4.5 → python_constricter-0.4.6}/constricter/fix/core/imports.py +0 -0
  57. {python_constricter-0.4.5 → python_constricter-0.4.6}/constricter/fix/core/inherited.py +0 -0
  58. {python_constricter-0.4.5 → python_constricter-0.4.6}/constricter/fix/core/signatures.py +0 -0
  59. {python_constricter-0.4.5 → python_constricter-0.4.6}/constricter/fix/index/__init__.py +0 -0
  60. {python_constricter-0.4.5 → python_constricter-0.4.6}/constricter/fix/index/across.py +0 -0
  61. {python_constricter-0.4.5 → python_constricter-0.4.6}/constricter/fix/index/annotated.py +0 -0
  62. {python_constricter-0.4.5 → python_constricter-0.4.6}/constricter/fix/index/awaits.py +0 -0
  63. {python_constricter-0.4.5 → python_constricter-0.4.6}/constricter/fix/index/beyond.py +0 -0
  64. {python_constricter-0.4.5 → python_constricter-0.4.6}/constricter/fix/index/callers.py +0 -0
  65. {python_constricter-0.4.5 → python_constricter-0.4.6}/constricter/fix/index/consistent.py +0 -0
  66. {python_constricter-0.4.5 → python_constricter-0.4.6}/constricter/fix/index/decorated.py +0 -0
  67. {python_constricter-0.4.5 → python_constricter-0.4.6}/constricter/fix/index/fixtures.py +0 -0
  68. {python_constricter-0.4.5 → python_constricter-0.4.6}/constricter/fix/index/linked.py +0 -0
  69. {python_constricter-0.4.5 → python_constricter-0.4.6}/constricter/fix/index/loose.py +0 -0
  70. {python_constricter-0.4.5 → python_constricter-0.4.6}/constricter/fix/index/managed.py +0 -0
  71. {python_constricter-0.4.5 → python_constricter-0.4.6}/constricter/fix/index/order.py +0 -0
  72. {python_constricter-0.4.5 → python_constricter-0.4.6}/constricter/fix/index/origins.py +0 -0
  73. {python_constricter-0.4.5 → python_constricter-0.4.6}/constricter/fix/index/own_methods.py +0 -0
  74. {python_constricter-0.4.5 → python_constricter-0.4.6}/constricter/fix/index/own_overloads.py +0 -0
  75. {python_constricter-0.4.5 → python_constricter-0.4.6}/constricter/fix/index/own_stubs.py +0 -0
  76. {python_constricter-0.4.5 → python_constricter-0.4.6}/constricter/fix/index/own_types.py +0 -0
  77. {python_constricter-0.4.5 → python_constricter-0.4.6}/constricter/fix/index/params.py +0 -0
  78. {python_constricter-0.4.5 → python_constricter-0.4.6}/constricter/fix/index/plain.py +0 -0
  79. {python_constricter-0.4.5 → python_constricter-0.4.6}/constricter/fix/index/project.py +0 -0
  80. {python_constricter-0.4.5 → python_constricter-0.4.6}/constricter/fix/index/sides.py +0 -0
  81. {python_constricter-0.4.5 → python_constricter-0.4.6}/constricter/fix/index/strings.py +0 -0
  82. {python_constricter-0.4.5 → python_constricter-0.4.6}/constricter/fix/index/stubs/__init__.py +0 -0
  83. {python_constricter-0.4.5 → python_constricter-0.4.6}/constricter/fix/index/stubs/atoms.py +0 -0
  84. {python_constricter-0.4.5 → python_constricter-0.4.6}/constricter/fix/index/stubs/chained.py +0 -0
  85. {python_constricter-0.4.5 → python_constricter-0.4.6}/constricter/fix/index/stubs/classnames.py +0 -0
  86. {python_constricter-0.4.5 → python_constricter-0.4.6}/constricter/fix/index/stubs/declared.py +0 -0
  87. {python_constricter-0.4.5 → python_constricter-0.4.6}/constricter/fix/index/stubs/names.py +0 -0
  88. {python_constricter-0.4.5 → python_constricter-0.4.6}/constricter/fix/index/stubs/read.py +0 -0
  89. {python_constricter-0.4.5 → python_constricter-0.4.6}/constricter/fix/index/stubs/signatures.py +0 -0
  90. {python_constricter-0.4.5 → python_constricter-0.4.6}/constricter/fix/index/stubs/stubbed.py +0 -0
  91. {python_constricter-0.4.5 → python_constricter-0.4.6}/constricter/fix/index/taken.py +0 -0
  92. {python_constricter-0.4.5 → python_constricter-0.4.6}/constricter/fix/index/tuples.py +0 -0
  93. {python_constricter-0.4.5 → python_constricter-0.4.6}/constricter/fix/index/used.py +0 -0
  94. {python_constricter-0.4.5 → python_constricter-0.4.6}/constricter/fix/libraries/__init__.py +0 -0
  95. {python_constricter-0.4.5 → python_constricter-0.4.6}/constricter/fix/libraries/generics.py +0 -0
  96. {python_constricter-0.4.5 → python_constricter-0.4.6}/constricter/fix/libraries/library.py +0 -0
  97. {python_constricter-0.4.5 → python_constricter-0.4.6}/constricter/fix/libraries/opened.py +0 -0
  98. {python_constricter-0.4.5 → python_constricter-0.4.6}/constricter/fix/libraries/operators.py +0 -0
  99. {python_constricter-0.4.5 → python_constricter-0.4.6}/constricter/fix/libraries/overloads.py +0 -0
  100. {python_constricter-0.4.5 → python_constricter-0.4.6}/constricter/fix/libraries/receivers.py +0 -0
  101. {python_constricter-0.4.5 → python_constricter-0.4.6}/constricter/fix/libraries/stdlib.py +0 -0
  102. {python_constricter-0.4.5 → python_constricter-0.4.6}/constricter/fix/libraries/walks.py +0 -0
  103. {python_constricter-0.4.5 → python_constricter-0.4.6}/constricter/fix/tables/aliases.json +0 -0
  104. {python_constricter-0.4.5 → python_constricter-0.4.6}/constricter/fix/tables/attributes.json +0 -0
  105. {python_constricter-0.4.5 → python_constricter-0.4.6}/constricter/fix/tables/awaited.json +0 -0
  106. {python_constricter-0.4.5 → python_constricter-0.4.6}/constricter/fix/tables/awaited_overloads.json +0 -0
  107. {python_constricter-0.4.5 → python_constricter-0.4.6}/constricter/fix/tables/bases.json +0 -0
  108. {python_constricter-0.4.5 → python_constricter-0.4.6}/constricter/fix/tables/classes.json +0 -0
  109. {python_constricter-0.4.5 → python_constricter-0.4.6}/constricter/fix/tables/elements.json +0 -0
  110. {python_constricter-0.4.5 → python_constricter-0.4.6}/constricter/fix/tables/functions.json +0 -0
  111. {python_constricter-0.4.5 → python_constricter-0.4.6}/constricter/fix/tables/generic_attributes.json +0 -0
  112. {python_constricter-0.4.5 → python_constricter-0.4.6}/constricter/fix/tables/method_overloads.json +0 -0
  113. {python_constricter-0.4.5 → python_constricter-0.4.6}/constricter/fix/tables/method_signatures.json +0 -0
  114. {python_constricter-0.4.5 → python_constricter-0.4.6}/constricter/fix/tables/methods.json +0 -0
  115. {python_constricter-0.4.5 → python_constricter-0.4.6}/constricter/fix/tables/overloads.json +0 -0
  116. {python_constricter-0.4.5 → python_constricter-0.4.6}/constricter/fix/tables/platform.json +0 -0
  117. {python_constricter-0.4.5 → python_constricter-0.4.6}/constricter/fix/tables/returns.json +0 -0
  118. {python_constricter-0.4.5 → python_constricter-0.4.6}/constricter/fix/tables/scalar_members.json +0 -0
  119. {python_constricter-0.4.5 → python_constricter-0.4.6}/constricter/fix/tables/scalars.json +0 -0
  120. {python_constricter-0.4.5 → python_constricter-0.4.6}/constricter/fix/tables/subscriptable.json +0 -0
  121. {python_constricter-0.4.5 → python_constricter-0.4.6}/constricter/fix/tables/type_parameters.json +0 -0
  122. {python_constricter-0.4.5 → python_constricter-0.4.6}/constricter/fix/tables/variables.json +0 -0
  123. {python_constricter-0.4.5 → python_constricter-0.4.6}/constricter/fix/values/__init__.py +0 -0
  124. {python_constricter-0.4.5 → python_constricter-0.4.6}/constricter/fix/values/aliased.py +0 -0
  125. {python_constricter-0.4.5 → python_constricter-0.4.6}/constricter/fix/values/bodies.py +0 -0
  126. {python_constricter-0.4.5 → python_constricter-0.4.6}/constricter/fix/values/callables.py +0 -0
  127. {python_constricter-0.4.5 → python_constricter-0.4.6}/constricter/fix/values/called.py +0 -0
  128. {python_constricter-0.4.5 → python_constricter-0.4.6}/constricter/fix/values/classvars.py +0 -0
  129. {python_constricter-0.4.5 → python_constricter-0.4.6}/constricter/fix/values/decided.py +0 -0
  130. {python_constricter-0.4.5 → python_constricter-0.4.6}/constricter/fix/values/displays.py +0 -0
  131. {python_constricter-0.4.5 → python_constricter-0.4.6}/constricter/fix/values/documented.py +0 -0
  132. {python_constricter-0.4.5 → python_constricter-0.4.6}/constricter/fix/values/doubts.py +0 -0
  133. {python_constricter-0.4.5 → python_constricter-0.4.6}/constricter/fix/values/entered.py +0 -0
  134. {python_constricter-0.4.5 → python_constricter-0.4.6}/constricter/fix/values/fills.py +0 -0
  135. {python_constricter-0.4.5 → python_constricter-0.4.6}/constricter/fix/values/hinted.py +0 -0
  136. {python_constricter-0.4.5 → python_constricter-0.4.6}/constricter/fix/values/loops.py +0 -0
  137. {python_constricter-0.4.5 → python_constricter-0.4.6}/constricter/fix/values/members.py +0 -0
  138. {python_constricter-0.4.5 → python_constricter-0.4.6}/constricter/fix/values/narrowed.py +0 -0
  139. {python_constricter-0.4.5 → python_constricter-0.4.6}/constricter/fix/values/operated.py +0 -0
  140. {python_constricter-0.4.5 → python_constricter-0.4.6}/constricter/fix/values/ordered.py +0 -0
  141. {python_constricter-0.4.5 → python_constricter-0.4.6}/constricter/fix/values/reads.py +0 -0
  142. {python_constricter-0.4.5 → python_constricter-0.4.6}/constricter/fix/values/refused.py +0 -0
  143. {python_constricter-0.4.5 → python_constricter-0.4.6}/constricter/fix/values/returns.py +0 -0
  144. {python_constricter-0.4.5 → python_constricter-0.4.6}/constricter/fix/values/shapes.py +0 -0
  145. {python_constricter-0.4.5 → python_constricter-0.4.6}/constricter/fix/values/stored.py +0 -0
  146. {python_constricter-0.4.5 → python_constricter-0.4.6}/constricter/fix/values/tables.py +0 -0
  147. {python_constricter-0.4.5 → python_constricter-0.4.6}/constricter/fix/values/targets.py +0 -0
  148. {python_constricter-0.4.5 → python_constricter-0.4.6}/constricter/fix/values/unchecked.py +0 -0
  149. {python_constricter-0.4.5 → python_constricter-0.4.6}/constricter/jsonc.py +0 -0
  150. {python_constricter-0.4.5 → python_constricter-0.4.6}/constricter/noqa.py +0 -0
  151. {python_constricter-0.4.5 → python_constricter-0.4.6}/constricter/notebook.py +0 -0
  152. {python_constricter-0.4.5 → python_constricter-0.4.6}/constricter/overrides.py +0 -0
  153. {python_constricter-0.4.5 → python_constricter-0.4.6}/constricter/plugins/__init__.py +0 -0
  154. {python_constricter-0.4.5 → python_constricter-0.4.6}/constricter/plugins/flake8.py +0 -0
  155. {python_constricter-0.4.5 → python_constricter-0.4.6}/constricter/plugins/options.py +0 -0
  156. {python_constricter-0.4.5 → python_constricter-0.4.6}/constricter/plugins/pylint.py +0 -0
  157. {python_constricter-0.4.5 → python_constricter-0.4.6}/constricter/py.typed +0 -0
  158. {python_constricter-0.4.5 → python_constricter-0.4.6}/constricter/rules/__init__.py +0 -0
  159. {python_constricter-0.4.5 → python_constricter-0.4.6}/constricter/rules/attributes.py +0 -0
  160. {python_constricter-0.4.5 → python_constricter-0.4.6}/constricter/rules/binding.py +0 -0
  161. {python_constricter-0.4.5 → python_constricter-0.4.6}/constricter/rules/calls.py +0 -0
  162. {python_constricter-0.4.5 → python_constricter-0.4.6}/constricter/rules/late.py +0 -0
  163. {python_constricter-0.4.5 → python_constricter-0.4.6}/constricter/rules/narrowing.py +0 -0
  164. {python_constricter-0.4.5 → python_constricter-0.4.6}/constricter/rules/parameters.py +0 -0
  165. {python_constricter-0.4.5 → python_constricter-0.4.6}/constricter/rules/rebinding.py +0 -0
  166. {python_constricter-0.4.5 → python_constricter-0.4.6}/constricter/rules/rebound.py +0 -0
  167. {python_constricter-0.4.5 → python_constricter-0.4.6}/constricter/rules/recorded.py +0 -0
  168. {python_constricter-0.4.5 → python_constricter-0.4.6}/constricter/rules/redundant.py +0 -0
  169. {python_constricter-0.4.5 → python_constricter-0.4.6}/constricter/rules/returning.py +0 -0
  170. {python_constricter-0.4.5 → python_constricter-0.4.6}/constricter/rules/scope.py +0 -0
  171. {python_constricter-0.4.5 → python_constricter-0.4.6}/constricter/rules/scoped.py +0 -0
  172. {python_constricter-0.4.5 → python_constricter-0.4.6}/constricter/rules/scoping.py +0 -0
  173. {python_constricter-0.4.5 → python_constricter-0.4.6}/constricter/rules/settings.py +0 -0
  174. {python_constricter-0.4.5 → python_constricter-0.4.6}/constricter/rules/signatures.py +0 -0
  175. {python_constricter-0.4.5 → python_constricter-0.4.6}/constricter/rules/widened.py +0 -0
  176. {python_constricter-0.4.5 → python_constricter-0.4.6}/constricter/source/__init__.py +0 -0
  177. {python_constricter-0.4.5 → python_constricter-0.4.6}/constricter/source/annotations.py +0 -0
  178. {python_constricter-0.4.5 → python_constricter-0.4.6}/constricter/source/concrete.py +0 -0
  179. {python_constricter-0.4.5 → python_constricter-0.4.6}/constricter/source/decorators.py +0 -0
  180. {python_constricter-0.4.5 → python_constricter-0.4.6}/constricter/source/flow.py +0 -0
  181. {python_constricter-0.4.5 → python_constricter-0.4.6}/constricter/source/inert.py +0 -0
  182. {python_constricter-0.4.5 → python_constricter-0.4.6}/constricter/source/keys.py +0 -0
  183. {python_constricter-0.4.5 → python_constricter-0.4.6}/constricter/source/parsed.py +0 -0
  184. {python_constricter-0.4.5 → python_constricter-0.4.6}/constricter/source/quoted.py +0 -0
  185. {python_constricter-0.4.5 → python_constricter-0.4.6}/constricter/source/usable.py +0 -0
  186. {python_constricter-0.4.5 → python_constricter-0.4.6}/constricter/traced.py +0 -0
  187. {python_constricter-0.4.5 → python_constricter-0.4.6}/hatch_build.py +0 -0
  188. {python_constricter-0.4.5 → python_constricter-0.4.6}/mypyc.txt +0 -0
  189. {python_constricter-0.4.5 → python_constricter-0.4.6}/stdlib_tables/__init__.py +0 -0
  190. {python_constricter-0.4.5 → python_constricter-0.4.6}/stdlib_tables/__main__.py +0 -0
  191. {python_constricter-0.4.5 → python_constricter-0.4.6}/stdlib_tables/accepting.py +0 -0
  192. {python_constricter-0.4.5 → python_constricter-0.4.6}/stdlib_tables/configured.py +0 -0
  193. {python_constricter-0.4.5 → python_constricter-0.4.6}/stdlib_tables/elements.py +0 -0
  194. {python_constricter-0.4.5 → python_constricter-0.4.6}/stdlib_tables/forms.py +0 -0
  195. {python_constricter-0.4.5 → python_constricter-0.4.6}/stdlib_tables/generate.py +0 -0
  196. {python_constricter-0.4.5 → python_constricter-0.4.6}/stdlib_tables/overloads.py +0 -0
  197. {python_constricter-0.4.5 → python_constricter-0.4.6}/stdlib_tables/partial.json +0 -0
  198. {python_constricter-0.4.5 → python_constricter-0.4.6}/stdlib_tables/reading.py +0 -0
  199. {python_constricter-0.4.5 → python_constricter-0.4.6}/stdlib_tables/shed.py +0 -0
  200. {python_constricter-0.4.5 → python_constricter-0.4.6}/stdlib_tables/stubs.py +0 -0
  201. {python_constricter-0.4.5 → python_constricter-0.4.6}/stdlib_tables/templates.py +0 -0
  202. {python_constricter-0.4.5 → python_constricter-0.4.6}/stdlib_tables/written.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: python-constricter
3
- Version: 0.4.5
3
+ Version: 0.4.6
4
4
  Import-Name: constricter
5
5
  Summary: Lint rules: every local variable is typed where it's first bound. A flake8 plugin, a pylint plugin and a standalone CLI.
6
6
  Author: Ivy Duggan
@@ -278,7 +278,9 @@ and `--show-fixes` lists each fix and how its value decided it, and after `--fix
278
278
  `--infer-with basedpyright` (or `ty`, or `pyrefly`, or several: `basedpyright,ty`; each installed
279
279
  alongside) asks those type checkers for what `--fix` can't type itself, as guesses;
280
280
  `--infer-from FILE` takes the types a run bound each name to, recorded by
281
- `python -m constricter.trace -m pytest`, the same way. The full list is in
281
+ `python -m constricter.trace -m pytest`, the same way; `python -m constricter.trace --check -m pytest`
282
+ holds the run's values to the annotations already written, and lists those that differ. The full
283
+ list is in
282
284
  [docs/FIXES.md](https://github.com/ivylikethevine/python-constricter/blob/main/docs/FIXES.md).
283
285
 
284
286
  ### Installing and running
@@ -251,7 +251,9 @@ and `--show-fixes` lists each fix and how its value decided it, and after `--fix
251
251
  `--infer-with basedpyright` (or `ty`, or `pyrefly`, or several: `basedpyright,ty`; each installed
252
252
  alongside) asks those type checkers for what `--fix` can't type itself, as guesses;
253
253
  `--infer-from FILE` takes the types a run bound each name to, recorded by
254
- `python -m constricter.trace -m pytest`, the same way. The full list is in
254
+ `python -m constricter.trace -m pytest`, the same way; `python -m constricter.trace --check -m pytest`
255
+ holds the run's values to the annotations already written, and lists those that differ. The full
256
+ list is in
255
257
  [docs/FIXES.md](https://github.com/ivylikethevine/python-constricter/blob/main/docs/FIXES.md).
256
258
 
257
259
  ### Installing and running
@@ -1,3 +1,3 @@
1
1
  """The version this was built as, from its git tag (written by the build, not tracked)."""
2
2
 
3
- __version__ = "0.4.5"
3
+ __version__ = "0.4.6"
@@ -190,7 +190,7 @@ def _start(files: Mapping[Path, str], checkers: Sequence["Checker"]) -> None:
190
190
  for checker in checkers:
191
191
  # None for no files: its heap is set as its first server starts.
192
192
  if wanted := checker.wanted(files):
193
- checker.share(wanted)
193
+ checker.share(wanted, sum(len(text) for text in files.values()))
194
194
  starting += [checker] * (wanted - len(checker.servers))
195
195
  if not starting:
196
196
  return
@@ -252,15 +252,17 @@ class Checker: # pylint: disable=too-many-instance-attributes
252
252
  self.abandoned: set[Path] = set() # the files a server hung on twice: never asked about again
253
253
  self.environment: dict[str, str] | None = None # its servers', where their heap is capped (`share`)
254
254
 
255
- def share(self, servers: int) -> None:
255
+ def share(self, servers: int, size: int) -> None:
256
256
  """Cap each server's heap at its share of the memory, as the first starts, where they run on Node.
257
257
 
258
- Of `servers`' share, a tenth is left for what isn't the heap; never under a server's own
259
- (`Server.memory`). Past the cap, basedpyright empties its caches, and else exits: restarted
260
- then, its files asked about alone (`_alone`).
258
+ Of `servers`' share, a tenth is left for what isn't the heap; never under what one server
259
+ takes for files of `size` bytes together (`Server.memory`, and `per_byte` for each). Past
260
+ the cap, basedpyright empties its caches, and else exits: restarted then, its files asked
261
+ about alone (`_alone`).
261
262
  """
262
263
  if self.server.node and self.environment is None:
263
- heap: int = max(self.server.memory, self.memory // servers * _HEAP // _WHOLE) >> 20
264
+ one: int = self.server.memory + self.server.per_byte * size
265
+ heap: int = max(one, self.memory // servers * _HEAP // _WHOLE) >> 20
264
266
  given: str = os.environ.get(_NODE_OPTIONS, "")
265
267
  self.environment = {**os.environ, _NODE_OPTIONS: f"{given} --max-old-space-size={heap}".strip()}
266
268
 
@@ -4,7 +4,8 @@ A file's hints rest on the whole program the checker reads, so a round's are kep
4
4
  they rest on (`key`): the checker and its build (see `remembered.build`), the text of every file
5
5
  asked about, the workspace's settings files (`pyproject.toml`, `pyrightconfig.json`, ...), the
6
6
  installed distributions of the environments a checker may read (the interpreter's, `VIRTUAL_ENV`'s
7
- and the workspace's own `.venv`), and the code here that asks and reads. Not a file of the
7
+ and the workspace's own `.venv`), the interpreters first on `PATH` (the one basedpyright asks for
8
+ its packages), and the code here that asks and reads. Not a file of the
8
9
  workspace's that isn't asked about: walking a tree costs as much as a round can save, and a
9
10
  project's files are asked about together. The first round of a project at the
10
11
  same commit asks again only when one of those changed; a later round's texts are `--fix`'s, so it's
@@ -19,6 +20,7 @@ import contextlib
19
20
  import hashlib
20
21
  import json
21
22
  import os
23
+ import shutil
22
24
  import time
23
25
  from collections.abc import Iterable, Mapping, Sequence
24
26
  from pathlib import Path
@@ -36,6 +38,7 @@ _SETTINGS: Final = frozenset(
36
38
  )
37
39
  _LOCAL_ENVIRONMENT: Final = ".venv"
38
40
  _VARIABLES: Final = ("VIRTUAL_ENV", "CONDA_PREFIX", "PYTHONPATH")
41
+ _INTERPRETERS: Final = ("python3", "python") # what a checker with none named starts, to ask for its packages
39
42
  _SUFFIX: Final = ".json"
40
43
  _WHERE: Final = ":" # between a hint's line and column, in an entry
41
44
  # One file's hints as an entry holds them: by `line:column`, the text and the edits' text and imports.
@@ -58,6 +61,7 @@ def key(checker: str, command: Sequence[str], root: Path, files: Mapping[Path, s
58
61
  """
59
62
  build: str = remembered.build(checker, Path(command[0]))
60
63
  texts: list[str] = [checker, *command, build, *(os.environ.get(name, "") for name in _VARIABLES)]
64
+ texts += [shutil.which(name) or "" for name in _INTERPRETERS]
61
65
  # The code that asks and reads them, `edits` the one that writes what the store keeps.
62
66
  parts: list[bytes] = [
63
67
  Path(cast("str", code.__file__)).read_bytes() for code in (connection, protocol, edits)
@@ -12,7 +12,7 @@ from constricter import notebook
12
12
 
13
13
  # Skipped in a directory walk unless `--exclude` says otherwise: hidden directories, and common
14
14
  # tool/vendor ones. Merged with `exclude`'s globs (matched per directory name), not replaced by them.
15
- _DEFAULT_EXCLUDES: Final = (".*", "__pycache__", "node_modules", "venv", "site-packages", "build", "dist")
15
+ DEFAULT_EXCLUDES: Final = (".*", "__pycache__", "node_modules", "venv", "site-packages", "build", "dist")
16
16
  STDIN: Final = Path("-")
17
17
  _KINDS: Final = ("*.py", f"*{notebook.SUFFIX}") # the files a directory walk finds
18
18
 
@@ -36,7 +36,7 @@ def python_files(
36
36
  ) -> Iterator[Path]:
37
37
  """Find the files to check.
38
38
 
39
- A directory walk skips `_DEFAULT_EXCLUDES` and `exclude`'s globs by directory name, and `exclude`
39
+ A directory walk skips `DEFAULT_EXCLUDES` and `exclude`'s globs by directory name, and `exclude`
40
40
  by whole path or file name; a file named directly is checked regardless. With `tracked`, a
41
41
  directory in a git checkout has only what git tracks there or would (`_listed`), so nothing its
42
42
  `.gitignore` files name.
@@ -45,7 +45,7 @@ def python_files(
45
45
  Each file given, and each `*.py` under each directory given.
46
46
 
47
47
  """
48
- globs: tuple[str, ...] = (*_DEFAULT_EXCLUDES, *exclude)
48
+ globs: tuple[str, ...] = (*DEFAULT_EXCLUDES, *exclude)
49
49
  path: Path
50
50
  found: Path
51
51
  for path in paths:
@@ -106,7 +106,9 @@ def _imports_read(modules: project.Index, path: Path, run: FileRun) -> bool:
106
106
  """Check whether a round of `--fix` imported a checked file's class whose members the file reads.
107
107
 
108
108
  What's read of them had no type while the file didn't spell the class (`f: TextIO`, from the
109
- standard-library tables, then `f.encoding`, on a corpus that checks `typing.py`).
109
+ standard-library tables, then `f.encoding`, on a corpus that checks `typing.py`). Or a name only
110
+ the file's own stub imported, for type checking too: the stub's types naming it had none in the
111
+ file's own check till then (`crossed.binds_stubbed`).
110
112
 
111
113
  Returns:
112
114
  Whether it did.
@@ -114,7 +116,14 @@ def _imports_read(modules: project.Index, path: Path, run: FileRun) -> bool:
114
116
  """
115
117
  return _changed(path, run) and any(
116
118
  isinstance(made.offence.edit, Fix)
117
- and crossed.reads_imported(modules, path, made.offence.edit.imports)
119
+ and (
120
+ crossed.reads_imported(modules, path, made.offence.edit.imports)
121
+ or crossed.binds_stubbed(
122
+ modules,
123
+ path,
124
+ (*made.offence.edit.imports, *made.offence.edit.guarded),
125
+ )
126
+ )
118
127
  for made in cast("CheckRun", run).made
119
128
  )
120
129
 
@@ -21,7 +21,7 @@ from constricter.source import parsed
21
21
 
22
22
  if TYPE_CHECKING: # slow to import, and only needed for many files
23
23
  from concurrent.futures import Future, ProcessPoolExecutor
24
- from multiprocessing.context import DefaultContext
24
+ from multiprocessing.context import BaseContext
25
25
 
26
26
  # A worker's answers, one per file of its share: what it read (to index), and what it found.
27
27
  _Reading: TypeAlias = "Future[list[project.Module | None]]"
@@ -237,11 +237,11 @@ def _preload() -> None:
237
237
  would import constricter itself as it starts. Once the server runs, this changes nothing; a
238
238
  forked worker has the parent's imports, and a spawned one imports its own whatever this says.
239
239
  """
240
- get_context: Callable[[], DefaultContext] = cast(
241
- "Callable[[], DefaultContext]",
240
+ get_context: Callable[[], BaseContext] = cast(
241
+ "Callable[[], BaseContext]",
242
242
  importlib.import_module("multiprocessing").get_context,
243
243
  )
244
- context: DefaultContext = get_context()
244
+ context: BaseContext = get_context()
245
245
  if context.get_start_method() == _FORKSERVER:
246
246
  context.set_forkserver_preload(_PRELOADED)
247
247
 
@@ -386,6 +386,16 @@ class LibraryNames(NamedTuple):
386
386
  written: frozenset[str] = frozenset()
387
387
 
388
388
 
389
+ class Echo(NamedTuple):
390
+ """The parameter a method returns as it's given: its call is what's passed for it (see `echoed`).
391
+
392
+ `position`: its place among a call's positional arguments, `None` for a keyword-only one.
393
+ """
394
+
395
+ position: int | None
396
+ name: str
397
+
398
+
389
399
  class Returned(NamedTuple):
390
400
  """Return types read from unannotated functions' own `return` statements (see `returned`).
391
401
 
@@ -394,13 +404,15 @@ class Returned(NamedTuple):
394
404
  whose `return`s are themselves guesses, what they rest on (`FIX_KINDS`), which its calls do too.
395
405
  `attributes`: its classes' unannotated instance attributes typed by their every `self.x = value`,
396
406
  by class (guesses: a subclass or outside code may assign one too); a guessed value's origins are
397
- in `guesses` as `C.x`.
407
+ in `guesses` as `C.x`. `echoes`: its classes' methods whose every `return` gives one parameter
408
+ as it's given, by class (see `Echo`).
398
409
  """
399
410
 
400
411
  calls: Mapping[str, str] = MappingProxyType({})
401
412
  methods: Mapping[str, Mapping[str, str]] = MappingProxyType({})
402
413
  guesses: Mapping[str, frozenset[str]] = MappingProxyType({})
403
414
  attributes: Mapping[str, Mapping[str, str]] = MappingProxyType({})
415
+ echoes: Mapping[str, Mapping[str, Echo]] = MappingProxyType({})
404
416
 
405
417
 
406
418
  class Partial(NamedTuple):
@@ -150,7 +150,7 @@ def guarded_classes(
150
150
  catalog: Index,
151
151
  path: Path,
152
152
  found: Imported,
153
- guarded: Mapping[str, Guarded],
153
+ guarded: dict[str, Guarded],
154
154
  spelled: frozenset[str],
155
155
  ) -> Classes:
156
156
  """Add the members of the classes `guarded` names that `found` hasn't taken, as the file names them.
@@ -160,7 +160,9 @@ def guarded_classes(
160
160
  that class's methods in the same pass, not only once the import is written. And those `spelled`
161
161
  names through a module the file imports, as the types those steps give write them
162
162
  (`trio.SocketListener`, which `trio` re-exports): the file reads no such attribute until a fix
163
- writes the type, so `found` took none of them.
163
+ writes the type, so `found` took none of them. What their members' types need imported is added
164
+ to `guarded`, and is a receiver's class in turn: `line, = ax.plot(...)`, `ax` an `Axes` by an
165
+ overload, is a `Line2D` the file imports for it, and `line.get_xdata()` one of its methods.
164
166
 
165
167
  Returns:
166
168
  `found`'s classes, with theirs.
@@ -169,11 +171,8 @@ def guarded_classes(
169
171
  target: Module | None
170
172
  if (target := module_at(catalog, path)) is None:
171
173
  return found.classes
172
- fresh: dict[str, Origin] = {
173
- name: each.origin
174
- for name, each in guarded.items()
175
- if name not in found.guarded and name not in target.names and name not in found.classes.methods
176
- }
174
+ known: set[str] = {*found.guarded, *target.names, *found.classes.methods}
175
+ fresh: dict[str, Origin] = {name: each.origin for name, each in guarded.items() if name not in known}
177
176
  through: dict[str, Origin] = {}
178
177
  attributes: set[str] = set()
179
178
  each: str
@@ -188,10 +187,12 @@ def guarded_classes(
188
187
  {key: dict(each) for key, each in found.classes.attributes.items()},
189
188
  {key: dict(each) for key, each in found.classes.methods.items()},
190
189
  )
191
- if fresh:
192
- _take(catalog, target, (fresh, None), taken, dict(guarded))
193
190
  if through:
194
- _take(catalog, target, (through, frozenset(attributes)), taken, dict(guarded))
191
+ _take(catalog, target, (through, frozenset(attributes)), taken, guarded)
192
+ for _ in range(HOPS): # as `imported` follows them: each hop's classes are receivers' too
193
+ fresh = {name: each.origin for name, each in guarded.items() if name not in known}
194
+ _take(catalog, target, (fresh, None), taken, guarded)
195
+ known.update(fresh)
195
196
  return Classes(taken.attributes, taken.methods)
196
197
 
197
198
 
@@ -281,6 +282,28 @@ def reads_imported(catalog: Index, path: Path, statements: Iterable[str]) -> boo
281
282
  return False
282
283
 
283
284
 
285
+ def binds_stubbed(catalog: Index, path: Path, statements: Iterable[str]) -> bool:
286
+ """Check whether `statements` import into a file a name only its own stub imported (`Module.stub_names`).
287
+
288
+ Its stub's types naming it had none in the file's own check while its source didn't bind it:
289
+ `aspect = self.get_aspect()`, declared `float | Literal["auto"]`, has one once `Literal` is imported.
290
+
291
+ Returns:
292
+ Whether they do; not for a file `catalog` doesn't have.
293
+
294
+ """
295
+ target: Module | None
296
+ if (target := module_at(catalog, path)) is None or not target.stub_names:
297
+ return False
298
+ statement: str
299
+ for statement in statements:
300
+ node: ast.stmt = ast.parse(statement).body[0]
301
+ names: list[ast.alias] = node.names if isinstance(node, ast.Import | ast.ImportFrom) else []
302
+ if any((alias.asname or alias.name).partition(".")[0] in target.stub_names for alias in names):
303
+ return True
304
+ return False
305
+
306
+
284
307
  def _written(spelled: str, attributes: frozenset[str]) -> bool:
285
308
  """Check whether a file can write a class as `spelled`: each part after its first an attribute it takes.
286
309
 
@@ -38,6 +38,7 @@ from constricter.source.declarations import (
38
38
  defaulted_type_vars,
39
39
  defined_type_vars,
40
40
  descriptors,
41
+ generic_alias_types,
41
42
  generic_classes,
42
43
  generic_members,
43
44
  generic_names,
@@ -214,6 +215,9 @@ class Module: # pylint: disable=too-many-instance-attributes
214
215
  # Those they leave bare (see `constricter.fix.index.consistent`).
215
216
  annotated: Mapping[str, tuple[str, ...]] = field(default_factory=dict[str, tuple[str, ...]])
216
217
  bare: frozenset[str] = frozenset()
218
+ # Those of `guarded` only its own stub imports (see `_own`): its stub's types are written with
219
+ # them, but its source binds none, so a fix there imports each one it writes.
220
+ stub_names: frozenset[str] = frozenset()
217
221
 
218
222
  @override
219
223
  def __getstate__(self) -> dict[str, object]:
@@ -495,11 +499,11 @@ def read(path: Path, name: str | None = None) -> Module | None:
495
499
  assigned: Counter[str] = _assigned(tree.body)
496
500
  rebound: frozenset[str] = frozenset(bound for bound, count in assigned.items() if count > 1)
497
501
  named: str = name or module_name(path)
498
- is_package: bool = path.stem == PACKAGE
499
502
  own: Tables
500
503
  names: dict[str, Origin]
501
504
  guarded: dict[str, Origin]
502
- own, names, guarded = _own(path, (source, tree), named, installed=installed)
505
+ stub_names: frozenset[str]
506
+ own, names, guarded, stub_names = _own(path, (source, tree), named, installed=installed)
503
507
  aliases: dict[str, bool] = _aliases(tree)
504
508
  defaulted: frozenset[str] = defaulted_type_vars(tree)
505
509
  type_vars: frozenset[str] = defined_type_vars(tree)
@@ -511,7 +515,7 @@ def read(path: Path, name: str | None = None) -> Module | None:
511
515
  methods=own.order.flattened(own.methods),
512
516
  type_vars=type_vars,
513
517
  guarded=guarded,
514
- stars=starred(tree, named, is_package=is_package),
518
+ stars=starred(tree, named, is_package=path.stem == PACKAGE),
515
519
  unannotated=unannotated(tree.body, passing(tree, type_vars)),
516
520
  decorated=held_back(tree.body),
517
521
  called=used.called(tree, names),
@@ -536,7 +540,7 @@ def read(path: Path, name: str | None = None) -> Module | None:
536
540
  passes=own.passes,
537
541
  aliases={alias: generic for alias, generic in aliases.items() if alias not in rebound},
538
542
  rebound=rebound,
539
- inner={} if installed else inner_origins(tree, named, is_package=is_package),
543
+ inner={} if installed else inner_origins(tree, named, is_package=path.stem == PACKAGE),
540
544
  variables=_variables(tree.body).difference(own.classes.keys()), # a frozenset: `- keys()` is a `set`
541
545
  assigned=frozenset(assigned).difference(aliases.keys(), type_vars),
542
546
  shadowed=frozenset() if installed else frozenset(names) & taken_names(tree)[1],
@@ -563,6 +567,7 @@ def read(path: Path, name: str | None = None) -> Module | None:
563
567
  annotated={} if installed else annotated.annotations(tree),
564
568
  bare=frozenset() if installed else annotated.bare(tree),
565
569
  kinds=None if installed else kinds(tree, aliases.keys() - rebound),
570
+ stub_names=stub_names,
566
571
  unawaited=frozenset(
567
572
  stmt.name
568
573
  for stmt in tree.body
@@ -577,15 +582,15 @@ def _own(
577
582
  named: str,
578
583
  *,
579
584
  installed: bool,
580
- ) -> tuple[Tables, dict[str, Origin], dict[str, Origin]]:
585
+ ) -> tuple[Tables, dict[str, Origin], dict[str, Origin], frozenset[str]]:
581
586
  """Read a module's own tables and names, a checked one's kept for its check (see `parsed.keep`).
582
587
 
583
588
  With its own stub's, where it has one (see `own_stubs.beside`): its importers read every type the stub
584
589
  declares, its check only those it can write as they are (its names', and the builtins').
585
590
 
586
591
  Returns:
587
- Its tables; what each name it binds refers to; and each name it imports for type checking
588
- alone, its stub's imports among them.
592
+ Its tables; what each name it binds refers to; each name it imports for type checking alone,
593
+ its stub's imports among them; and those of them only its stub imports.
589
594
 
590
595
  """
591
596
  source: str
@@ -597,16 +602,52 @@ def _own(
597
602
  names.update(skipped(tree, names)) # `pa = pytest.importorskip("pyarrow")`, as `import pyarrow as pa`
598
603
  guarded: dict[str, Origin] = guarded_origins(tree, named, is_package=is_package)
599
604
  if installed:
600
- return own, names, guarded
605
+ return own, names, guarded, frozenset()
601
606
  kept: Tables = own
607
+ only: frozenset[str] = frozenset()
602
608
  beside: tuple[Tables, dict[str, Origin]] | None
603
609
  if (beside := own_stubs.beside(path, named, is_package=is_package)) is not None: # `mod.pyi`, read first
604
- writable: frozenset[str] = frozenset(names).union(guarded, own.classes, BUILTINS)
605
- kept = own_stubs.stubbed(own, beside[0], lambda each: roots(each) <= writable)
610
+ kept = _spelled(own, beside[0], frozenset(names).union(guarded))
606
611
  own = own_stubs.stubbed(own, beside[0])
612
+ only = frozenset(each for each in beside[1] if each not in names and each not in guarded)
607
613
  guarded = {**{each: at for each, at in beside[1].items() if each not in names}, **guarded}
608
614
  parsed.keep(source, (tree, kept)) # for the check to take, rather than parse it and read it again
609
- return own, names, guarded
615
+ return own, names, guarded, only
616
+
617
+
618
+ def _spelled(own: Tables, stub: Tables, names: frozenset[str]) -> Tables:
619
+ """Take a stub's types a module can write as they are: by `names`, its classes and the builtins.
620
+
621
+ Returns:
622
+ The module's tables, with those (see `own_stubs.stubbed`).
623
+
624
+ """
625
+ writable: frozenset[str] = names.union(own.classes, BUILTINS)
626
+ return own_stubs.stubbed(own, stub, lambda each: roots(each) <= writable)
627
+
628
+
629
+ def checkable(path: Path, tree: ast.Module) -> Tables | None:
630
+ """Read what a module with its own stub is checked with, from a tree the index kept no tables for.
631
+
632
+ The index keeps them for the text it read (`_own`): a file checked as any other text, `--fix`'s
633
+ since, or once more as the same, would know none of its stub's types.
634
+
635
+ Returns:
636
+ Its tables with its stub's, as `_own` keeps them; `None` where it has no stub
637
+ (see `own_stubs.beside`).
638
+
639
+ """
640
+ if path.suffix != SUFFIX: # a notebook, standard input, a text with no file
641
+ return None
642
+ is_package: bool = path.stem == PACKAGE
643
+ named: str = module_name(path)
644
+ beside: tuple[Tables, dict[str, Origin]] | None
645
+ if (beside := own_stubs.beside(path, named, is_package=is_package)) is None:
646
+ return None
647
+ names: dict[str, Origin] = origins_of(tree, named, is_package=is_package)
648
+ names.update(skipped(tree, names))
649
+ guarded: dict[str, Origin] = guarded_origins(tree, named, is_package=is_package)
650
+ return _spelled(module_tables(tree), beside[0], frozenset(names).union(guarded))
610
651
 
611
652
 
612
653
  def _loose(body: Sequence[ast.stmt]) -> frozenset[str]:
@@ -770,7 +811,8 @@ def _aliases(tree: ast.Module) -> dict[str, bool]:
770
811
  """Find a module's type aliases, at its top level or under an `if` or `try` there.
771
812
 
772
813
  A name annotated `TypeAlias`, bound to a subscript or a union (`Json = dict[str, "Json"] | str`),
773
- or a `type` statement's.
814
+ a `type` statement's, or one `TypeAliasType` makes with type parameters
815
+ (`Result = TypeAliasType("Result", Accepted[T] | Declined, type_params=(T,))`), which is generic.
774
816
 
775
817
  Returns:
776
818
  Each one's name, and whether it takes type arguments: its value names one of the module's type
@@ -798,7 +840,7 @@ def _aliases(tree: ast.Module) -> dict[str, bool]:
798
840
  found[named.id] = bool(cast("object", getattr(stmt, "type_params", ())))
799
841
  case _:
800
842
  pass
801
- return found
843
+ return found | dict.fromkeys(generic_alias_types(tree), True)
802
844
 
803
845
 
804
846
  def _assigned(body: Sequence[ast.stmt]) -> Counter[str]:
@@ -55,7 +55,7 @@ def own(catalog: project.Index, path: Path) -> Own:
55
55
  origin: Origin
56
56
  for name, origin in target.guarded.items():
57
57
  generic: bool | None = _class(catalog, origin)
58
- if generic is not None and name not in target.names:
58
+ if generic is not None and name not in target.names and name not in target.stub_names:
59
59
  found[name] = Guarded(origin, None)
60
60
  if generic:
61
61
  generics.add(name)
@@ -67,6 +67,8 @@ def vetted(catalog: project.Index, path: Path, hints: tuple[Hints, ...]) -> tupl
67
67
 
68
68
  And those writing a name the file binds that a module it imports whole has a class of too (see
69
69
  `_ambiguous`); a hint showing such a name is dropped whole, since what it shows is taken first.
70
+ So is a hint writing bare a name the file binds to a module, or one its edits say is another
71
+ class than the file's (see `_misbound`).
70
72
 
71
73
  Returns:
72
74
  The hints, without them: a hint without its edit is judged by what it shows alone.
@@ -79,30 +81,61 @@ def vetted(catalog: project.Index, path: Path, hints: tuple[Hints, ...]) -> tupl
79
81
  checking: Mapping[str, Origin] = Empty() if target is None else target.guarded
80
82
  found: dict[str, _Defined | None] = {name: _defined(catalog, origin) for name, origin in checking.items()}
81
83
  guarded: dict[str, _Defined] = {name: defined for name, defined in found.items() if defined is not None}
84
+ bound: dict[str, Origin] = {} if target is None else {**target.guarded, **target.names}
82
85
  return tuple(
83
86
  _shared(
84
87
  catalog,
85
88
  module,
86
- found._replace(
87
- types={
88
- where: shown
89
- for where, shown in found.types.items()
90
- if not _ambiguous(catalog, target, shown, ())
91
- },
92
- offered={
93
- where: offered
94
- for where, offered in found.offered.items()
95
- if _sound(catalog, module, offered, found.types.get(where, ""))
96
- and not _ambiguous(catalog, target, offered.text, offered.imports)
97
- and not _ambiguous(catalog, target, found.types.get(where, ""), ())
98
- },
99
- ),
89
+ _kept(catalog, module, target, bound, found),
100
90
  guarded,
101
91
  )
102
92
  for found in hints
103
93
  )
104
94
 
105
95
 
96
+ def _kept(
97
+ catalog: project.Index,
98
+ module: tuple[str, bool],
99
+ target: project.Module | None,
100
+ bound: Mapping[str, Origin],
101
+ found: Hints,
102
+ ) -> Hints:
103
+ """Keep the hints `vetted` keeps of one checker's, and the edits it keeps of them.
104
+
105
+ `bound`: what each name the file binds at its top level is, an `if TYPE_CHECKING:` import's too.
106
+
107
+ Returns:
108
+ Them.
109
+
110
+ """
111
+ types: dict[tuple[int, int], str] = {}
112
+ misbound: set[tuple[int, int]] = set()
113
+ where: tuple[int, int]
114
+ shown: str
115
+ for where, shown in found.types.items():
116
+ edit: Offered | None = found.offered.get(where)
117
+ imports: tuple[str, ...] = () if edit is None else edit.imports
118
+ text: str = shown
119
+ if _misbound(catalog, module, bound, shown, imports):
120
+ if edit is None or _misbound(catalog, module, bound, edit.text, imports):
121
+ misbound.add(where)
122
+ continue
123
+ text = edit.text # `datetime.datetime`, where the hint shows the module `datetime`
124
+ if not _ambiguous(catalog, target, text, ()):
125
+ types[where] = text
126
+ return found._replace(
127
+ types=types,
128
+ offered={
129
+ where: offered
130
+ for where, offered in found.offered.items()
131
+ if where not in misbound
132
+ and _sound(catalog, module, offered, types.get(where, ""))
133
+ and not _ambiguous(catalog, target, offered.text, offered.imports)
134
+ and not _ambiguous(catalog, target, found.types.get(where, ""), ())
135
+ },
136
+ )
137
+
138
+
106
139
  def _shared(
107
140
  catalog: project.Index,
108
141
  module: tuple[str, bool],
@@ -289,6 +322,112 @@ def _another(catalog: project.Index, other: Origin, bound: Origin) -> bool:
289
322
  return defined is None or defined != _defined(catalog, bound)
290
323
 
291
324
 
325
+ def _misbound(
326
+ catalog: project.Index,
327
+ module: tuple[str, bool],
328
+ bound: Mapping[str, Origin],
329
+ text: str,
330
+ imports: tuple[str, ...],
331
+ ) -> bool:
332
+ """Check whether a hint's `text` writes bare a name the file binds to a module, or to another class.
333
+
334
+ A checker names a class by its bare name, whatever the file binds that name to: sphinx's
335
+ `img: Image`, `PIL.Image.Image` where the file's `Image` is the module (`from PIL import Image`),
336
+ and httpx's `resp: Response`, httpcore's class where the file's `Response` is httpx's own. Which
337
+ class it means is where its edits' `imports` import it from (see `_meant`): another than the
338
+ file's, by where the index defines each, is another class. `bound`: what each name the file binds is.
339
+
340
+ Returns:
341
+ Whether it does.
342
+
343
+ """
344
+ written: set[str] = _bare(text) & bound.keys()
345
+ if any(_whole(catalog, bound[name]) for name in written):
346
+ return True
347
+ meant: dict[str, Origin] = _meant(module, imports, written)
348
+ return any(_differs(catalog, bound[name], origin) for name, origin in meant.items())
349
+
350
+
351
+ def _bare(text: str) -> set[str]:
352
+ """Name the names a hint's `text` writes bare: not a dotted name's root (`np` in `np.ndarray`).
353
+
354
+ Returns:
355
+ Them; none for a text that doesn't parse.
356
+
357
+ """
358
+ try:
359
+ tree: ast.Expression = ast.parse(text, mode="eval")
360
+ except SyntaxError:
361
+ return set()
362
+ roots: set[int] = {id(node.value) for node in ast.walk(tree) if isinstance(node, ast.Attribute)}
363
+ return {node.id for node in ast.walk(tree) if isinstance(node, ast.Name) and id(node) not in roots}
364
+
365
+
366
+ def _whole(catalog: project.Index, origin: Origin) -> bool:
367
+ """Check whether `origin`, what a file's name is bound to, is a module: `import m`, or one the index has.
368
+
369
+ Returns:
370
+ Whether it is.
371
+
372
+ """
373
+ return origin[1] is None or f"{origin[0]}.{origin[1]}" in catalog.modules
374
+
375
+
376
+ def _meant(module: tuple[str, bool], imports: tuple[str, ...], written: set[str]) -> dict[str, Origin]:
377
+ """Read which class each of `written` is, by a hint's edits' `imports`.
378
+
379
+ A `from` import binding the name says where it's from; an `import m` says `m`'s class of the
380
+ name, whether the edit writes it through `m` or bare (`Response`, with `import httpcore._models`).
381
+
382
+ Returns:
383
+ Each name the edits say, and its class: relative to `module`, the hinted file's, made absolute.
384
+
385
+ """
386
+ if not written:
387
+ return {}
388
+ found: dict[str, Origin] = {}
389
+ statement: str
390
+ for statement in imports:
391
+ try:
392
+ node: ast.stmt = ast.parse(statement).body[0]
393
+ except SyntaxError: # from a file no import can name (`v3.0.0.c.py`)
394
+ continue
395
+ alias: ast.alias
396
+ match node:
397
+ case ast.ImportFrom(names=[alias]) if (alias.asname or alias.name) in written:
398
+ origin: str = absolute(module[0], node.module, node.level, is_package=module[1])
399
+ found[alias.asname or alias.name] = (origin, alias.name)
400
+ case ast.Import(names=[alias]) if alias.asname is None:
401
+ found.update({name: (alias.name, name) for name in written if name not in found})
402
+ case _:
403
+ pass
404
+ return found
405
+
406
+
407
+ def _differs(catalog: project.Index, bound: Origin, meant: Origin) -> bool:
408
+ """Check whether `meant`, the class a hint's edits import, isn't `bound`, what the file's name is.
409
+
410
+ It isn't where the file's name is the module that defines it, or where the index defines each
411
+ elsewhere. A class the index doesn't have isn't told from the file's, unless the file's is a
412
+ checked file's own and it's the standard library's (`pathlib.Path`, where the file has a `Path`).
413
+
414
+ Returns:
415
+ Whether it isn't.
416
+
417
+ """
418
+ if bound == meant:
419
+ return False
420
+ if f"{bound[0]}.{bound[1]}" == meant[0]:
421
+ return True
422
+ found: tuple[project.Module, str] | None
423
+ if (found := project.type_definition(catalog.modules, bound)) is None:
424
+ return False
425
+ defined: _Defined | None
426
+ if (defined := _defined(catalog, meant)) is not None:
427
+ return defined != (found[0].name, found[1])
428
+ return not found[0].installed and _class(catalog, meant) is not None
429
+
430
+
292
431
  def _private(catalog: project.Index, name: str) -> bool:
293
432
  """Check whether module `name` is an installed package's private one.
294
433