inline-snapshot 0.36.1__tar.gz → 0.36.2__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 (240) hide show
  1. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/.github/workflows/ci.yml +8 -8
  2. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/CHANGELOG.md +7 -0
  3. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/PKG-INFO +1 -1
  4. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/benchmarks/README.md +3 -0
  5. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/benchmarks/_fixtures.py +1 -1
  6. inline_snapshot-0.36.2/benchmarks/bench_snapshot.py +144 -0
  7. inline_snapshot-0.36.2/known_issues/pydantic-ai-report-memory.md +167 -0
  8. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/src/inline_snapshot/_external/_external.py +87 -41
  9. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/src/inline_snapshot/_external/_external_base.py +40 -19
  10. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/src/inline_snapshot/_external/_external_file.py +57 -33
  11. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/src/inline_snapshot/_external/_outsource.py +2 -2
  12. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/src/inline_snapshot/_get_snapshot_value.py +2 -2
  13. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/src/inline_snapshot/_global_state.py +2 -2
  14. inline_snapshot-0.36.2/src/inline_snapshot/_inline_snapshot.py +87 -0
  15. inline_snapshot-0.36.2/src/inline_snapshot/_snapshot/_operation/__init__.py +1 -0
  16. inline_snapshot-0.36.2/src/inline_snapshot/_snapshot/_operation/base.py +23 -0
  17. inline_snapshot-0.36.2/src/inline_snapshot/_snapshot/_operation/collection_operation.py +122 -0
  18. inline_snapshot-0.36.2/src/inline_snapshot/_snapshot/_operation/dict_operation.py +134 -0
  19. inline_snapshot-0.36.2/src/inline_snapshot/_snapshot/_operation/eq_operation.py +86 -0
  20. inline_snapshot-0.36.2/src/inline_snapshot/_snapshot/_operation/min_max_operation.py +144 -0
  21. inline_snapshot-0.36.2/src/inline_snapshot/_snapshot/snapshot_data.py +53 -0
  22. inline_snapshot-0.36.2/src/inline_snapshot/_snapshot/snapshot_value.py +204 -0
  23. inline_snapshot-0.36.1/src/inline_snapshot/_snapshot/undecided_value.py → inline_snapshot-0.36.2/src/inline_snapshot/_snapshot/value_conversion.py +0 -60
  24. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/src/inline_snapshot/_snapshot_arg.py +83 -52
  25. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/src/inline_snapshot/_snapshot_session.py +6 -15
  26. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/src/inline_snapshot/_types.py +4 -14
  27. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/src/inline_snapshot/fix_pytest_diff.py +3 -3
  28. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/src/inline_snapshot/pydantic_fix.py +2 -2
  29. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/src/inline_snapshot/version.py +1 -1
  30. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/tests/adapter/test_dataclass.py +1 -0
  31. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/tests/adapter/test_sequence.py +1 -0
  32. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/tests/conftest.py +26 -14
  33. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/tests/external/test_external.py +40 -2
  34. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/tests/external/test_external_file.py +26 -3
  35. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/tests/test_benchmark_fixtures.py +20 -3
  36. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/tests/test_change.py +14 -0
  37. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/tests/test_change_collection_error.py +10 -14
  38. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/tests/test_get_snapshot_value.py +0 -1
  39. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/tests/test_inline_snapshot.py +114 -4
  40. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/tests/test_snapshot_arg.py +60 -2
  41. inline_snapshot-0.36.2/tests/test_snapshot_arg_unmanaged.py +41 -0
  42. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/tests/test_without_node.py +4 -2
  43. inline_snapshot-0.36.1/benchmarks/bench_snapshot.py +0 -62
  44. inline_snapshot-0.36.1/src/inline_snapshot/_inline_snapshot.py +0 -137
  45. inline_snapshot-0.36.1/src/inline_snapshot/_snapshot/collection_value.py +0 -110
  46. inline_snapshot-0.36.1/src/inline_snapshot/_snapshot/dict_value.py +0 -107
  47. inline_snapshot-0.36.1/src/inline_snapshot/_snapshot/eq_value.py +0 -72
  48. inline_snapshot-0.36.1/src/inline_snapshot/_snapshot/generic_value.py +0 -132
  49. inline_snapshot-0.36.1/src/inline_snapshot/_snapshot/min_max_value.py +0 -135
  50. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/.github/FUNDING.yml +0 -0
  51. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/.github/actions/setup/action.yml +0 -0
  52. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/.github/copilot-instructions.md +0 -0
  53. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/.github/pull_request_template.md +0 -0
  54. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/.github/workflows/benchmark-report.yml +0 -0
  55. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/.github/workflows/benchmarks.yml +0 -0
  56. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/.github/workflows/cog.yml +0 -0
  57. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/.github/workflows/deploy_development_docs.yml +0 -0
  58. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/.github/workflows/docs.yml +0 -0
  59. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/.github/workflows/test_docs.yml +0 -0
  60. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/.gitignore +0 -0
  61. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/.inline-snapshot/external/.gitignore +0 -0
  62. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/.inline-snapshot/external/ef2d127de37b942baad06145e54b0c619a1f22327b2ebbcfbec78f5564afe39d.json +0 -0
  63. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/.inline-snapshot/files_using_external.txt +0 -0
  64. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/.pre-commit-config.yaml +0 -0
  65. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/AGENTS.md +0 -0
  66. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/CONTRIBUTING.md +0 -0
  67. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/LICENSE +0 -0
  68. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/MANIFEST.in +0 -0
  69. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/README.md +0 -0
  70. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/asv.conf.json +0 -0
  71. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/benchmarks/__init__.py +0 -0
  72. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/benchmarks/_workloads.py +0 -0
  73. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/benchmarks/bench_pytest.py +0 -0
  74. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/changelog.d/.gitkeep +0 -0
  75. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/conftest.py +0 -0
  76. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/docs/alternatives.md +0 -0
  77. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/docs/assets/code_generation/string-update.rich.svg +0 -0
  78. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/docs/assets/create_fix.mp4 +0 -0
  79. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/docs/assets/favicon.png +0 -0
  80. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/docs/assets/favicon.svg +0 -0
  81. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/docs/assets/introduction/show-error.rich.svg +0 -0
  82. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/docs/assets/introduction/simple-example-changed.rich.svg +0 -0
  83. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/docs/assets/introduction/simple-example.rich.svg +0 -0
  84. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/docs/assets/logo.svg +0 -0
  85. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/docs/assets/logo_orig.svg +0 -0
  86. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/docs/assets/pycharm_run.mp4 +0 -0
  87. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/docs/assets/pytest/create-fix-trim-update.rich.svg +0 -0
  88. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/docs/assets/pytest/report.rich.svg +0 -0
  89. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/docs/assets/pytest/review.rich.svg +0 -0
  90. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/docs/assets/pytest/short-report.rich.svg +0 -0
  91. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/docs/assets/readme/example-snapshot-arg.rich.svg +0 -0
  92. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/docs/assets/readme/example-snapshot.rich.svg +0 -0
  93. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/docs/categories.md +0 -0
  94. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/docs/changelog.md +0 -0
  95. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/docs/cmp_snapshot.md +0 -0
  96. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/docs/code_generation.md +0 -0
  97. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/docs/configuration.md +0 -0
  98. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/docs/contributing.md +0 -0
  99. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/docs/customize_repr.md +0 -0
  100. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/docs/eq_snapshot.md +0 -0
  101. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/docs/external/assets/register-is-array-for.rich.svg +0 -0
  102. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/docs/external/assets/register-numberset-format.rich.svg +0 -0
  103. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/docs/external/external.md +0 -0
  104. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/docs/external/external_file.md +0 -0
  105. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/docs/external/outsource.md +0 -0
  106. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/docs/external/register_format.md +0 -0
  107. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/docs/extra.md +0 -0
  108. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/docs/fix_assert.md +0 -0
  109. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/docs/get_snapshot_value.md +0 -0
  110. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/docs/getitem_snapshot.md +0 -0
  111. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/docs/howto/parametrize.md +0 -0
  112. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/docs/in_snapshot.md +0 -0
  113. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/docs/index.md +0 -0
  114. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/docs/insiders.md +0 -0
  115. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/docs/limitations.md +0 -0
  116. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/docs/plugin.md +0 -0
  117. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/docs/plugins/pyproject.toml +0 -0
  118. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/docs/plugins/replace_url.py +0 -0
  119. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/docs/pycharm.md +0 -0
  120. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/docs/pytest.md +0 -0
  121. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/docs/snapshot_arg.md +0 -0
  122. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/docs/styles/extra.css +0 -0
  123. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/docs/testing.md +0 -0
  124. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/docs/theme/main.html +0 -0
  125. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/docs/third_party.md +0 -0
  126. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/docs/types.md +0 -0
  127. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/mkdocs.yml +0 -0
  128. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/pyproject.toml +0 -0
  129. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/redeploy_docs.sh +0 -0
  130. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/scripts/clean_changelog_fragments.py +0 -0
  131. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/scripts/replace_words.py +0 -0
  132. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/scripts/test_downstream.py +0 -0
  133. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/src/inline_snapshot/__init__.py +0 -0
  134. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/src/inline_snapshot/_adapter_context.py +0 -0
  135. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/src/inline_snapshot/_align.py +0 -0
  136. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/src/inline_snapshot/_change.py +0 -0
  137. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/src/inline_snapshot/_code_repr.py +0 -0
  138. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/src/inline_snapshot/_compare_context.py +0 -0
  139. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/src/inline_snapshot/_config.py +0 -0
  140. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/src/inline_snapshot/_customize/__init__.py +0 -0
  141. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/src/inline_snapshot/_customize/_builder.py +0 -0
  142. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/src/inline_snapshot/_customize/_custom.py +0 -0
  143. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/src/inline_snapshot/_customize/_custom_call.py +0 -0
  144. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/src/inline_snapshot/_customize/_custom_code.py +0 -0
  145. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/src/inline_snapshot/_customize/_custom_dict.py +0 -0
  146. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/src/inline_snapshot/_customize/_custom_external.py +0 -0
  147. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/src/inline_snapshot/_customize/_custom_sequence.py +0 -0
  148. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/src/inline_snapshot/_customize/_custom_undefined.py +0 -0
  149. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/src/inline_snapshot/_customize/_custom_unmanaged.py +0 -0
  150. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/src/inline_snapshot/_customize/_uncustomized.py +0 -0
  151. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/src/inline_snapshot/_exceptions.py +0 -0
  152. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/src/inline_snapshot/_external/__init__.py +0 -0
  153. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/src/inline_snapshot/_external/_diff.py +0 -0
  154. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/src/inline_snapshot/_external/_external_location.py +0 -0
  155. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/src/inline_snapshot/_external/_find_external.py +0 -0
  156. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/src/inline_snapshot/_external/_format/__init__.py +0 -0
  157. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/src/inline_snapshot/_external/_format/_binary.py +0 -0
  158. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/src/inline_snapshot/_external/_format/_json.py +0 -0
  159. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/src/inline_snapshot/_external/_format/_protocol.py +0 -0
  160. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/src/inline_snapshot/_external/_format/_rich_svg.py +0 -0
  161. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/src/inline_snapshot/_external/_format/_text.py +0 -0
  162. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/src/inline_snapshot/_external/_storage/__init__.py +0 -0
  163. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/src/inline_snapshot/_external/_storage/_hash.py +0 -0
  164. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/src/inline_snapshot/_external/_storage/_protocol.py +0 -0
  165. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/src/inline_snapshot/_external/_storage/_uuid.py +0 -0
  166. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/src/inline_snapshot/_external/_tracked_files.py +0 -0
  167. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/src/inline_snapshot/_fix_assert.py +0 -0
  168. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/src/inline_snapshot/_flags.py +0 -0
  169. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/src/inline_snapshot/_format.py +0 -0
  170. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/src/inline_snapshot/_generator_utils.py +0 -0
  171. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/src/inline_snapshot/_is.py +0 -0
  172. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/src/inline_snapshot/_new_adapter.py +0 -0
  173. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/src/inline_snapshot/_problems.py +0 -0
  174. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/src/inline_snapshot/_rewrite_code.py +0 -0
  175. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/src/inline_snapshot/_sentinels.py +0 -0
  176. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/src/inline_snapshot/_snapshot/__init__.py +0 -0
  177. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/src/inline_snapshot/_source_file.py +0 -0
  178. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/src/inline_snapshot/_unmanaged.py +0 -0
  179. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/src/inline_snapshot/_utils.py +0 -0
  180. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/src/inline_snapshot/extra.py +0 -0
  181. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/src/inline_snapshot/fix_pytest_cache.py +0 -0
  182. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/src/inline_snapshot/plugin/__init__.py +0 -0
  183. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/src/inline_snapshot/plugin/_default_plugin.py +0 -0
  184. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/src/inline_snapshot/plugin/_spec.py +0 -0
  185. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/src/inline_snapshot/py.typed +0 -0
  186. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/src/inline_snapshot/pytest_plugin.py +0 -0
  187. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/src/inline_snapshot/syntax_warnings.py +0 -0
  188. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/src/inline_snapshot/testing/__init__.py +0 -0
  189. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/src/inline_snapshot/testing/_example.py +0 -0
  190. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/src/inline_snapshot/testing/_terminal_svg.py +0 -0
  191. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/test-repos.json +0 -0
  192. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/testing/generate_tests.py +0 -0
  193. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/tests/__init__.py +0 -0
  194. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/tests/adapter/test_call.py +0 -0
  195. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/tests/adapter/test_change_types.py +0 -0
  196. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/tests/adapter/test_dict.py +0 -0
  197. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/tests/adapter/test_general.py +0 -0
  198. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/tests/adapter/test_namedtuple.py +0 -0
  199. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/tests/external/__init__.py +0 -0
  200. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/tests/external/storage/test_generic.py +0 -0
  201. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/tests/external/storage/test_hash.py +0 -0
  202. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/tests/external/storage/test_uuid.py +0 -0
  203. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/tests/external/test_external_location.py +0 -0
  204. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/tests/external/test_formats.py +0 -0
  205. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/tests/external/test_module_name.py +0 -0
  206. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/tests/test_align.py +0 -0
  207. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/tests/test_builder.py +0 -0
  208. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/tests/test_ci.py +0 -0
  209. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/tests/test_code_repr.py +0 -0
  210. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/tests/test_config.py +0 -0
  211. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/tests/test_customize.py +0 -0
  212. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/tests/test_datetime_timezone.py +0 -0
  213. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/tests/test_dirty_equals.py +0 -0
  214. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/tests/test_docs.py +0 -0
  215. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/tests/test_encoding.py +0 -0
  216. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/tests/test_example.py +0 -0
  217. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/tests/test_formatting.py +0 -0
  218. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/tests/test_fstring.py +0 -0
  219. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/tests/test_hasrepr.py +0 -0
  220. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/tests/test_is.py +0 -0
  221. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/tests/test_preserve_values.py +0 -0
  222. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/tests/test_pydantic.py +0 -0
  223. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/tests/test_pypy.py +0 -0
  224. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/tests/test_pytest_diff_fix.py +0 -0
  225. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/tests/test_pytest_plugin.py +0 -0
  226. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/tests/test_pytester.py +0 -0
  227. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/tests/test_raises.py +0 -0
  228. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/tests/test_rewrite_code.py +0 -0
  229. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/tests/test_skip_updates.py +0 -0
  230. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/tests/test_snapshot_value.py +0 -0
  231. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/tests/test_storage.py +0 -0
  232. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/tests/test_string.py +0 -0
  233. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/tests/test_transformed.py +0 -0
  234. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/tests/test_typing.py +0 -0
  235. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/tests/test_update.py +0 -0
  236. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/tests/test_warns.py +0 -0
  237. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/tests/test_xdist.py +0 -0
  238. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/tests/test_xfail.py +0 -0
  239. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/tests/utils.py +0 -0
  240. {inline_snapshot-0.36.1 → inline_snapshot-0.36.2}/uv.lock +0 -0
