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.
- {gyomu_python_analysis-0.2.0 → gyomu_python_analysis-0.3.0}/.gitignore +10 -0
- {gyomu_python_analysis-0.2.0 → gyomu_python_analysis-0.3.0}/PKG-INFO +2 -2
- {gyomu_python_analysis-0.2.0 → gyomu_python_analysis-0.3.0}/pyproject.toml +1 -1
- gyomu_python_analysis-0.3.0/python_analysis_test_support/fixtures/src/analysis/docstring/15-custom-list-section.py +7 -0
- gyomu_python_analysis-0.3.0/python_analysis_test_support/fixtures/src/analysis/symbol/variable.py +33 -0
- gyomu_python_analysis-0.3.0/python_analysis_test_support/helpers.py +341 -0
- gyomu_python_analysis-0.3.0/python_analysis_test_support/monorepo_fixtures/packages/project_a/pyproject.toml +4 -0
- gyomu_python_analysis-0.3.0/python_analysis_test_support/monorepo_fixtures/packages/project_a/src/project_a/module.py +1 -0
- gyomu_python_analysis-0.3.0/python_analysis_test_support/monorepo_fixtures/packages/project_b/pyproject.toml +4 -0
- gyomu_python_analysis-0.3.0/python_analysis_test_support/monorepo_fixtures/packages/project_b/src/project_b/module.py +1 -0
- gyomu_python_analysis-0.3.0/python_analysis_test_support/monorepo_fixtures/pyproject.toml +9 -0
- {gyomu_python_analysis-0.2.0 → gyomu_python_analysis-0.3.0}/src/gyomu_python_analysis/analysis/analyzers/cls.py +51 -24
- {gyomu_python_analysis-0.2.0 → gyomu_python_analysis-0.3.0}/src/gyomu_python_analysis/analysis/analyzers/decorator.py +9 -4
- {gyomu_python_analysis-0.2.0 → gyomu_python_analysis-0.3.0}/src/gyomu_python_analysis/analysis/analyzers/docstring.py +89 -26
- {gyomu_python_analysis-0.2.0 → gyomu_python_analysis-0.3.0}/src/gyomu_python_analysis/analysis/analyzers/expression/expr.py +115 -59
- {gyomu_python_analysis-0.2.0 → gyomu_python_analysis-0.3.0}/src/gyomu_python_analysis/analysis/analyzers/functions.py +12 -6
- {gyomu_python_analysis-0.2.0 → gyomu_python_analysis-0.3.0}/src/gyomu_python_analysis/analysis/analyzers/imports.py +1 -1
- {gyomu_python_analysis-0.2.0 → gyomu_python_analysis-0.3.0}/src/gyomu_python_analysis/analysis/analyzers/internal/common.py +11 -2
- {gyomu_python_analysis-0.2.0 → gyomu_python_analysis-0.3.0}/src/gyomu_python_analysis/analysis/analyzers/pydantic.py +30 -0
- {gyomu_python_analysis-0.2.0 → gyomu_python_analysis-0.3.0}/src/gyomu_python_analysis/analysis/analyzers/type_alias.py +9 -3
- {gyomu_python_analysis-0.2.0 → gyomu_python_analysis-0.3.0}/src/gyomu_python_analysis/analysis/analyzers/types.py +6 -3
- gyomu_python_analysis-0.3.0/src/gyomu_python_analysis/analysis/analyzers/variables.py +60 -0
- {gyomu_python_analysis-0.2.0 → gyomu_python_analysis-0.3.0}/src/gyomu_python_analysis/analysis/extract/symbols.py +8 -13
- {gyomu_python_analysis-0.2.0 → gyomu_python_analysis-0.3.0}/src/gyomu_python_analysis/analysis/get_module.py +16 -5
- gyomu_python_analysis-0.3.0/src/gyomu_python_analysis/analysis/initialize.py +189 -0
- {gyomu_python_analysis-0.2.0 → gyomu_python_analysis-0.3.0}/src/gyomu_python_analysis/analysis/load_file_context.py +6 -2
- {gyomu_python_analysis-0.2.0 → gyomu_python_analysis-0.3.0}/src/gyomu_python_analysis/analysis/load_module.py +10 -3
- gyomu_python_analysis-0.3.0/src/gyomu_python_analysis/analysis/workspace.py +235 -0
- {gyomu_python_analysis-0.2.0 → gyomu_python_analysis-0.3.0}/src/gyomu_python_analysis/error/analysis.py +3 -1
- {gyomu_python_analysis-0.2.0 → gyomu_python_analysis-0.3.0}/src/gyomu_python_analysis/path/conversion.py +15 -0
- {gyomu_python_analysis-0.2.0 → gyomu_python_analysis-0.3.0}/src/gyomu_python_analysis/project/context.py +17 -2
- gyomu_python_analysis-0.3.0/src/gyomu_python_analysis/project/workspace.py +41 -0
- gyomu_python_analysis-0.3.0/tests/unit/analysis/analyzers/internal/__init__.py +0 -0
- {gyomu_python_analysis-0.2.0 → gyomu_python_analysis-0.3.0}/tests/unit/analysis/analyzers/test_analyze_dependency.py +2 -0
- {gyomu_python_analysis-0.2.0 → gyomu_python_analysis-0.3.0}/tests/unit/analysis/analyzers/test_analyze_docstring.py +33 -0
- {gyomu_python_analysis-0.2.0 → gyomu_python_analysis-0.3.0}/tests/unit/analysis/analyzers/test_analyze_types.py +3 -0
- {gyomu_python_analysis-0.2.0 → gyomu_python_analysis-0.3.0}/tests/unit/analysis/analyzers/test_analyze_variable.py +35 -4
- {gyomu_python_analysis-0.2.0 → gyomu_python_analysis-0.3.0}/tests/unit/analysis/test_get_module.py +24 -25
- gyomu_python_analysis-0.3.0/tests/unit/analysis/test_initialize.py +275 -0
- {gyomu_python_analysis-0.2.0 → gyomu_python_analysis-0.3.0}/tests/unit/analysis/test_load_file.py +14 -3
- {gyomu_python_analysis-0.2.0 → gyomu_python_analysis-0.3.0}/tests/unit/analysis/test_load_module.py +20 -9
- {gyomu_python_analysis-0.2.0 → gyomu_python_analysis-0.3.0}/tests/unit/analysis/test_metadata.py +2 -1
- gyomu_python_analysis-0.3.0/tests/unit/analysis/test_workspace.py +326 -0
- gyomu_python_analysis-0.3.0/tests/unit/path/__init__.py +0 -0
- {gyomu_python_analysis-0.2.0 → gyomu_python_analysis-0.3.0}/tests/unit/path/test_conversion.py +40 -0
- gyomu_python_analysis-0.2.0/python_analysis_test_support/fixtures/src/analysis/symbol/variable.py +0 -8
- gyomu_python_analysis-0.2.0/python_analysis_test_support/helpers.py +0 -341
- gyomu_python_analysis-0.2.0/src/gyomu_python_analysis/analysis/analyzers/variables.py +0 -22
- gyomu_python_analysis-0.2.0/src/gyomu_python_analysis/error/update.py +0 -32
- {gyomu_python_analysis-0.2.0 → gyomu_python_analysis-0.3.0}/README.md +0 -0
- {gyomu_python_analysis-0.2.0 → gyomu_python_analysis-0.3.0}/experiments/griffe_analysis.py +0 -0
- {gyomu_python_analysis-0.2.0 → gyomu_python_analysis-0.3.0}/experiments/griffe_dump.py +0 -0
- {gyomu_python_analysis-0.2.0 → gyomu_python_analysis-0.3.0}/experiments/sample/__init__.py +0 -0
- {gyomu_python_analysis-0.2.0 → gyomu_python_analysis-0.3.0}/experiments/sample/user.py +0 -0
- {gyomu_python_analysis-0.2.0 → gyomu_python_analysis-0.3.0}/experiments/sample.py +0 -0
- {gyomu_python_analysis-0.2.0 → gyomu_python_analysis-0.3.0}/python_analysis_test_support/__init__.py +0 -0
- {gyomu_python_analysis-0.2.0 → gyomu_python_analysis-0.3.0}/python_analysis_test_support/fixtures/pyproject.toml +0 -0
- {gyomu_python_analysis-0.2.0 → gyomu_python_analysis-0.3.0}/python_analysis_test_support/fixtures/src/__init__.py +0 -0
- {gyomu_python_analysis-0.2.0 → gyomu_python_analysis-0.3.0}/python_analysis_test_support/fixtures/src/analysis/__init__.py +0 -0
- {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
- {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
- {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
- {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
- {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
- {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
- {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
- {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
- {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
- {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
- {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
- {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
- {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
- {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
- {gyomu_python_analysis-0.2.0 → gyomu_python_analysis-0.3.0}/python_analysis_test_support/fixtures/src/analysis/docstring/__init__.py +0 -0
- {gyomu_python_analysis-0.2.0 → gyomu_python_analysis-0.3.0}/python_analysis_test_support/fixtures/src/analysis/import/__init__.py +0 -0
- {gyomu_python_analysis-0.2.0 → gyomu_python_analysis-0.3.0}/python_analysis_test_support/fixtures/src/analysis/import/all.py +0 -0
- {gyomu_python_analysis-0.2.0 → gyomu_python_analysis-0.3.0}/python_analysis_test_support/fixtures/src/analysis/import/all2.py +0 -0
- {gyomu_python_analysis-0.2.0 → gyomu_python_analysis-0.3.0}/python_analysis_test_support/fixtures/src/analysis/import/imports.py +0 -0
- {gyomu_python_analysis-0.2.0 → gyomu_python_analysis-0.3.0}/python_analysis_test_support/fixtures/src/analysis/import/relative.py +0 -0
- {gyomu_python_analysis-0.2.0 → gyomu_python_analysis-0.3.0}/python_analysis_test_support/fixtures/src/analysis/shared.py +0 -0
- {gyomu_python_analysis-0.2.0 → gyomu_python_analysis-0.3.0}/python_analysis_test_support/fixtures/src/analysis/symbol/__init__.py +0 -0
- {gyomu_python_analysis-0.2.0 → gyomu_python_analysis-0.3.0}/python_analysis_test_support/fixtures/src/analysis/symbol/call.py +0 -0
- {gyomu_python_analysis-0.2.0 → gyomu_python_analysis-0.3.0}/python_analysis_test_support/fixtures/src/analysis/symbol/callable.py +0 -0
- {gyomu_python_analysis-0.2.0 → gyomu_python_analysis-0.3.0}/python_analysis_test_support/fixtures/src/analysis/symbol/classes.py +0 -0
- {gyomu_python_analysis-0.2.0 → gyomu_python_analysis-0.3.0}/python_analysis_test_support/fixtures/src/analysis/symbol/decorator.py +0 -0
- {gyomu_python_analysis-0.2.0 → gyomu_python_analysis-0.3.0}/python_analysis_test_support/fixtures/src/analysis/symbol/functions.py +0 -0
- {gyomu_python_analysis-0.2.0 → gyomu_python_analysis-0.3.0}/python_analysis_test_support/fixtures/src/analysis/symbol/generics.py +0 -0
- {gyomu_python_analysis-0.2.0 → gyomu_python_analysis-0.3.0}/python_analysis_test_support/fixtures/src/analysis/symbol/location.py +0 -0
- {gyomu_python_analysis-0.2.0 → gyomu_python_analysis-0.3.0}/python_analysis_test_support/fixtures/src/analysis/symbol/pydantic.py +0 -0
- {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
- {gyomu_python_analysis-0.2.0 → gyomu_python_analysis-0.3.0}/python_analysis_test_support/fixtures/src/analysis/symbol/types.py +0 -0
- {gyomu_python_analysis-0.2.0 → gyomu_python_analysis-0.3.0}/python_analysis_test_support/fixtures/src/analysis/types/__init__.py +0 -0
- {gyomu_python_analysis-0.2.0 → gyomu_python_analysis-0.3.0}/python_analysis_test_support/fixtures/src/analysis/types/name.py +0 -0
- {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
- {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
- {gyomu_python_analysis-0.2.0 → gyomu_python_analysis-0.3.0}/roadmap.md +0 -0
- {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
- {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
- {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
- {gyomu_python_analysis-0.2.0 → gyomu_python_analysis-0.3.0}/src/gyomu_python_analysis/analysis/analyzers/context.py +0 -0
- {gyomu_python_analysis-0.2.0 → gyomu_python_analysis-0.3.0}/src/gyomu_python_analysis/analysis/analyzers/dependency.py +0 -0
- {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
- {gyomu_python_analysis-0.2.0 → gyomu_python_analysis-0.3.0}/src/gyomu_python_analysis/analysis/analyzers/expression/name.py +0 -0
- {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
- {gyomu_python_analysis-0.2.0 → gyomu_python_analysis-0.3.0}/src/gyomu_python_analysis/analysis/analyzers/internal/location.py +0 -0
- {gyomu_python_analysis-0.2.0 → gyomu_python_analysis-0.3.0}/src/gyomu_python_analysis/analysis/analyzers/internal/visibility.py +0 -0
- {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
- {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
- {gyomu_python_analysis-0.2.0 → gyomu_python_analysis-0.3.0}/src/gyomu_python_analysis/analysis/file/source_file_context.py +0 -0
- {gyomu_python_analysis-0.2.0 → gyomu_python_analysis-0.3.0}/src/gyomu_python_analysis/analysis/load.py +0 -0
- {gyomu_python_analysis-0.2.0 → gyomu_python_analysis-0.3.0}/src/gyomu_python_analysis/analysis/metadata.py +0 -0
- {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
- {gyomu_python_analysis-0.2.0 → gyomu_python_analysis-0.3.0}/src/gyomu_python_analysis/analysis/parser/docstring.py +0 -0
- {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
- {gyomu_python_analysis-0.2.0/tests/unit → gyomu_python_analysis-0.3.0/src/gyomu_python_analysis/path}/__init__.py +0 -0
- {gyomu_python_analysis-0.2.0/tests/unit/analysis → gyomu_python_analysis-0.3.0/src/gyomu_python_analysis/project}/__init__.py +0 -0
- {gyomu_python_analysis-0.2.0/tests/unit/analysis/analyzers → gyomu_python_analysis-0.3.0/tests/unit}/__init__.py +0 -0
- {gyomu_python_analysis-0.2.0/tests/unit/analysis/analyzers/expression → gyomu_python_analysis-0.3.0/tests/unit/analysis}/__init__.py +0 -0
- {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
- {gyomu_python_analysis-0.2.0/tests/unit/path → gyomu_python_analysis-0.3.0/tests/unit/analysis/analyzers/expression}/__init__.py +0 -0
- {gyomu_python_analysis-0.2.0 → gyomu_python_analysis-0.3.0}/tests/unit/analysis/analyzers/expression/test_analyze_expression_name.py +0 -0
- {gyomu_python_analysis-0.2.0 → gyomu_python_analysis-0.3.0}/tests/unit/analysis/analyzers/internal/test_location.py +0 -0
- {gyomu_python_analysis-0.2.0 → gyomu_python_analysis-0.3.0}/tests/unit/analysis/analyzers/internal/test_visibility.py +0 -0
- {gyomu_python_analysis-0.2.0 → gyomu_python_analysis-0.3.0}/tests/unit/analysis/analyzers/test_analyze_classes.py +0 -0
- {gyomu_python_analysis-0.2.0 → gyomu_python_analysis-0.3.0}/tests/unit/analysis/analyzers/test_analyze_decorator.py +0 -0
- {gyomu_python_analysis-0.2.0 → gyomu_python_analysis-0.3.0}/tests/unit/analysis/analyzers/test_analyze_functions.py +0 -0
- {gyomu_python_analysis-0.2.0 → gyomu_python_analysis-0.3.0}/tests/unit/analysis/analyzers/test_analyze_imports.py +0 -0
- {gyomu_python_analysis-0.2.0 → gyomu_python_analysis-0.3.0}/tests/unit/analysis/analyzers/test_analyze_pydantic.py +0 -0
- {gyomu_python_analysis-0.2.0 → gyomu_python_analysis-0.3.0}/tests/unit/analysis/analyzers/test_analyze_type_alias.py +0 -0
- {gyomu_python_analysis-0.2.0 → gyomu_python_analysis-0.3.0}/tests/unit/analysis/analyzers/test_context.py +0 -0
- {gyomu_python_analysis-0.2.0 → gyomu_python_analysis-0.3.0}/tests/unit/analysis/test_load.py +0 -0
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: gyomu-python-analysis
|
|
3
|
-
Version: 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
|
|
10
|
+
Requires-Dist: returns
|
|
11
11
|
Description-Content-Type: text/markdown
|
|
12
12
|
|
|
13
13
|
# gyomu-python-analysis
|
gyomu_python_analysis-0.3.0/python_analysis_test_support/fixtures/src/analysis/symbol/variable.py
ADDED
|
@@ -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 @@
|
|
|
1
|
+
VERSION = "1.0"
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
VERSION = "1.1"
|