gyomu-python-analysis 0.2.0__tar.gz → 0.3.0__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 (131) hide show
  1. {gyomu_python_analysis-0.2.0 → gyomu_python_analysis-0.3.0}/.gitignore +10 -0
  2. {gyomu_python_analysis-0.2.0 → gyomu_python_analysis-0.3.0}/PKG-INFO +2 -2
  3. {gyomu_python_analysis-0.2.0 → gyomu_python_analysis-0.3.0}/pyproject.toml +1 -1
  4. gyomu_python_analysis-0.3.0/python_analysis_test_support/fixtures/src/analysis/docstring/15-custom-list-section.py +7 -0
  5. gyomu_python_analysis-0.3.0/python_analysis_test_support/fixtures/src/analysis/symbol/variable.py +33 -0
  6. gyomu_python_analysis-0.3.0/python_analysis_test_support/helpers.py +341 -0
  7. gyomu_python_analysis-0.3.0/python_analysis_test_support/monorepo_fixtures/packages/project_a/pyproject.toml +4 -0
  8. gyomu_python_analysis-0.3.0/python_analysis_test_support/monorepo_fixtures/packages/project_a/src/project_a/module.py +1 -0
  9. gyomu_python_analysis-0.3.0/python_analysis_test_support/monorepo_fixtures/packages/project_b/pyproject.toml +4 -0
  10. gyomu_python_analysis-0.3.0/python_analysis_test_support/monorepo_fixtures/packages/project_b/src/project_b/module.py +1 -0
  11. gyomu_python_analysis-0.3.0/python_analysis_test_support/monorepo_fixtures/pyproject.toml +9 -0
  12. {gyomu_python_analysis-0.2.0 → gyomu_python_analysis-0.3.0}/src/gyomu_python_analysis/analysis/analyzers/cls.py +51 -24
  13. {gyomu_python_analysis-0.2.0 → gyomu_python_analysis-0.3.0}/src/gyomu_python_analysis/analysis/analyzers/decorator.py +9 -4
  14. {gyomu_python_analysis-0.2.0 → gyomu_python_analysis-0.3.0}/src/gyomu_python_analysis/analysis/analyzers/docstring.py +89 -26
  15. {gyomu_python_analysis-0.2.0 → gyomu_python_analysis-0.3.0}/src/gyomu_python_analysis/analysis/analyzers/expression/expr.py +115 -59
  16. {gyomu_python_analysis-0.2.0 → gyomu_python_analysis-0.3.0}/src/gyomu_python_analysis/analysis/analyzers/functions.py +12 -6
  17. {gyomu_python_analysis-0.2.0 → gyomu_python_analysis-0.3.0}/src/gyomu_python_analysis/analysis/analyzers/imports.py +1 -1
  18. {gyomu_python_analysis-0.2.0 → gyomu_python_analysis-0.3.0}/src/gyomu_python_analysis/analysis/analyzers/internal/common.py +11 -2
  19. {gyomu_python_analysis-0.2.0 → gyomu_python_analysis-0.3.0}/src/gyomu_python_analysis/analysis/analyzers/pydantic.py +30 -0
  20. {gyomu_python_analysis-0.2.0 → gyomu_python_analysis-0.3.0}/src/gyomu_python_analysis/analysis/analyzers/type_alias.py +9 -3
  21. {gyomu_python_analysis-0.2.0 → gyomu_python_analysis-0.3.0}/src/gyomu_python_analysis/analysis/analyzers/types.py +6 -3
  22. gyomu_python_analysis-0.3.0/src/gyomu_python_analysis/analysis/analyzers/variables.py +60 -0
  23. {gyomu_python_analysis-0.2.0 → gyomu_python_analysis-0.3.0}/src/gyomu_python_analysis/analysis/extract/symbols.py +8 -13
  24. {gyomu_python_analysis-0.2.0 → gyomu_python_analysis-0.3.0}/src/gyomu_python_analysis/analysis/get_module.py +16 -5
  25. gyomu_python_analysis-0.3.0/src/gyomu_python_analysis/analysis/initialize.py +189 -0
  26. {gyomu_python_analysis-0.2.0 → gyomu_python_analysis-0.3.0}/src/gyomu_python_analysis/analysis/load_file_context.py +6 -2
  27. {gyomu_python_analysis-0.2.0 → gyomu_python_analysis-0.3.0}/src/gyomu_python_analysis/analysis/load_module.py +10 -3
  28. gyomu_python_analysis-0.3.0/src/gyomu_python_analysis/analysis/workspace.py +235 -0
  29. {gyomu_python_analysis-0.2.0 → gyomu_python_analysis-0.3.0}/src/gyomu_python_analysis/error/analysis.py +3 -1
  30. {gyomu_python_analysis-0.2.0 → gyomu_python_analysis-0.3.0}/src/gyomu_python_analysis/path/conversion.py +15 -0
  31. {gyomu_python_analysis-0.2.0 → gyomu_python_analysis-0.3.0}/src/gyomu_python_analysis/project/context.py +17 -2
  32. gyomu_python_analysis-0.3.0/src/gyomu_python_analysis/project/workspace.py +41 -0
  33. gyomu_python_analysis-0.3.0/tests/unit/analysis/analyzers/internal/__init__.py +0 -0
  34. {gyomu_python_analysis-0.2.0 → gyomu_python_analysis-0.3.0}/tests/unit/analysis/analyzers/test_analyze_dependency.py +2 -0
  35. {gyomu_python_analysis-0.2.0 → gyomu_python_analysis-0.3.0}/tests/unit/analysis/analyzers/test_analyze_docstring.py +33 -0
  36. {gyomu_python_analysis-0.2.0 → gyomu_python_analysis-0.3.0}/tests/unit/analysis/analyzers/test_analyze_types.py +3 -0
  37. {gyomu_python_analysis-0.2.0 → gyomu_python_analysis-0.3.0}/tests/unit/analysis/analyzers/test_analyze_variable.py +35 -4
  38. {gyomu_python_analysis-0.2.0 → gyomu_python_analysis-0.3.0}/tests/unit/analysis/test_get_module.py +24 -25
  39. gyomu_python_analysis-0.3.0/tests/unit/analysis/test_initialize.py +275 -0
  40. {gyomu_python_analysis-0.2.0 → gyomu_python_analysis-0.3.0}/tests/unit/analysis/test_load_file.py +14 -3
  41. {gyomu_python_analysis-0.2.0 → gyomu_python_analysis-0.3.0}/tests/unit/analysis/test_load_module.py +20 -9
  42. {gyomu_python_analysis-0.2.0 → gyomu_python_analysis-0.3.0}/tests/unit/analysis/test_metadata.py +2 -1
  43. gyomu_python_analysis-0.3.0/tests/unit/analysis/test_workspace.py +326 -0
  44. gyomu_python_analysis-0.3.0/tests/unit/path/__init__.py +0 -0
  45. {gyomu_python_analysis-0.2.0 → gyomu_python_analysis-0.3.0}/tests/unit/path/test_conversion.py +40 -0
  46. gyomu_python_analysis-0.2.0/python_analysis_test_support/fixtures/src/analysis/symbol/variable.py +0 -8
  47. gyomu_python_analysis-0.2.0/python_analysis_test_support/helpers.py +0 -341
  48. gyomu_python_analysis-0.2.0/src/gyomu_python_analysis/analysis/analyzers/variables.py +0 -22
  49. gyomu_python_analysis-0.2.0/src/gyomu_python_analysis/error/update.py +0 -32
  50. {gyomu_python_analysis-0.2.0 → gyomu_python_analysis-0.3.0}/README.md +0 -0
  51. {gyomu_python_analysis-0.2.0 → gyomu_python_analysis-0.3.0}/experiments/griffe_analysis.py +0 -0
  52. {gyomu_python_analysis-0.2.0 → gyomu_python_analysis-0.3.0}/experiments/griffe_dump.py +0 -0
  53. {gyomu_python_analysis-0.2.0 → gyomu_python_analysis-0.3.0}/experiments/sample/__init__.py +0 -0
  54. {gyomu_python_analysis-0.2.0 → gyomu_python_analysis-0.3.0}/experiments/sample/user.py +0 -0
  55. {gyomu_python_analysis-0.2.0 → gyomu_python_analysis-0.3.0}/experiments/sample.py +0 -0
  56. {gyomu_python_analysis-0.2.0 → gyomu_python_analysis-0.3.0}/python_analysis_test_support/__init__.py +0 -0
  57. {gyomu_python_analysis-0.2.0 → gyomu_python_analysis-0.3.0}/python_analysis_test_support/fixtures/pyproject.toml +0 -0
  58. {gyomu_python_analysis-0.2.0 → gyomu_python_analysis-0.3.0}/python_analysis_test_support/fixtures/src/__init__.py +0 -0
  59. {gyomu_python_analysis-0.2.0 → gyomu_python_analysis-0.3.0}/python_analysis_test_support/fixtures/src/analysis/__init__.py +0 -0
  60. {gyomu_python_analysis-0.2.0 → gyomu_python_analysis-0.3.0}/python_analysis_test_support/fixtures/src/analysis/docstring/01-simple.py +0 -0
  61. {gyomu_python_analysis-0.2.0 → gyomu_python_analysis-0.3.0}/python_analysis_test_support/fixtures/src/analysis/docstring/02-args.py +0 -0
  62. {gyomu_python_analysis-0.2.0 → gyomu_python_analysis-0.3.0}/python_analysis_test_support/fixtures/src/analysis/docstring/03-typed-return.py +0 -0
  63. {gyomu_python_analysis-0.2.0 → gyomu_python_analysis-0.3.0}/python_analysis_test_support/fixtures/src/analysis/docstring/04-raises.py +0 -0
  64. {gyomu_python_analysis-0.2.0 → gyomu_python_analysis-0.3.0}/python_analysis_test_support/fixtures/src/analysis/docstring/05-examples.py +0 -0
  65. {gyomu_python_analysis-0.2.0 → gyomu_python_analysis-0.3.0}/python_analysis_test_support/fixtures/src/analysis/docstring/06-notes.py +0 -0
  66. {gyomu_python_analysis-0.2.0 → gyomu_python_analysis-0.3.0}/python_analysis_test_support/fixtures/src/analysis/docstring/07-complex.py +0 -0
  67. {gyomu_python_analysis-0.2.0 → gyomu_python_analysis-0.3.0}/python_analysis_test_support/fixtures/src/analysis/docstring/08-gyomu-context.py +0 -0
  68. {gyomu_python_analysis-0.2.0 → gyomu_python_analysis-0.3.0}/python_analysis_test_support/fixtures/src/analysis/docstring/09-custom-section.py +0 -0
  69. {gyomu_python_analysis-0.2.0 → gyomu_python_analysis-0.3.0}/python_analysis_test_support/fixtures/src/analysis/docstring/10-edge-cases.py +0 -0
  70. {gyomu_python_analysis-0.2.0 → gyomu_python_analysis-0.3.0}/python_analysis_test_support/fixtures/src/analysis/docstring/11-custom-and-gyomu-context.py +0 -0
  71. {gyomu_python_analysis-0.2.0 → gyomu_python_analysis-0.3.0}/python_analysis_test_support/fixtures/src/analysis/docstring/12-module.py +0 -0
  72. {gyomu_python_analysis-0.2.0 → gyomu_python_analysis-0.3.0}/python_analysis_test_support/fixtures/src/analysis/docstring/13-class.py +0 -0
  73. {gyomu_python_analysis-0.2.0 → gyomu_python_analysis-0.3.0}/python_analysis_test_support/fixtures/src/analysis/docstring/14-variable.py +0 -0
  74. {gyomu_python_analysis-0.2.0 → gyomu_python_analysis-0.3.0}/python_analysis_test_support/fixtures/src/analysis/docstring/__init__.py +0 -0
  75. {gyomu_python_analysis-0.2.0 → gyomu_python_analysis-0.3.0}/python_analysis_test_support/fixtures/src/analysis/import/__init__.py +0 -0
  76. {gyomu_python_analysis-0.2.0 → gyomu_python_analysis-0.3.0}/python_analysis_test_support/fixtures/src/analysis/import/all.py +0 -0
  77. {gyomu_python_analysis-0.2.0 → gyomu_python_analysis-0.3.0}/python_analysis_test_support/fixtures/src/analysis/import/all2.py +0 -0
  78. {gyomu_python_analysis-0.2.0 → gyomu_python_analysis-0.3.0}/python_analysis_test_support/fixtures/src/analysis/import/imports.py +0 -0
  79. {gyomu_python_analysis-0.2.0 → gyomu_python_analysis-0.3.0}/python_analysis_test_support/fixtures/src/analysis/import/relative.py +0 -0
  80. {gyomu_python_analysis-0.2.0 → gyomu_python_analysis-0.3.0}/python_analysis_test_support/fixtures/src/analysis/shared.py +0 -0
  81. {gyomu_python_analysis-0.2.0 → gyomu_python_analysis-0.3.0}/python_analysis_test_support/fixtures/src/analysis/symbol/__init__.py +0 -0
  82. {gyomu_python_analysis-0.2.0 → gyomu_python_analysis-0.3.0}/python_analysis_test_support/fixtures/src/analysis/symbol/call.py +0 -0
  83. {gyomu_python_analysis-0.2.0 → gyomu_python_analysis-0.3.0}/python_analysis_test_support/fixtures/src/analysis/symbol/callable.py +0 -0
  84. {gyomu_python_analysis-0.2.0 → gyomu_python_analysis-0.3.0}/python_analysis_test_support/fixtures/src/analysis/symbol/classes.py +0 -0
  85. {gyomu_python_analysis-0.2.0 → gyomu_python_analysis-0.3.0}/python_analysis_test_support/fixtures/src/analysis/symbol/decorator.py +0 -0
  86. {gyomu_python_analysis-0.2.0 → gyomu_python_analysis-0.3.0}/python_analysis_test_support/fixtures/src/analysis/symbol/functions.py +0 -0
  87. {gyomu_python_analysis-0.2.0 → gyomu_python_analysis-0.3.0}/python_analysis_test_support/fixtures/src/analysis/symbol/generics.py +0 -0
  88. {gyomu_python_analysis-0.2.0 → gyomu_python_analysis-0.3.0}/python_analysis_test_support/fixtures/src/analysis/symbol/location.py +0 -0
  89. {gyomu_python_analysis-0.2.0 → gyomu_python_analysis-0.3.0}/python_analysis_test_support/fixtures/src/analysis/symbol/pydantic.py +0 -0
  90. {gyomu_python_analysis-0.2.0 → gyomu_python_analysis-0.3.0}/python_analysis_test_support/fixtures/src/analysis/symbol/type_alias.py +0 -0
  91. {gyomu_python_analysis-0.2.0 → gyomu_python_analysis-0.3.0}/python_analysis_test_support/fixtures/src/analysis/symbol/types.py +0 -0
  92. {gyomu_python_analysis-0.2.0 → gyomu_python_analysis-0.3.0}/python_analysis_test_support/fixtures/src/analysis/types/__init__.py +0 -0
  93. {gyomu_python_analysis-0.2.0 → gyomu_python_analysis-0.3.0}/python_analysis_test_support/fixtures/src/analysis/types/name.py +0 -0
  94. {gyomu_python_analysis-0.2.0/src/gyomu_python_analysis → gyomu_python_analysis-0.3.0/python_analysis_test_support/monorepo_fixtures/packages/project_a/src/project_a}/__init__.py +0 -0
  95. {gyomu_python_analysis-0.2.0/src/gyomu_python_analysis/analysis → gyomu_python_analysis-0.3.0/python_analysis_test_support/monorepo_fixtures/packages/project_b/src/project_b}/__init__.py +0 -0
  96. {gyomu_python_analysis-0.2.0 → gyomu_python_analysis-0.3.0}/roadmap.md +0 -0
  97. {gyomu_python_analysis-0.2.0/src/gyomu_python_analysis/analysis/analyzers → gyomu_python_analysis-0.3.0/src/gyomu_python_analysis}/__init__.py +0 -0
  98. {gyomu_python_analysis-0.2.0/src/gyomu_python_analysis/analysis/analyzers/expression → gyomu_python_analysis-0.3.0/src/gyomu_python_analysis/analysis}/__init__.py +0 -0
  99. {gyomu_python_analysis-0.2.0/src/gyomu_python_analysis/analysis/analyzers/internal → gyomu_python_analysis-0.3.0/src/gyomu_python_analysis/analysis/analyzers}/__init__.py +0 -0
  100. {gyomu_python_analysis-0.2.0 → gyomu_python_analysis-0.3.0}/src/gyomu_python_analysis/analysis/analyzers/context.py +0 -0
  101. {gyomu_python_analysis-0.2.0 → gyomu_python_analysis-0.3.0}/src/gyomu_python_analysis/analysis/analyzers/dependency.py +0 -0
  102. {gyomu_python_analysis-0.2.0/src/gyomu_python_analysis/analysis/extract → gyomu_python_analysis-0.3.0/src/gyomu_python_analysis/analysis/analyzers/expression}/__init__.py +0 -0
  103. {gyomu_python_analysis-0.2.0 → gyomu_python_analysis-0.3.0}/src/gyomu_python_analysis/analysis/analyzers/expression/name.py +0 -0
  104. {gyomu_python_analysis-0.2.0/src/gyomu_python_analysis/analysis/file → gyomu_python_analysis-0.3.0/src/gyomu_python_analysis/analysis/analyzers/internal}/__init__.py +0 -0
  105. {gyomu_python_analysis-0.2.0 → gyomu_python_analysis-0.3.0}/src/gyomu_python_analysis/analysis/analyzers/internal/location.py +0 -0
  106. {gyomu_python_analysis-0.2.0 → gyomu_python_analysis-0.3.0}/src/gyomu_python_analysis/analysis/analyzers/internal/visibility.py +0 -0
  107. {gyomu_python_analysis-0.2.0/src/gyomu_python_analysis/analysis/parser → gyomu_python_analysis-0.3.0/src/gyomu_python_analysis/analysis/extract}/__init__.py +0 -0
  108. {gyomu_python_analysis-0.2.0/src/gyomu_python_analysis/error → gyomu_python_analysis-0.3.0/src/gyomu_python_analysis/analysis/file}/__init__.py +0 -0
  109. {gyomu_python_analysis-0.2.0 → gyomu_python_analysis-0.3.0}/src/gyomu_python_analysis/analysis/file/source_file_context.py +0 -0
  110. {gyomu_python_analysis-0.2.0 → gyomu_python_analysis-0.3.0}/src/gyomu_python_analysis/analysis/load.py +0 -0
  111. {gyomu_python_analysis-0.2.0 → gyomu_python_analysis-0.3.0}/src/gyomu_python_analysis/analysis/metadata.py +0 -0
  112. {gyomu_python_analysis-0.2.0/src/gyomu_python_analysis/path → gyomu_python_analysis-0.3.0/src/gyomu_python_analysis/analysis/parser}/__init__.py +0 -0
  113. {gyomu_python_analysis-0.2.0 → gyomu_python_analysis-0.3.0}/src/gyomu_python_analysis/analysis/parser/docstring.py +0 -0
  114. {gyomu_python_analysis-0.2.0/src/gyomu_python_analysis/project → gyomu_python_analysis-0.3.0/src/gyomu_python_analysis/error}/__init__.py +0 -0
  115. {gyomu_python_analysis-0.2.0/tests/unit → gyomu_python_analysis-0.3.0/src/gyomu_python_analysis/path}/__init__.py +0 -0
  116. {gyomu_python_analysis-0.2.0/tests/unit/analysis → gyomu_python_analysis-0.3.0/src/gyomu_python_analysis/project}/__init__.py +0 -0
  117. {gyomu_python_analysis-0.2.0/tests/unit/analysis/analyzers → gyomu_python_analysis-0.3.0/tests/unit}/__init__.py +0 -0
  118. {gyomu_python_analysis-0.2.0/tests/unit/analysis/analyzers/expression → gyomu_python_analysis-0.3.0/tests/unit/analysis}/__init__.py +0 -0
  119. {gyomu_python_analysis-0.2.0/tests/unit/analysis/analyzers/internal → gyomu_python_analysis-0.3.0/tests/unit/analysis/analyzers}/__init__.py +0 -0
  120. {gyomu_python_analysis-0.2.0/tests/unit/path → gyomu_python_analysis-0.3.0/tests/unit/analysis/analyzers/expression}/__init__.py +0 -0
  121. {gyomu_python_analysis-0.2.0 → gyomu_python_analysis-0.3.0}/tests/unit/analysis/analyzers/expression/test_analyze_expression_name.py +0 -0
  122. {gyomu_python_analysis-0.2.0 → gyomu_python_analysis-0.3.0}/tests/unit/analysis/analyzers/internal/test_location.py +0 -0
  123. {gyomu_python_analysis-0.2.0 → gyomu_python_analysis-0.3.0}/tests/unit/analysis/analyzers/internal/test_visibility.py +0 -0
  124. {gyomu_python_analysis-0.2.0 → gyomu_python_analysis-0.3.0}/tests/unit/analysis/analyzers/test_analyze_classes.py +0 -0
  125. {gyomu_python_analysis-0.2.0 → gyomu_python_analysis-0.3.0}/tests/unit/analysis/analyzers/test_analyze_decorator.py +0 -0
  126. {gyomu_python_analysis-0.2.0 → gyomu_python_analysis-0.3.0}/tests/unit/analysis/analyzers/test_analyze_functions.py +0 -0
  127. {gyomu_python_analysis-0.2.0 → gyomu_python_analysis-0.3.0}/tests/unit/analysis/analyzers/test_analyze_imports.py +0 -0
  128. {gyomu_python_analysis-0.2.0 → gyomu_python_analysis-0.3.0}/tests/unit/analysis/analyzers/test_analyze_pydantic.py +0 -0
  129. {gyomu_python_analysis-0.2.0 → gyomu_python_analysis-0.3.0}/tests/unit/analysis/analyzers/test_analyze_type_alias.py +0 -0
  130. {gyomu_python_analysis-0.2.0 → gyomu_python_analysis-0.3.0}/tests/unit/analysis/analyzers/test_context.py +0 -0
  131. {gyomu_python_analysis-0.2.0 → gyomu_python_analysis-0.3.0}/tests/unit/analysis/test_load.py +0 -0