@@ -24,7 +24,7 @@ jobs:
24
24
  strategy:
25
25
  matrix:
26
26
  python-version: ['3.9', '3.10', '3.11', '3.12', '3.13', '3.14', pypy3.11]
27
- os: [ubuntu-latest, windows-2022, macos-14]
27
+ os: [ubuntu-latest, windows-2022, macos-15]
28
28
  extra_deps: ['"--with=pydantic<2"', '"--with=pydantic>2"']
29
29
  is_insider:
30
30
  - ${{contains(github.repository, '-insiders/')}}
@@ -33,20 +33,20 @@ jobs:
33
33
  - is_insider: true
34
34
  os: windows-2022
35
35
  - is_insider: true
36
- os: macos-14
36
+ os: macos-15
37
37
 
38
38
  - python-version: '3.14'
39
39
  extra_deps: '"--with=pydantic<2"'
40
40
 
41
- - os: macos-14
41
+ - os: macos-15
42
42
  python-version: '3.10'
43
- - os: macos-14
43
+ - os: macos-15
44
44
  python-version: '3.11'
45
- - os: macos-14
45
+ - os: macos-15
46
46
  python-version: '3.12'
47
- - os: macos-14
47
+ - os: macos-15
48
48
  python-version: '3.13'
49
- - os: macos-14
49
+ - os: macos-15
50
50
  python-version: pypy3.11