@@ -17,3 +17,13 @@ __pycache__/
17
17
  .ruff_cache/
18
18
  htmlcov/
19
19
  *.egg-info/
20
+ log/
21
+
22
+
23
+ # gyomu ai related
24
+ **/.gyomu/cache
25
+ **/.gyomu/snapshot
26
+ **/.gyomu/checkpoint
27
+
28
+ # snapshot
29
+ __snapshots__
@@ -1,13 +1,13 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: gyomu-python-analysis
3
- Version: 0.2.0
3
+ Version: 0.3.0
4
4
  Summary: Gyomu Python Analysis
5
5
  Requires-Python: >=3.13
6
6
  Requires-Dist: docstring-parser>=0.18.0
7
7
  Requires-Dist: griffelib>=2.2.0
8
8
  Requires-Dist: gyomu-infra
9
9
  Requires-Dist: gyomu-schema
10
- Requires-Dist: returns>=0.29.0
10
+ Requires-Dist: returns
11
11
  Description-Content-Type: text/markdown
12
12
 
13
13
  # gyomu-python-analysis
@@ -7,7 +7,7 @@ requires-python = ">=3.13"
7
7
  dependencies = [
8
8
  "gyomu-schema",
9
9
  "gyomu-infra",
10
- "returns>=0.29.0",
10
+ "returns",
11
11
  "griffelib>=2.2.0",
12
12
  "docstring-parser>=0.18.0",
13
13
  ]
@@ -0,0 +1,7 @@
1
+ def custom_list_section() -> None:
2
+ """Process something.
3
+
4
+ Attributes:
5
+ foo: Foo attribute.
6
+ bar: Bar attribute.
7
+ """
@@ -0,0 +1,33 @@
1
+
2
+ from typing import Annotated
3
+
4
+ from pydantic import Field
5
+
6
+ VERSION = 5
7
+ VERSION_STR = "5"
8
+
9
+ _internal_value = 10
10
+
11
+ ANNOTATED: int
12
+
13
+ Calculated = 2 + 3
14
+
15
+
16
+ Confidence = Annotated[
17
+ float,
18
+ Field(
19
+ ge=0.0,
20
+ le=1.0,
21
+ description="AI decision confidence used for merge strategy routing",
22
+ ),
23
+ ]
24
+
25
+ Confidence2 = Annotated[
26
+ float,
27
+ SomeMetadata(),
28
+ Field(
29
+ ge=0.0,
30
+ le=1.0,
31
+ description="AI decision confidence used for merge strategy routing",
32
+ ),
33
+ ]
@@ -0,0 +1,341 @@
1
+ from dataclasses import dataclass
2
+ from pathlib import Path
3
+
4
+ from griffe import Attribute, Class, Function, TypeAlias
5
+ from gyomu_infra.logger import logger
6
+ from gyomu_python_analysis.analysis.analyzers.cls import analyze_class
7
+ from gyomu_python_analysis.analysis.analyzers.context import initialize_symbol_context
8
+ from gyomu_python_analysis.analysis.analyzers.functions import analyze_function
9
+ from gyomu_python_analysis.analysis.analyzers.type_alias import analyze_type_alias
10
+ from gyomu_python_analysis.analysis.analyzers.variables import analyze_variable
11
+ from gyomu_python_analysis.analysis.file.source_file_context import SourceFileContext
12
+ from gyomu_python_analysis.analysis.initialize import initialize_project_context
13
+ from gyomu_python_analysis.analysis.load import load_module
14
+ from gyomu_python_analysis.analysis.load_module import load_module_analysis
15
+ from gyomu_python_analysis.project.context import ProjectContext, PyProjectConfig
16
+ from gyomu_schema.schemas.python.class_analysis import ClassAnalysis
17
+ from gyomu_schema.schemas.python.function_analysis import FunctionAnalysis
18
+ from gyomu_schema.schemas.python.module import ModuleAnalysis
19
+ from gyomu_schema.schemas.python.symbol import SymbolAnalysis
20
+ from gyomu_schema.schemas.python.type_alias import TypeAliasAnalysis
21
+ from gyomu_schema.schemas.python.types import (
22
+ ProjectRelativePath,
23
+ PythonPath,
24
+ WorkspaceRelativePath,
25
+ )
26
+ from gyomu_schema.schemas.python.variable import VariableAnalysis
27
+ from gyomu_schema.schemas.types import FullPath
28
+ from returns.result import Failure
29
+
30
+ TEST_SUPPORT_ROOT = FullPath(Path(__file__).parent)
31
+ FIXTURES_ROOT = FullPath(Path(__file__).parent / "fixtures")
32
+ MONOREPO_FIXTURES_ROOT = FullPath(Path(__file__).parent / "monorepo_fixtures")
33
+
34
+
35
+ _default_project_config = PyProjectConfig(
36
+ path=WorkspaceRelativePath(Path(".")),
37
+ name="test",
38
+ version="0.1",
39
+ description=None,
40
+ formatter_line_length=88,
41
+ )
42
+
43
+
44
+ def _create_context() -> ProjectContext:
45
+ return initialize_project_context(
46
+ project_root=FIXTURES_ROOT, source_root=ProjectRelativePath(Path("src"))
47
+ ).unwrap()
48
+
49
+
50
+ # def create_declaration_identity(id: str) -> DeclarationIdentity:
51
+ # return DeclarationIdentity(
52
+ # symbol_id=SymbolId(id),
53
+ # declaration_id=DeclarationId("."),
54
+ # )
55
+
56
+
57
+ # def create_location(
58
+ # start_offset: int = 0,
59
+ # end_offset: int = 0,
60
+ # start_line: int = 1,
61
+ # start_column: int = 0,
62
+ # end_line: int = 1,
63
+ # end_column: int = 0,
64
+ # ) -> SourceLocation:
65
+ # return SourceLocation(
66
+ # start_line=start_line,
67
+ # start_offset=start_offset,
68
+ # end_line=end_line,
69
+ # end_offset=end_offset,
70
+ # start_column=start_column,
71
+ # end_column=end_column,
72
+ # )
73
+
74
+
75
+ # _default_identity = DeclarationIdentity(
76
+ # symbol_id=SymbolId("test.User"),
77
+ # declaration_id=DeclarationId("."),
78
+ # )
79
+
80
+
81
+ # def create_type_alias_analysis(
82
+ # indent: int,
83
+ # location: SourceLocation,
84
+ # name: str = "test_func",
85
+ # identity: DeclarationIdentity | None = None,
86
+ # ) -> TypeAliasAnalysis:
87
+ # if identity is None:
88
+ # identity = create_declaration_identity(name)
89
+ # return TypeAliasAnalysis(
90
+ # name=name,
91
+ # docstring=None,
92
+ # identity=identity,
93
+ # decorators=tuple(),
94
+ # dependencies=tuple(),
95
+ # indent=indent,
96
+ # kind=DeclarationKind.TYPEALIAS,
97
+ # visibility=Visibility.PUBLIC,
98
+ # location=location,
99
+ # alias_type=None,
100
+ # )
101
+
102
+
103
+ # def create_variable_analysis(
104
+ # indent: int,
105
+ # location: SourceLocation,
106
+ # name: str = "test_func",
107
+ # identity: DeclarationIdentity | None = None,
108
+ # ) -> VariableAnalysis:
109
+ # if identity is None:
110
+ # identity = create_declaration_identity(name)
111
+ # return VariableAnalysis(
112
+ # name=name,
113
+ # docstring=None,
114
+ # identity=identity,
115
+ # decorators=tuple(),
116
+ # dependencies=tuple(),
117
+ # indent=indent,
118
+ # kind=DeclarationKind.VARIABLE,
119
+ # visibility=Visibility.PUBLIC,
120
+ # location=location,
121
+ # type=None,
122
+ # value_source=None,
123
+ # value_expression=None,
124
+ # pydantic=None,
125
+ # )
126
+
127
+
128
+ # def create_function_analysis(
129
+ # indent: int,
130
+ # location: SourceLocation,
131
+ # name: str = "test_func",
132
+ # identity: DeclarationIdentity | None = None,
133
+ # ) -> FunctionAnalysis:
134
+ # if identity is None:
135
+ # identity = create_declaration_identity(name)
136
+ # return FunctionAnalysis(
137
+ # name=name,
138
+ # docstring=None,
139
+ # identity=identity,
140
+ # decorators=tuple(),
141
+ # dependencies=tuple(),
142
+ # indent=indent,
143
+ # is_async=False,
144
+ # kind=DeclarationKind.FUNCTION,
145
+ # parameters=tuple(),
146
+ # return_type=None,
147
+ # visibility=Visibility.PUBLIC,
148
+ # location=location,
149
+ # )
150
+
151
+
152
+ # def create_method_analysis(
153
+ # indent: int | None,
154
+ # location: SourceLocation | None,
155
+ # name: str = "test_func",
156
+ # identity: DeclarationIdentity | None = None,
157
+ # ) -> MethodAnalysis:
158
+ # if identity is None:
159
+ # identity = create_declaration_identity(name)
160
+ # return MethodAnalysis(
161
+ # name=name,
162
+ # docstring=None,
163
+ # identity=identity,
164
+ # decorators=tuple(),
165
+ # indent=indent,
166
+ # is_async=False,
167
+ # kind=DeclarationKind.METHOD,
168
+ # parameters=tuple(),
169
+ # return_type=None,
170
+ # visibility=Visibility.PUBLIC,
171
+ # location=location,
172
+ # )
173
+
174
+
175
+ # def create_class_analysis(
176
+ # indent: int,
177
+ # location: SourceLocation,
178
+ # name: str = "test_class",
179
+ # identity: DeclarationIdentity | None = None,
180
+ # ) -> ClassAnalysis:
181
+ # if identity is None:
182
+ # identity = create_declaration_identity(name)
183
+ # return ClassAnalysis(
184
+ # name=name,
185
+ # docstring=None,
186
+ # identity=identity,
187
+ # decorators=tuple(),
188
+ # dependencies=tuple(),
189
+ # indent=indent,
190
+ # kind=DeclarationKind.CLASS,
191
+ # bases=tuple(),
192
+ # visibility=Visibility.PUBLIC,
193
+ # location=location,
194
+ # methods=tuple(),
195
+ # variables=tuple(),
196
+ # type_aliases=tuple(),
197
+ # inner_classes=tuple(),
198
+ # )
199
+
200
+
201
+ # def create_file_analysis_context(
202
+ # symbol: SymbolAnalysis | MemberAnalysis | None = None,
203
+ # symbol2: SymbolAnalysis | MemberAnalysis | None = None,
204
+ # symbol3: SymbolAnalysis | MemberAnalysis | None = None,
205
+ # ) -> FileAnalysisContext:
206
+ # symbols: dict[DeclarationIdentity, SymbolAnalysis | MemberAnalysis]
207
+ # symbols = dict([(symbol.identity, symbol)]) if symbol else dict()
208
+
209
+ # if symbol2:
210
+ # symbols[symbol2.identity] = symbol2
211
+ # if symbol3:
212
+ # symbols[symbol3.identity] = symbol3
213
+ # return FileAnalysisContext(
214
+ # metadata=FileAnalysisMetadata(parsed_docstring=dict(), symbols=symbols),
215
+ # analysis=ModuleAnalysis(
216
+ # path=SourceRelativePath(Path(".")),
217
+ # name="test",
218
+ # module_name=PythonPath(""),
219
+ # docstring=None,
220
+ # imports=tuple(),
221
+ # symbols=(),
222
+ # ),
223
+ # )
224
+
225
+
226
+ @dataclass
227
+ class BaseContext:
228
+ project: ProjectContext
229
+ source: SourceFileContext
230
+
231
+
232
+ class AnalysisTestBase:
233
+ def _analyze_module_base(self, file_name: PythonPath) -> ModuleAnalysis:
234
+ context = self._read_module_fixture(file_name)
235
+ result = load_module_analysis(context.project, file_name)
236
+ if isinstance(result, Failure):
237
+ raise result.failure()
238
+
239
+ return result.unwrap()
240
+
241
+ def _analyze_typealias_bases(
242
+ self, file_name: PythonPath, symbol_name: str, dump_required: bool = False
243
+ ) -> TypeAliasAnalysis:
244
+ symbol, source_lines = self._analyze_symbol(
245
+ file_name, symbol_name, dump_required
246
+ )
247
+ assert isinstance(symbol, TypeAlias)
248
+ return analyze_type_alias(
249
+ alias=symbol,
250
+ name=symbol_name,
251
+ context=initialize_symbol_context(
252
+ module_name=file_name, name=symbol_name, source_lines=source_lines
253
+ ),
254
+ )
255
+
256
+ def _analyze_function_base(
257
+ self, file_name: PythonPath, symbol_name: str, dump_required: bool = False
258
+ ) -> FunctionAnalysis:
259
+ symbol, source_lines = self._analyze_symbol(
260
+ file_name, symbol_name, dump_required
261
+ )
262
+ assert isinstance(symbol, Function)
263
+ return analyze_function(
264
+ func=symbol,
265
+ name=symbol_name,
266
+ context=initialize_symbol_context(
267
+ module_name=file_name, name=symbol_name, source_lines=source_lines
268
+ ),
269
+ )
270
+
271
+ def _analyze_variable_base(
272
+ self, file_name: PythonPath, symbol_name: str, dump_required: bool = False
273
+ ) -> VariableAnalysis:
274
+ symbol, source_lines = self._analyze_symbol(
275
+ file_name, symbol_name, dump_required
276
+ )
277
+ assert isinstance(symbol, Attribute)
278
+ return analyze_variable(
279
+ variable=symbol,
280
+ name=symbol_name,
281
+ context=initialize_symbol_context(
282
+ module_name=file_name, name=symbol_name, source_lines=source_lines
283
+ ),
284
+ )
285
+
286
+ def _analyze_class_base(
287
+ self, file_name: PythonPath, symbol_name: str, dump_required: bool = False
288
+ ) -> ClassAnalysis:
289
+ symbol, source_lines = self._analyze_symbol(
290
+ file_name, symbol_name, dump_required
291
+ )
292
+ assert isinstance(symbol, Class)
293
+ return analyze_class(
294
+ cls=symbol,
295
+ name=symbol_name,
296
+ context=initialize_symbol_context(
297
+ module_name=file_name, name=symbol_name, source_lines=source_lines
298
+ ),
299
+ )
300
+
301
+ def _analyze_symbol(
302
+ self, file_name: PythonPath, symbol_name: str, dump_required: bool = False
303
+ ) -> tuple[SymbolAnalysis, list[str]]:
304
+ module_name = file_name
305
+ context = self._read_module_fixture(module_name)
306
+ module = context.source.module
307
+ symbol = module[symbol_name]
308
+
309
+ if dump_required:
310
+ logger.info(symbol.as_dict())
311
+
312
+ source_full_path = (
313
+ context.project.project_root
314
+ / context.project.source_root
315
+ / context.source.path
316
+ )
317
+ source_lines = source_full_path.read_text(
318
+ encoding="utf-8",
319
+ ).splitlines(keepends=True)
320
+
321
+ return symbol, source_lines
322
+
323
+ def _read_module_fixture(self, module_path: PythonPath) -> BaseContext:
324
+ context = _create_context()
325
+ # search_path = context.project_root / context.source_root
326
+ # print("search:", search_path)
327
+ # print("modulePath:", modulePath)
328
+
329
+ # loader = GriffeLoader(
330
+ # search_paths=[search_path],
331
+ # )
332
+ # module = loader.load(modulePath)
333
+ # if isinstance(module, Module):
334
+ # print("location:", module.filepath)
335
+ # return module
336
+ # raise ValueError("Invalid:")
337
+ result = load_module(context, module_path)
338
+
339
+ source_file_context = result.unwrap()
340
+
341
+ return BaseContext(project=context, source=source_file_context)
@@ -0,0 +1,4 @@
1
+ [project]
2
+ name = "project-a"
3
+ version = "0.1.0"
4
+ description = "Project A"
@@ -0,0 +1,4 @@
1
+ [project]
2
+ name = "project-b"
3
+ version = "0.1.0"
4
+ description = "Project B"
@@ -0,0 +1,9 @@
1
+ [project]
2
+ name = "test-monorepo"
3
+ version = "0.1.0"
4
+
5
+ [tool.uv.workspace]
6
+ members = [
7
+ "packages/project_a",
8
+ "packages/project_b",
9
+ ]