51
51
 
52
52
  - os: windows-2022
@@ -118,7 +118,7 @@ jobs:
118
118
  uvx coverage html --skip-covered --skip-empty
119
119
 
120
120
  # Report and write to summary.
121
- uvx coverage report --format=markdown --skip-covered --skip-empty -m >> $GITHUB_STEP_SUMMARY
121
+ uvx coverage report --format=markdown --skip-covered --skip-empty -m >> "$GITHUB_STEP_SUMMARY"
122
122
  uvx coverage report --skip-covered --skip-empty -m > htmlcov/report.txt
123
123
 
124
124
  # Report again and fail if under 100%.
@@ -1,4 +1,11 @@
1
1
 
2
+ <a id='changelog-0.36.2'></a>
3
+ # v0.36.2 — 2026-11-09
4
+
5
+ ## Fixed
6
+
7
+ - Reduce memory use in active snapshot modes by eagerly recording snapshot changes without retaining completed test frames until the final report.
8
+
2
9
  <a id='changelog-0.36.1'></a>
3
10
  # v0.36.1 — 2026-10-12
4
11
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: inline-snapshot
3
- Version: 0.36.1
3
+ Version: 0.36.2
4
4
  Summary: golden master/snapshot/approval testing library which puts the values right into your source code
5
5
  Project-URL: Changelog, https://15r10nk.github.io/inline-snapshot/latest/changelog/
6
6
  Project-URL: Discussions, https://github.com/15r10nk/inline-snapshots/discussions
@@ -37,6 +37,9 @@ ignored by Git.
37
37
  timing. This is a cold start of snapshot processing, not of the OS file cache.
38
38
  - **Five pytest sessions:** active, disabled, create, fix, and update. Each runs
39
39
  ten tests in a fresh process, including startup, reporting, and source edits.
40
+ - **Retained snapshot state:** the recursive size of the session snapshot registry
41
+ after evaluating 100 distinct active scalar call sites. Each call frame has an
42
+ unrelated 100 kB local payload, exposing accidental frame retention.
40
43
 
41
44
  Workloads live in `_workloads.py`; `_fixtures.py` creates distinct call sites.
42
45
  Keep expected values inline and increment `SUITE_VERSION` in `_fixtures.py`
@@ -11,7 +11,7 @@ import sys
11
11
  from ._workloads import comparison_template
12
12
  from ._workloads import session_template
13
13
 
14
- SUITE_VERSION = "3"
14
+ SUITE_VERSION = "4"
15
15
  BATCH_SIZE = 10
16
16
  CASES = [
17
17
  "scalar",
@@ -0,0 +1,144 @@
1
+ """First-use comparisons in a fresh process for every measured batch."""
2
+
3
+ import sys
4
+ import types
5
+ from pathlib import Path
6
+ from tempfile import TemporaryDirectory
7
+ from textwrap import dedent
8
+
9
+ from ._fixtures import CASES
10
+ from ._fixtures import SUITE_VERSION
11
+
12
+
13
+ def retained_size(root):
14
+ """Return the recursive size of state owned by ``root``.
15
+
16
+ Frames expose their local values separately from ordinary instance state.
17
+ Classes, functions, and modules are shared rather than owned and are not
18
+ followed.
19
+ """
20
+ pending = [root]
21
+ seen = set()
22
+ total = 0
23
+ while pending:
24
+ value = pending.pop()
25
+ if id(value) in seen:
26
+ continue
27
+ seen.add(id(value))
28
+ total += sys.getsizeof(value)
29
+
30
+ if isinstance(value, types.FrameType):
31
+ pending.extend(value.f_locals.values())
32
+ elif isinstance(value, dict):
33
+ pending.extend(value.keys())
34
+ pending.extend(value.values())
35
+ elif isinstance(value, (list, tuple, set, frozenset)):
36
+ pending.extend(value)
37
+ elif not isinstance(
38
+ value,
39
+ (
40
+ str,
41
+ bytes,
42
+ int,
43
+ float,
44
+ complex,
45
+ type,
46
+ types.FunctionType,
47
+ types.MethodType,
48
+ types.ModuleType,
49
+ ),
50
+ ):
51
+ pending.extend(vars(value).values() if hasattr(value, "__dict__") else ())
52
+ return total
53
+
54
+
55
+ class Comparison:
56
+ version = SUITE_VERSION
57
+ params = [CASES, ["active", "disabled", "plain"]]
58
+ param_names = ["case", "mode"]
59
+ # Each timeraw sample starts a new process and executes the batch once.
60
+ number = 1
61
+ warmup_time = 0
62
+ repeat = 10
63
+ rounds = 2
64
+ timeout = 300
65
+
66
+ def timeraw_comparison(self, case, mode):
67
+ setup = dedent(f"""\
68
+ import atexit
69
+ import sys
70
+ from pathlib import Path
71
+ from tempfile import TemporaryDirectory
72
+
73
+ sys.path.insert(0, {str(Path(__file__).resolve().parent.parent)!r})
74
+ from benchmarks._fixtures import BATCH_SIZE, load_module, snapshot_functions, source
75
+ from inline_snapshot._global_state import snapshot_env
76
+
77
+ directory = TemporaryDirectory()
78
+ atexit.register(directory.cleanup)
79
+ path = Path(directory.name) / "fixture.py"
80
+ path.write_text(source({case!r}), encoding="utf-8")
81
+ module = load_module(path)
82
+ context = snapshot_env()
83
+ state = context.__enter__()
84
+ atexit.register(context.__exit__, None, None, None)
85
+ state.active = {mode != 'disabled'}
86
+ functions = (
87
+ [module.plain] * BATCH_SIZE
88
+ if {mode == 'plain'} else snapshot_functions(module)
89
+ )
90
+ """)
91
+ statement = dedent(f"""\
92
+ for function in functions:
93
+ function()
94
+ assert not state.missing_values and not state.incorrect_values
95
+ assert len(state.snapshots) == {'BATCH_SIZE' if mode == 'active' else '0'}
96
+ """)
97
+ return statement, setup
98
+
99
+
100
+ class ModelComparison(Comparison):
101
+ """Optional adapter workload, kept as a separate benchmark family."""
102
+
103
+ params = [["models"], ["active", "disabled", "plain"]]
104
+
105
+
106
+ class RetainedSnapshotState:
107
+ """Memory retained by the session registry after snapshot evaluation."""
108
+
109
+ version = SUITE_VERSION
110
+ params = ["scalar"]
111
+ param_names = ["case"]
112
+ number = 1
113
+ repeat = 3
114
+ timeout = 300
115
+ unit = "byte"
116
+ call_site_count = 100
117
+ frame_payload_size = 100_000
118
+
119
+ def setup(self, case):
120
+ from inline_snapshot._global_state import snapshot_env
121
+
122
+ from ._fixtures import load_module
123
+ from ._fixtures import source
124
+
125
+ self.directory = TemporaryDirectory()
126
+ path = Path(self.directory.name) / "fixture.py"
127
+ workload = source(case, count=self.call_site_count)
128
+ workload = workload.replace(
129
+ "):\n",
130
+ f"):\n frame_payload = bytearray({self.frame_payload_size})\n",
131
+ )
132
+ path.write_text(workload, encoding="utf-8")
133
+ self.module = load_module(path)
134
+ self.context = snapshot_env()
135
+ self.state = self.context.__enter__()
136
+ for index in range(self.call_site_count):
137
+ getattr(self.module, f"test_snapshot_{index}")()
138
+
139
+ def track_retained_snapshots(self, case):
140
+ return retained_size(self.state.snapshots)
141
+
142
+ def teardown(self, case):
143
+ self.context.__exit__(None, None, None)
144
+ self.directory.cleanup()
@@ -0,0 +1,167 @@
1
+ # Pydantic AI `--inline-snapshot=report` memory investigation
2
+
3
+ ## Summary
4
+
5
+ Pydantic AI used approximately 2.1 GiB of peak memory with
6
+ `inline-snapshot==0.36.1` in report mode, compared with approximately 1.0 GiB
7
+ when inline-snapshot was disabled.
8
+
9
+ The `SnapshotData` prototype reduces peak memory to approximately 1.8 GiB when
10
+ used with the local optimized `executing` checkout. A pre-report RSS probe using
11
+ the released `executing` measured approximately 1.6 GiB after garbage
12
+ collection.
13
+
14
+ The prototype removes the original large direct frame-retention path. Most of
15
+ the remaining difference from disabled mode is source and AST state retained by
16
+ `executing`. A smaller number of `AdapterContext` objects remain because their
17
+ returned `SnapshotValue` facades are themselves still live.
18
+
19
+ ## Benchmark results
20
+
21
+ The original peak-memory measurements were:
22
+
23
+ | Mode | Wall time | Peak memory |
24
+ |---|---:|---:|
25
+ | `0.36.1`, report, released `executing` | 2.3 min | 2.1 GiB |
26
+ | prototype, report, editable `executing` | 2.3 min | 1.8 GiB |
27
+ | `0.36.1`, disabled | 1.9 min | 1.0 GiB |
28
+
29
+ The editable `executing` branch lazily constructs its line-to-node and qualname
30
+ indexes. This explains its memory and runtime improvement, but it still retains
31
+ the base parsed source and AST cache.
32
+
33
+ ## Pre-report object measurements
34
+
35
+ A temporary `pytest_sessionfinish(tryfirst=True)` hook measured state after a
36
+ full Pydantic AI test run and `gc.collect()`, immediately before
37
+ inline-snapshot generated its report.
38
+
39
+ | Measurement | Prototype report | Prototype disabled |
40
+ |---|---:|---:|
41
+ | Current RSS | 1,608 MiB | 1,000 MiB |
42
+ | GC-tracked objects | 5,079,094 | 2,126,212 |
43
+ | Snapshot registry entries | 4,359 | 0 |
44
+ | Selected operations | 4,269 | 0 |
45
+ | Unique `executing.Source` objects | 159 | 0 |
46
+ | AST nodes | 954,193 | 37,165 |
47
+ | Frames | 1,576 | 227 |
48
+ | `AdapterContext` objects | 577 | 0 |
49
+
50
+ All snapshot registry entries in report mode were `SnapshotData` objects.
51
+
52
+ One unrelated Pydantic AI terminal-width test failed consistently under Python
53
+ 3.15 during these runs. Measurements were still collected at the intended
54
+ pre-report hook.
55
+
56
+ ## Why source and AST state remains
57
+
58
+ `executing.Source.__source_cache_with_lines` caches a `Source` for every parsed
59
+ file. Each source contains its parsed AST. `executing` also adds parent links to
60
+ AST nodes, making a file's tree a connected object graph.
61
+
62
+ The snapshot state can retain this graph through two mechanisms:
63
+
64
+ 1. Eagerly materialized `ChangeBase` objects contain a `SourceFile` and AST
65
+ nodes needed to render and apply the final report.
66
+ 2. `CustomCode._repr_str` can contain an AST node. That node's parent links
67
+ connect it to the rest of the file tree.
68
+
69
+ `SnapshotData` itself stores only the source filename as a `Path`; it does not
70
+ retain a `SourceFile` merely to identify the call site at session end.
71
+
72
+ The local `executing` changes avoid eagerly constructing some secondary indexes,
73
+ but do not change the lifetime of the source cache or base AST.
74
+
75
+ This source/AST state is therefore the dominant remaining difference between
76
+ report and disabled mode.
77
+
78
+ ## Attribution of the 577 retained `AdapterContext` objects
79
+
80
+ All 577 contexts were accounted for.
81
+
82
+ ### 532 contexts: retained snapshot facades
83
+
84
+ 532 contexts were owned directly by live `SnapshotValue` objects. These
85
+ facades were retained by module-level pytest parameter definitions and similar
86
+ case objects. For example:
87
+
88
+ ```python
89
+ @pytest.mark.parametrize(
90
+ "value,expected",
91
+ [
92
+ (0, snapshot("0")),
93
+ (0.0, snapshot("0.000")),
94
+ ],
95
+ )
96
+ def test_render(value, expected):
97
+ assert render(value) == expected
98
+ ```
99
+
100
+ Pytest retains parameter tuples, dictionaries and case objects for the entire
101
+ session. The ownership probe found the facades retained by:
102
+
103
+ - 255 dictionaries;
104
+ - 245 tuples;
105
+ - persistent test case objects such as `Case`, `Cell`, `ModelCase`, and
106
+ `ResumedContentCase`.
107
+
108
+ As a focused confirmation, `tests/evals/test_render_numbers.py` produced 66
109
+ contexts. That module contains 66 snapshots in parameter definitions, and the
110
+ probe found exactly 66 live facades owned by 66 parameter tuples and 66 pytest
111
+ dictionaries.
112
+
113
+ This behavior follows the current lifetime rule: a facade's `AdapterContext`
114
+ remains alive while the object returned by `snapshot()` remains alive.
115
+
116
+ ### 45 contexts: nested snapshot facades
117
+
118
+ The other 45 contexts were reachable from the global snapshot registry through
119
+ the following path:
120
+
121
+ ```text
122
+ SnapshotData._new_value
123
+ → CustomDict
124
+ → CustomUnmanaged
125
+ → dirty_equals.IsJson.expected_value
126
+ → SnapshotValue._context
127
+ ```
128
+
129
+ These are nested matcher expressions such as:
130
+
131
+ ```python
132
+ IsJson(snapshot(...))
133
+ ```
134
+
135
+ The outer snapshot retains the unmanaged `IsJson` matcher, and that matcher
136
+ retains the nested snapshot facade. The 45 contexts retain 29 distinct frames
137
+ because multiple nested snapshots originate from the same frame.
138
+
139
+ This is registry-mediated retention, but it also follows the facade lifetime
140
+ rule: the nested snapshot result remains part of a retained value.
141
+
142
+ ## Synthetic frame-retention benchmark
143
+
144
+ The inline-snapshot ASV suite now includes a retained-state benchmark with 100
145
+ distinct active scalar call sites. Every call frame contains an unrelated
146
+ 100 kB local payload.
147
+
148
+ | Revision | Recursively retained state |
149
+ |---|---:|
150
+ | `0.36.1` / `main` | 10,395,316 bytes |
151
+ | `SnapshotData` prototype | 351,244 bytes |
152
+
153
+ This is an approximately 97% reduction and confirms that ordinary completed
154
+ call frames are no longer retained through the session registry.
155
+
156
+ ## Conclusions
157
+
158
+ - The `SnapshotData` architecture fixes the main direct frame-retention issue.
159
+ - The 577 remaining contexts are not an unexplained cache: 532 belong to
160
+ intentionally live facades and 45 belong to nested facades inside retained
161
+ matcher values.
162
+ - Most remaining memory is associated with the 159 parsed source files and
163
+ roughly 954,000 live AST nodes.
164
+ - Reducing the remaining memory will require addressing source/AST lifetime or
165
+ replacing retained AST references with compact source-location or rendered
166
+ representations. It is separate from the original completed-frame retention
167
+ fix.
@@ -1,6 +1,9 @@
1
1
  from __future__ import annotations
2
2
 
3
3
  import ast
4
+ import inspect
5
+ from pathlib import Path
6
+ from types import CodeType
4
7
  from types import FrameType
5
8
 
6
9
  from inline_snapshot._adapter_context import AdapterContext
@@ -8,50 +11,91 @@ from inline_snapshot._change import CallArg
8
11
  from inline_snapshot._change import Replace
9
12
  from inline_snapshot._exceptions import UsageError
10
13
  from inline_snapshot._external._external_base import ExternalBase
14
+ from inline_snapshot._external._external_base import ExternalBaseData
11
15
  from inline_snapshot._external._format._protocol import get_format_handler
12
16
  from inline_snapshot._external._format._protocol import get_format_handler_from_suffix
13
17
  from inline_snapshot._external._storage._protocol import StorageLookupError
14
18
  from inline_snapshot._global_state import state
15
- from inline_snapshot._inline_snapshot import create_snapshot
16
- from inline_snapshot._types import SnapshotRefBase
19
+ from inline_snapshot._types import snapshot_key
17
20
  from inline_snapshot._unmanaged import declare_unmanaged
18
21
 
19
22
  from ._external_location import ExternalLocation
20
23
 
21
24
 
22
25
  def external(name: str | None = None):
23
- return create_snapshot(External, name)
26
+ frame = inspect.currentframe()
27
+ assert frame is not None
28
+ frame = frame.f_back
29
+ assert frame is not None
30
+
31
+ if not state().active:
32
+ return External.create_raw(name, frame)
33
+
34
+ key = snapshot_key(frame)
35
+ context = AdapterContext(frame)
36
+ data = state().snapshots.get(key)
37
+ if not isinstance(data, ExternalData):
38
+ data = ExternalData.from_name(name, context, frame.f_code)
39
+ state().snapshots[key] = data
40
+
41
+ return External(context, data)
42
+
43
+
44
+ class ExternalData(ExternalBaseData):
45
+ """Frame-free state shared by evaluations of one external call site."""
46
+
47
+ original_location: ExternalLocation
48
+ location: ExternalLocation
49
+
50
+ def __init__(
51
+ self,
52
+ *,
53
+ original_name: str | None,
54
+ original_location: ExternalLocation,
55
+ location: ExternalLocation,
56
+ filename: Path,
57
+ code: CodeType,
58
+ ) -> None:
59
+ super().__init__(
60
+ original_location=original_location,
61
+ location=location,
62
+ )
63
+ self.original_name = original_name
64
+ self.filename = filename
65
+ # Prevent reuse of the id(frame.f_code) component in snapshot_key().
66
+ self.code = code
67
+
68
+ @classmethod
69
+ def from_name(
70
+ cls, name: str | None, context: AdapterContext, code: CodeType
71
+ ) -> ExternalData:
72
+ location = ExternalLocation.from_name(name, context=context)
73
+ return cls(
74
+ original_name=name,
75
+ original_location=ExternalLocation.from_name(name, context=context),
76
+ location=location,
77
+ filename=Path(context.file.filename),
78
+ code=code,
79
+ )
80
+
81
+ def __repr__(self) -> str:
82
+ return f'external("{self.original_location.to_str()}")'
24
83
 
25
84
 
26
85
  @declare_unmanaged
27
- class External(ExternalBase, SnapshotRefBase):
28
- _original_location: ExternalLocation
29
- _location: ExternalLocation
86
+ class External(ExternalBase):
30
87
  _context: AdapterContext
31
88
 
32
- def __init__(self, name: str, frame: FrameType):
89
+ def __init__(self, context: AdapterContext, data: ExternalData):
33
90
  """External objects are used to move some data outside the source code.
34
91
  You should not instantiate this class directly, but by using `external()` instead.
35
92
 
36
93
  The location where the external data is stored can be defined by the storage protocol.
37
94
  The format is defined by the suffix.
38
-
39
- Parameters:
40
- name: the name of the external stored object which has the form "<hash>:<name>.<suffix>".
41
95
  """
42
96
 
43
- self._context = AdapterContext(frame)
44
- self._original_name = name
45
-
46
- self._location = ExternalLocation.from_name(name, context=self._context)
47
- self._original_location = ExternalLocation.from_name(
48
- name, context=self._context
49
- )
50
-
51
- super().__init__()
52
-
53
- def result(self):
54
- return self
97
+ self._context = context
98
+ self._data = data
55
99
 
56
100
  @classmethod
57
101
  def create_raw(cls, obj, frame: FrameType):
@@ -62,7 +106,7 @@ class External(ExternalBase, SnapshotRefBase):
62
106
 
63
107
  @property
64
108
  def _format(self):
65
- return get_format_handler_from_suffix(self._location.suffix or "")
109
+ return get_format_handler_from_suffix(self._data.location.suffix or "")
66
110
 
67
111
  def _changes(self):
68
112
 
@@ -71,9 +115,9 @@ class External(ExternalBase, SnapshotRefBase):
71
115
  if node is not None:
72
116
  assert isinstance(node, ast.Call)
73
117
 
74
- new_name = self._location.to_str()
75
- if new_name != self._original_name:
76
- if self._original_name is None:
118
+ new_name = self._data.location.to_str()
119
+ if new_name != self._data.original_name:
120
+ if self._data.original_name is None:
77
121
  yield CallArg(
78
122
  "create",
79
123
  self._context.file,
@@ -86,8 +130,8 @@ class External(ExternalBase, SnapshotRefBase):
86
130
  else:
87
131
  yield Replace(
88
132
  (
89
- ("fix" if self._original_location.stem else "create")
90
- if self._tmp_file is not None
133
+ ("fix" if self._data.original_location.stem else "create")
134
+ if self._data.tmp_file is not None
91
135
  else "update"
92
136
  ),
93
137
  self._context.file,
@@ -98,7 +142,7 @@ class External(ExternalBase, SnapshotRefBase):
98
142
  yield from super()._changes()
99
143
 
100
144
  def _is_empty(self):
101
- return not self._original_location.stem
145
+ return not self._data.original_location.stem
102
146
 
103
147
  def __repr__(self):
104
148
  """Returns the representation of the external object.
@@ -107,34 +151,36 @@ class External(ExternalBase, SnapshotRefBase):
107
151
  [config](configuration.md).
108
152
  """
109
153
 
110
- return f'external("{self._original_location.to_str()}")'
154
+ return f'external("{self._data.original_location.to_str()}")'
111
155
 
112
156
  @property
113
157
  def storage(self):
114
- storage_name = self._location.storage or state().default_storage
158
+ storage_name = self._data.location.storage or state().default_storage
115
159
 
116
160
  return state().all_storages[storage_name]
117
161
 
118
162
  def _assign(self, other):
119
- format = get_format_handler(other, self._location.suffix)
163
+ format = get_format_handler(other, self._data.location.suffix)
120
164
 
121
- if not self._location.suffix:
122
- self._location.suffix = format.suffix
165
+ if not self._data.location.suffix:
166
+ self._data.location.suffix = format.suffix
123
167
 
124
- self._tmp_file = state().new_tmp_path(self._location.suffix)
168
+ self._data.tmp_file = state().new_tmp_path(self._data.location.suffix)
125
169
 
126
- format.encode(other, self._tmp_file)
127
- self._location = self.storage.new_location(self._location, self._tmp_file)
170
+ format.encode(other, self._data.tmp_file)
171
+ self._data.location = self.storage.new_location(
172
+ self._data.location, self._data.tmp_file
173
+ )
128
174
 
129
175
  def _load_value(self, which):
130
176
  if which == "new":
131
- if self._tmp_file:
132
- format = get_format_handler_from_suffix(self._location.suffix)
133
- return format.decode(self._tmp_file)
177
+ if self._data.tmp_file:
178
+ format = get_format_handler_from_suffix(self._data.location.suffix)
179
+ return format.decode(self._data.tmp_file)
134
180
  else:
135
181
  raise StorageLookupError("no new value", files=[])
136
182
  if which == "old":
137
- location = self._original_location
183
+ location = self._data.original_location
138
184
  if not location.exists():
139
185
  raise StorageLookupError("no old value", files=[])
140
186