gyomu-python-analysis 0.2.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/.gitignore +19 -0
- gyomu_python_analysis-0.2.0/PKG-INFO +15 -0
- gyomu_python_analysis-0.2.0/README.md +3 -0
- gyomu_python_analysis-0.2.0/experiments/griffe_analysis.py +12 -0
- gyomu_python_analysis-0.2.0/experiments/griffe_dump.py +96 -0
- gyomu_python_analysis-0.2.0/experiments/sample/__init__.py +0 -0
- gyomu_python_analysis-0.2.0/experiments/sample/user.py +14 -0
- gyomu_python_analysis-0.2.0/experiments/sample.py +35 -0
- gyomu_python_analysis-0.2.0/pyproject.toml +26 -0
- gyomu_python_analysis-0.2.0/python_analysis_test_support/__init__.py +0 -0
- gyomu_python_analysis-0.2.0/python_analysis_test_support/fixtures/pyproject.toml +13 -0
- gyomu_python_analysis-0.2.0/python_analysis_test_support/fixtures/src/__init__.py +0 -0
- gyomu_python_analysis-0.2.0/python_analysis_test_support/fixtures/src/analysis/__init__.py +0 -0
- gyomu_python_analysis-0.2.0/python_analysis_test_support/fixtures/src/analysis/docstring/01-simple.py +12 -0
- gyomu_python_analysis-0.2.0/python_analysis_test_support/fixtures/src/analysis/docstring/02-args.py +12 -0
- gyomu_python_analysis-0.2.0/python_analysis_test_support/fixtures/src/analysis/docstring/03-typed-return.py +10 -0
- gyomu_python_analysis-0.2.0/python_analysis_test_support/fixtures/src/analysis/docstring/04-raises.py +14 -0
- gyomu_python_analysis-0.2.0/python_analysis_test_support/fixtures/src/analysis/docstring/05-examples.py +18 -0
- gyomu_python_analysis-0.2.0/python_analysis_test_support/fixtures/src/analysis/docstring/06-notes.py +16 -0
- gyomu_python_analysis-0.2.0/python_analysis_test_support/fixtures/src/analysis/docstring/07-complex.py +31 -0
- gyomu_python_analysis-0.2.0/python_analysis_test_support/fixtures/src/analysis/docstring/08-gyomu-context.py +14 -0
- gyomu_python_analysis-0.2.0/python_analysis_test_support/fixtures/src/analysis/docstring/09-custom-section.py +13 -0
- gyomu_python_analysis-0.2.0/python_analysis_test_support/fixtures/src/analysis/docstring/10-edge-cases.py +17 -0
- gyomu_python_analysis-0.2.0/python_analysis_test_support/fixtures/src/analysis/docstring/11-custom-and-gyomu-context.py +12 -0
- gyomu_python_analysis-0.2.0/python_analysis_test_support/fixtures/src/analysis/docstring/12-module.py +18 -0
- gyomu_python_analysis-0.2.0/python_analysis_test_support/fixtures/src/analysis/docstring/13-class.py +58 -0
- gyomu_python_analysis-0.2.0/python_analysis_test_support/fixtures/src/analysis/docstring/14-variable.py +49 -0
- gyomu_python_analysis-0.2.0/python_analysis_test_support/fixtures/src/analysis/docstring/__init__.py +0 -0
- gyomu_python_analysis-0.2.0/python_analysis_test_support/fixtures/src/analysis/import/__init__.py +0 -0
- gyomu_python_analysis-0.2.0/python_analysis_test_support/fixtures/src/analysis/import/all.py +5 -0
- gyomu_python_analysis-0.2.0/python_analysis_test_support/fixtures/src/analysis/import/all2.py +2 -0
- gyomu_python_analysis-0.2.0/python_analysis_test_support/fixtures/src/analysis/import/imports.py +10 -0
- gyomu_python_analysis-0.2.0/python_analysis_test_support/fixtures/src/analysis/import/relative.py +1 -0
- gyomu_python_analysis-0.2.0/python_analysis_test_support/fixtures/src/analysis/shared.py +1 -0
- gyomu_python_analysis-0.2.0/python_analysis_test_support/fixtures/src/analysis/symbol/__init__.py +7 -0
- gyomu_python_analysis-0.2.0/python_analysis_test_support/fixtures/src/analysis/symbol/call.py +30 -0
- gyomu_python_analysis-0.2.0/python_analysis_test_support/fixtures/src/analysis/symbol/callable.py +54 -0
- gyomu_python_analysis-0.2.0/python_analysis_test_support/fixtures/src/analysis/symbol/classes.py +75 -0
- gyomu_python_analysis-0.2.0/python_analysis_test_support/fixtures/src/analysis/symbol/decorator.py +84 -0
- gyomu_python_analysis-0.2.0/python_analysis_test_support/fixtures/src/analysis/symbol/functions.py +20 -0
- gyomu_python_analysis-0.2.0/python_analysis_test_support/fixtures/src/analysis/symbol/generics.py +12 -0
- gyomu_python_analysis-0.2.0/python_analysis_test_support/fixtures/src/analysis/symbol/location.py +13 -0
- gyomu_python_analysis-0.2.0/python_analysis_test_support/fixtures/src/analysis/symbol/pydantic.py +42 -0
- gyomu_python_analysis-0.2.0/python_analysis_test_support/fixtures/src/analysis/symbol/type_alias.py +6 -0
- gyomu_python_analysis-0.2.0/python_analysis_test_support/fixtures/src/analysis/symbol/types.py +37 -0
- gyomu_python_analysis-0.2.0/python_analysis_test_support/fixtures/src/analysis/symbol/variable.py +8 -0
- gyomu_python_analysis-0.2.0/python_analysis_test_support/fixtures/src/analysis/types/__init__.py +0 -0
- gyomu_python_analysis-0.2.0/python_analysis_test_support/fixtures/src/analysis/types/name.py +43 -0
- gyomu_python_analysis-0.2.0/python_analysis_test_support/helpers.py +341 -0
- gyomu_python_analysis-0.2.0/roadmap.md +951 -0
- gyomu_python_analysis-0.2.0/src/gyomu_python_analysis/__init__.py +0 -0
- gyomu_python_analysis-0.2.0/src/gyomu_python_analysis/analysis/__init__.py +0 -0
- gyomu_python_analysis-0.2.0/src/gyomu_python_analysis/analysis/analyzers/__init__.py +0 -0
- gyomu_python_analysis-0.2.0/src/gyomu_python_analysis/analysis/analyzers/cls.py +343 -0
- gyomu_python_analysis-0.2.0/src/gyomu_python_analysis/analysis/analyzers/context.py +66 -0
- gyomu_python_analysis-0.2.0/src/gyomu_python_analysis/analysis/analyzers/decorator.py +88 -0
- gyomu_python_analysis-0.2.0/src/gyomu_python_analysis/analysis/analyzers/dependency.py +134 -0
- gyomu_python_analysis-0.2.0/src/gyomu_python_analysis/analysis/analyzers/docstring.py +288 -0
- gyomu_python_analysis-0.2.0/src/gyomu_python_analysis/analysis/analyzers/expression/__init__.py +0 -0
- gyomu_python_analysis-0.2.0/src/gyomu_python_analysis/analysis/analyzers/expression/expr.py +400 -0
- gyomu_python_analysis-0.2.0/src/gyomu_python_analysis/analysis/analyzers/expression/name.py +38 -0
- gyomu_python_analysis-0.2.0/src/gyomu_python_analysis/analysis/analyzers/functions.py +53 -0
- gyomu_python_analysis-0.2.0/src/gyomu_python_analysis/analysis/analyzers/imports.py +21 -0
- gyomu_python_analysis-0.2.0/src/gyomu_python_analysis/analysis/analyzers/internal/__init__.py +0 -0
- gyomu_python_analysis-0.2.0/src/gyomu_python_analysis/analysis/analyzers/internal/common.py +87 -0
- gyomu_python_analysis-0.2.0/src/gyomu_python_analysis/analysis/analyzers/internal/location.py +68 -0
- gyomu_python_analysis-0.2.0/src/gyomu_python_analysis/analysis/analyzers/internal/visibility.py +27 -0
- gyomu_python_analysis-0.2.0/src/gyomu_python_analysis/analysis/analyzers/pydantic.py +62 -0
- gyomu_python_analysis-0.2.0/src/gyomu_python_analysis/analysis/analyzers/type_alias.py +24 -0
- gyomu_python_analysis-0.2.0/src/gyomu_python_analysis/analysis/analyzers/types.py +29 -0
- gyomu_python_analysis-0.2.0/src/gyomu_python_analysis/analysis/analyzers/variables.py +22 -0
- gyomu_python_analysis-0.2.0/src/gyomu_python_analysis/analysis/extract/__init__.py +0 -0
- gyomu_python_analysis-0.2.0/src/gyomu_python_analysis/analysis/extract/symbols.py +118 -0
- gyomu_python_analysis-0.2.0/src/gyomu_python_analysis/analysis/file/__init__.py +0 -0
- gyomu_python_analysis-0.2.0/src/gyomu_python_analysis/analysis/file/source_file_context.py +10 -0
- gyomu_python_analysis-0.2.0/src/gyomu_python_analysis/analysis/get_module.py +55 -0
- gyomu_python_analysis-0.2.0/src/gyomu_python_analysis/analysis/load.py +42 -0
- gyomu_python_analysis-0.2.0/src/gyomu_python_analysis/analysis/load_file_context.py +27 -0
- gyomu_python_analysis-0.2.0/src/gyomu_python_analysis/analysis/load_module.py +65 -0
- gyomu_python_analysis-0.2.0/src/gyomu_python_analysis/analysis/metadata.py +49 -0
- gyomu_python_analysis-0.2.0/src/gyomu_python_analysis/analysis/parser/__init__.py +0 -0
- gyomu_python_analysis-0.2.0/src/gyomu_python_analysis/analysis/parser/docstring.py +7 -0
- gyomu_python_analysis-0.2.0/src/gyomu_python_analysis/error/__init__.py +0 -0
- gyomu_python_analysis-0.2.0/src/gyomu_python_analysis/error/analysis.py +36 -0
- gyomu_python_analysis-0.2.0/src/gyomu_python_analysis/error/update.py +32 -0
- gyomu_python_analysis-0.2.0/src/gyomu_python_analysis/path/__init__.py +0 -0
- gyomu_python_analysis-0.2.0/src/gyomu_python_analysis/path/conversion.py +25 -0
- gyomu_python_analysis-0.2.0/src/gyomu_python_analysis/project/__init__.py +0 -0
- gyomu_python_analysis-0.2.0/src/gyomu_python_analysis/project/context.py +18 -0
- gyomu_python_analysis-0.2.0/tests/unit/__init__.py +0 -0
- gyomu_python_analysis-0.2.0/tests/unit/analysis/__init__.py +0 -0
- gyomu_python_analysis-0.2.0/tests/unit/analysis/analyzers/__init__.py +0 -0
- gyomu_python_analysis-0.2.0/tests/unit/analysis/analyzers/expression/__init__.py +0 -0
- gyomu_python_analysis-0.2.0/tests/unit/analysis/analyzers/expression/test_analyze_expression_name.py +71 -0
- gyomu_python_analysis-0.2.0/tests/unit/analysis/analyzers/internal/__init__.py +0 -0
- gyomu_python_analysis-0.2.0/tests/unit/analysis/analyzers/internal/test_location.py +97 -0
- gyomu_python_analysis-0.2.0/tests/unit/analysis/analyzers/internal/test_visibility.py +25 -0
- gyomu_python_analysis-0.2.0/tests/unit/analysis/analyzers/test_analyze_classes.py +372 -0
- gyomu_python_analysis-0.2.0/tests/unit/analysis/analyzers/test_analyze_decorator.py +283 -0
- gyomu_python_analysis-0.2.0/tests/unit/analysis/analyzers/test_analyze_dependency.py +339 -0
- gyomu_python_analysis-0.2.0/tests/unit/analysis/analyzers/test_analyze_docstring.py +538 -0
- gyomu_python_analysis-0.2.0/tests/unit/analysis/analyzers/test_analyze_functions.py +88 -0
- gyomu_python_analysis-0.2.0/tests/unit/analysis/analyzers/test_analyze_imports.py +66 -0
- gyomu_python_analysis-0.2.0/tests/unit/analysis/analyzers/test_analyze_pydantic.py +96 -0
- gyomu_python_analysis-0.2.0/tests/unit/analysis/analyzers/test_analyze_type_alias.py +95 -0
- gyomu_python_analysis-0.2.0/tests/unit/analysis/analyzers/test_analyze_types.py +813 -0
- gyomu_python_analysis-0.2.0/tests/unit/analysis/analyzers/test_analyze_variable.py +89 -0
- gyomu_python_analysis-0.2.0/tests/unit/analysis/analyzers/test_context.py +65 -0
- gyomu_python_analysis-0.2.0/tests/unit/analysis/test_get_module.py +275 -0
- gyomu_python_analysis-0.2.0/tests/unit/analysis/test_load.py +42 -0
- gyomu_python_analysis-0.2.0/tests/unit/analysis/test_load_file.py +96 -0
- gyomu_python_analysis-0.2.0/tests/unit/analysis/test_load_module.py +311 -0
- gyomu_python_analysis-0.2.0/tests/unit/analysis/test_metadata.py +317 -0
- gyomu_python_analysis-0.2.0/tests/unit/path/__init__.py +0 -0
- gyomu_python_analysis-0.2.0/tests/unit/path/test_conversion.py +81 -0
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: gyomu-python-analysis
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Summary: Gyomu Python Analysis
|
|
5
|
+
Requires-Python: >=3.13
|
|
6
|
+
Requires-Dist: docstring-parser>=0.18.0
|
|
7
|
+
Requires-Dist: griffelib>=2.2.0
|
|
8
|
+
Requires-Dist: gyomu-infra
|
|
9
|
+
Requires-Dist: gyomu-schema
|
|
10
|
+
Requires-Dist: returns>=0.29.0
|
|
11
|
+
Description-Content-Type: text/markdown
|
|
12
|
+
|
|
13
|
+
# gyomu-python-analysis
|
|
14
|
+
|
|
15
|
+
python analysis components for Gyomu Python.
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
from pathlib import Path
|
|
2
|
+
from pprint import pprint
|
|
3
|
+
|
|
4
|
+
from griffe import Alias, visit
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def dump_docstring(obj: object, indent: str) -> None:
|
|
8
|
+
docstring = getattr(obj, "docstring", None)
|
|
9
|
+
|
|
10
|
+
if docstring is None:
|
|
11
|
+
print(f"{indent}docstring: <none>")
|
|
12
|
+
return
|
|
13
|
+
|
|
14
|
+
print(f"{indent}docstring type: {type(docstring)}")
|
|
15
|
+
print(f"{indent}docstring value: {docstring.value!r}")
|
|
16
|
+
|
|
17
|
+
for name in dir(docstring):
|
|
18
|
+
if (
|
|
19
|
+
"line" in name.lower()
|
|
20
|
+
or "column" in name.lower()
|
|
21
|
+
or "offset" in name.lower()
|
|
22
|
+
or "position" in name.lower()
|
|
23
|
+
or "loc" in name.lower()
|
|
24
|
+
):
|
|
25
|
+
try:
|
|
26
|
+
value = getattr(docstring, name)
|
|
27
|
+
except Exception:
|
|
28
|
+
continue
|
|
29
|
+
|
|
30
|
+
if not callable(value):
|
|
31
|
+
print(f"{indent}{name}: {value!r}")
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def dump_alias(
|
|
35
|
+
alias: Alias,
|
|
36
|
+
indent: str,
|
|
37
|
+
) -> None:
|
|
38
|
+
print(f"{indent}Alias: {alias.name}")
|
|
39
|
+
print(f"{indent} target_path: {alias.target_path}")
|
|
40
|
+
pprint(alias)
|
|
41
|
+
print(f"{indent} is_alias: {alias.is_alias}")
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
def dump_object(obj: object, indent: str = "") -> None:
|
|
45
|
+
if isinstance(obj, Alias):
|
|
46
|
+
dump_alias(obj, indent)
|
|
47
|
+
return
|
|
48
|
+
|
|
49
|
+
print(f"{indent}{type(obj).__name__}: {getattr(obj, 'name', '<unknown>')}")
|
|
50
|
+
|
|
51
|
+
for attr in (
|
|
52
|
+
"lineno",
|
|
53
|
+
"endlineno",
|
|
54
|
+
# "docstring",
|
|
55
|
+
"members",
|
|
56
|
+
"bases",
|
|
57
|
+
"parameters",
|
|
58
|
+
"returns",
|
|
59
|
+
"decorators",
|
|
60
|
+
"annotation",
|
|
61
|
+
"value",
|
|
62
|
+
"kind",
|
|
63
|
+
):
|
|
64
|
+
try:
|
|
65
|
+
value = getattr(obj, attr)
|
|
66
|
+
except AttributeError:
|
|
67
|
+
continue
|
|
68
|
+
|
|
69
|
+
print(f"{indent} {attr}: {value!r}")
|
|
70
|
+
|
|
71
|
+
dump_docstring(obj, indent + " ")
|
|
72
|
+
|
|
73
|
+
members = getattr(obj, "members", None)
|
|
74
|
+
|
|
75
|
+
if members:
|
|
76
|
+
for member in members.values():
|
|
77
|
+
print()
|
|
78
|
+
dump_object(member, indent + " ")
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
def main() -> None:
|
|
82
|
+
source_path = Path("sample.py").resolve()
|
|
83
|
+
|
|
84
|
+
source = source_path.read_text(encoding="utf-8")
|
|
85
|
+
|
|
86
|
+
module = visit(
|
|
87
|
+
module_name="sample",
|
|
88
|
+
filepath=source_path,
|
|
89
|
+
code=source,
|
|
90
|
+
)
|
|
91
|
+
|
|
92
|
+
dump_object(module)
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
if __name__ == "__main__":
|
|
96
|
+
main()
|
|
File without changes
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
from pydantic import BaseModel, Field
|
|
2
|
+
|
|
3
|
+
Version = 1.2
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class User(BaseModel):
|
|
7
|
+
"""User information."""
|
|
8
|
+
|
|
9
|
+
id: int = Field(description="Primary identifier")
|
|
10
|
+
|
|
11
|
+
@classmethod
|
|
12
|
+
def create(cls, name: str) -> "User":
|
|
13
|
+
"""Create a user."""
|
|
14
|
+
return cls(id=1)
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import asyncio
|
|
2
|
+
import pathlib
|
|
3
|
+
|
|
4
|
+
from pydantic import BaseModel
|
|
5
|
+
from pydantic import Field as fld
|
|
6
|
+
from pydantic.aliases import AliasChoices as choice
|
|
7
|
+
from pydantic.config import JsonDict
|
|
8
|
+
|
|
9
|
+
from .griffe_analysis import Field as fld2
|
|
10
|
+
|
|
11
|
+
VERSION = 0.1
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
async def add(a: int, b: int):
|
|
15
|
+
await asyncio.sleep(1)
|
|
16
|
+
return a + b
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def add2(a: int, b: int) -> int:
|
|
20
|
+
return a + b
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
class User(BaseModel):
|
|
24
|
+
"""User information."""
|
|
25
|
+
|
|
26
|
+
id: int = fld(description="Primary identifier")
|
|
27
|
+
|
|
28
|
+
@classmethod
|
|
29
|
+
def create(cls, name: str) -> "User":
|
|
30
|
+
"""Create a user."""
|
|
31
|
+
path: pathlib.Path = pathlib.Path("c:\\data")
|
|
32
|
+
dict: JsonDict = {}
|
|
33
|
+
ch: choice = {}
|
|
34
|
+
fld3: fld2 = {}
|
|
35
|
+
return cls(id=1)
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "gyomu-python-analysis"
|
|
3
|
+
dynamic = ["version"]
|
|
4
|
+
description = "Gyomu Python Analysis"
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
requires-python = ">=3.13"
|
|
7
|
+
dependencies = [
|
|
8
|
+
"gyomu-schema",
|
|
9
|
+
"gyomu-infra",
|
|
10
|
+
"returns>=0.29.0",
|
|
11
|
+
"griffelib>=2.2.0",
|
|
12
|
+
"docstring-parser>=0.18.0",
|
|
13
|
+
]
|
|
14
|
+
|
|
15
|
+
[build-system]
|
|
16
|
+
requires = ["hatchling"]
|
|
17
|
+
build-backend = "hatchling.build"
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
[tool.uv.sources]
|
|
21
|
+
gyomu-schema = { workspace = true }
|
|
22
|
+
gyomu-infra = { workspace = true }
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
[tool.hatch.version]
|
|
26
|
+
path = "../../version/__about__.py"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
def load_user(user_id: int) -> dict[str, object]:
|
|
2
|
+
"""Load a user.
|
|
3
|
+
|
|
4
|
+
Args:
|
|
5
|
+
user_id: The user ID.
|
|
6
|
+
|
|
7
|
+
Raises:
|
|
8
|
+
ValueError: If the user ID is invalid.
|
|
9
|
+
LookupError: If the user cannot be found.
|
|
10
|
+
|
|
11
|
+
Returns:
|
|
12
|
+
The user information.
|
|
13
|
+
"""
|
|
14
|
+
return dict()
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
def add(left: int, right: int) -> int:
|
|
2
|
+
"""Add two numbers.
|
|
3
|
+
|
|
4
|
+
Args:
|
|
5
|
+
left: The left operand.
|
|
6
|
+
right: The right operand.
|
|
7
|
+
|
|
8
|
+
Returns:
|
|
9
|
+
The sum of the two operands.
|
|
10
|
+
|
|
11
|
+
Examples:
|
|
12
|
+
>>> add(1, 2)
|
|
13
|
+
3
|
|
14
|
+
|
|
15
|
+
>>> add(-1, 5)
|
|
16
|
+
4
|
|
17
|
+
"""
|
|
18
|
+
return 1
|
gyomu_python_analysis-0.2.0/python_analysis_test_support/fixtures/src/analysis/docstring/06-notes.py
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
def process(value: str) -> str:
|
|
2
|
+
"""Process a value.
|
|
3
|
+
|
|
4
|
+
Args:
|
|
5
|
+
value: The value to process.
|
|
6
|
+
|
|
7
|
+
Notes:
|
|
8
|
+
The value is normalized before processing.
|
|
9
|
+
Leading and trailing whitespace is removed.
|
|
10
|
+
|
|
11
|
+
This operation does not modify the original value.
|
|
12
|
+
|
|
13
|
+
Returns:
|
|
14
|
+
The processed value.
|
|
15
|
+
"""
|
|
16
|
+
return "A"
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
def process_user(
|
|
2
|
+
user_id: int,
|
|
3
|
+
name: str,
|
|
4
|
+
*,
|
|
5
|
+
active: bool = True,
|
|
6
|
+
) -> dict[str, object]:
|
|
7
|
+
"""Process a user.
|
|
8
|
+
|
|
9
|
+
This function loads a user and updates its information.
|
|
10
|
+
|
|
11
|
+
Args:
|
|
12
|
+
user_id (int): The user ID.
|
|
13
|
+
name (str): The user's name.
|
|
14
|
+
active (bool): Whether the user is active.
|
|
15
|
+
|
|
16
|
+
Raises:
|
|
17
|
+
ValueError: If the user ID is invalid.
|
|
18
|
+
LookupError: If the user does not exist.
|
|
19
|
+
|
|
20
|
+
Returns:
|
|
21
|
+
dict[str, object]: The updated user information.
|
|
22
|
+
|
|
23
|
+
Examples:
|
|
24
|
+
>>> process_user(1, "Alice")
|
|
25
|
+
{'id': 1, 'name': 'Alice', 'active': True}
|
|
26
|
+
|
|
27
|
+
Notes:
|
|
28
|
+
The user is loaded from the repository before being updated.
|
|
29
|
+
The operation is transactional.
|
|
30
|
+
"""
|
|
31
|
+
return dict()
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
def process_user(user_id: int) -> dict[str, object]:
|
|
2
|
+
"""Process a user.
|
|
3
|
+
|
|
4
|
+
Args:
|
|
5
|
+
user_id: The user ID.
|
|
6
|
+
|
|
7
|
+
Returns:
|
|
8
|
+
The processed user.
|
|
9
|
+
|
|
10
|
+
Gyomu Context:
|
|
11
|
+
This function is used by the user synchronization workflow.
|
|
12
|
+
It should only be called from the application service layer.
|
|
13
|
+
"""
|
|
14
|
+
return dict()
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
def no_sections() -> None:
|
|
2
|
+
"""Do something.
|
|
3
|
+
|
|
4
|
+
This function does something without any arguments or return value.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def empty_docstring() -> None:
|
|
9
|
+
""""""
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def section_only() -> None:
|
|
13
|
+
"""Do something.
|
|
14
|
+
|
|
15
|
+
Notes:
|
|
16
|
+
This is a note.
|
|
17
|
+
"""
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
def custom_and_gyomu_context() -> None:
|
|
2
|
+
"""Process something.
|
|
3
|
+
|
|
4
|
+
Foo:
|
|
5
|
+
This is a custom section.
|
|
6
|
+
|
|
7
|
+
It contains additional information.
|
|
8
|
+
|
|
9
|
+
Gyomu Context:
|
|
10
|
+
This function is used by the application workflow.
|
|
11
|
+
It should only be called from the service layer.
|
|
12
|
+
"""
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"""User management module.
|
|
2
|
+
|
|
3
|
+
This module provides operations for creating and updating users.
|
|
4
|
+
|
|
5
|
+
Notes:
|
|
6
|
+
User data is managed by the application service layer.
|
|
7
|
+
|
|
8
|
+
Gyomu Context:
|
|
9
|
+
This module belongs to the user synchronization workflow.
|
|
10
|
+
It should only be used by the application service layer.
|
|
11
|
+
"""
|
|
12
|
+
|
|
13
|
+
from dataclasses import dataclass
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
@dataclass
|
|
17
|
+
class User:
|
|
18
|
+
name: str
|
gyomu_python_analysis-0.2.0/python_analysis_test_support/fixtures/src/analysis/docstring/13-class.py
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
class User:
|
|
2
|
+
"""User model.
|
|
3
|
+
|
|
4
|
+
This class represents a user in the application.
|
|
5
|
+
|
|
6
|
+
Notes:
|
|
7
|
+
User instances are managed by the application service layer.
|
|
8
|
+
|
|
9
|
+
Gyomu Context:
|
|
10
|
+
This class is used by the user synchronization workflow.
|
|
11
|
+
It should only be created by the application service layer.
|
|
12
|
+
"""
|
|
13
|
+
|
|
14
|
+
name: str
|
|
15
|
+
"""The user's name."""
|
|
16
|
+
|
|
17
|
+
active: bool
|
|
18
|
+
"""Whether the user is active."""
|
|
19
|
+
|
|
20
|
+
def __init__(
|
|
21
|
+
self,
|
|
22
|
+
name: str,
|
|
23
|
+
active: bool = True,
|
|
24
|
+
) -> None:
|
|
25
|
+
"""Initialize a user.
|
|
26
|
+
|
|
27
|
+
Args:
|
|
28
|
+
name (str): The user's name.
|
|
29
|
+
active (bool): Whether the user is active.
|
|
30
|
+
|
|
31
|
+
Notes:
|
|
32
|
+
The user is active by default.
|
|
33
|
+
"""
|
|
34
|
+
self.name = name
|
|
35
|
+
self.active = active
|
|
36
|
+
|
|
37
|
+
def activate(self) -> None:
|
|
38
|
+
"""Activate the user.
|
|
39
|
+
|
|
40
|
+
This method marks the user as active.
|
|
41
|
+
|
|
42
|
+
Returns:
|
|
43
|
+
None.
|
|
44
|
+
|
|
45
|
+
Gyomu Context:
|
|
46
|
+
This method is used during the user synchronization workflow.
|
|
47
|
+
"""
|
|
48
|
+
self.active = True
|
|
49
|
+
|
|
50
|
+
def deactivate(self) -> None:
|
|
51
|
+
"""Deactivate the user.
|
|
52
|
+
|
|
53
|
+
This method marks the user as inactive.
|
|
54
|
+
|
|
55
|
+
Notes:
|
|
56
|
+
Deactivated users are not synchronized.
|
|
57
|
+
"""
|
|
58
|
+
self.active = False
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"""Variable analysis fixture.
|
|
2
|
+
|
|
3
|
+
This module contains various kinds of variables for analysis.
|
|
4
|
+
|
|
5
|
+
Notes:
|
|
6
|
+
Variables are used to represent application configuration and state.
|
|
7
|
+
|
|
8
|
+
Gyomu Context:
|
|
9
|
+
This module is used by the configuration loading workflow.
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
# Simple variable
|
|
13
|
+
name = "Alice"
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
# Annotated variable
|
|
17
|
+
age: int = 30
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
# Variable without an initial value
|
|
21
|
+
active: bool
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
# Constant-like variable
|
|
25
|
+
MAX_RETRY: int = 3
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
# Variable with a generic type
|
|
29
|
+
users: list[str] = []
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
# Variable with a docstring
|
|
33
|
+
description = "A user description."
|
|
34
|
+
"""Description of the user.
|
|
35
|
+
|
|
36
|
+
This variable contains the human-readable description.
|
|
37
|
+
|
|
38
|
+
Notes:
|
|
39
|
+
The description is displayed to users.
|
|
40
|
+
"""
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
# Variable with an annotation and a docstring
|
|
44
|
+
status: str = "active"
|
|
45
|
+
"""Current user status.
|
|
46
|
+
|
|
47
|
+
Gyomu Context:
|
|
48
|
+
This value is updated during user synchronization.
|
|
49
|
+
"""
|
gyomu_python_analysis-0.2.0/python_analysis_test_support/fixtures/src/analysis/docstring/__init__.py
ADDED
|
File without changes
|
gyomu_python_analysis-0.2.0/python_analysis_test_support/fixtures/src/analysis/import/__init__.py
ADDED
|
File without changes
|
gyomu_python_analysis-0.2.0/python_analysis_test_support/fixtures/src/analysis/import/imports.py
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import pathlib # noqa: F401, I001
|
|
2
|
+
import pathlib as path # noqa: F401
|
|
3
|
+
from pydantic import BaseModel # noqa: F401
|
|
4
|
+
from pydantic import Field as fld # noqa: F401
|
|
5
|
+
from pydantic import Field as fld2 # noqa: F401
|
|
6
|
+
|
|
7
|
+
from .relative import Field as rel1 # noqa: F401
|
|
8
|
+
from ..shared import Value # noqa: F401
|
|
9
|
+
from .all import * # noqa: F403
|
|
10
|
+
from .all2 import * # noqa: F403
|
gyomu_python_analysis-0.2.0/python_analysis_test_support/fixtures/src/analysis/import/relative.py
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Field = "test"
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Value = 1.0
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
def call_simple():
|
|
2
|
+
return foo()
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
def call_with_positional_argument():
|
|
6
|
+
return foo(1)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def call_with_multiple_positional_arguments():
|
|
10
|
+
return foo(1, "value", bar)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def call_with_keyword_argument():
|
|
14
|
+
return foo(name="value")
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def call_with_multiple_keyword_arguments():
|
|
18
|
+
return foo(name="value", mode="before")
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def call_with_mixed_arguments():
|
|
22
|
+
return foo("name", mode="before")
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def call_with_nested_call():
|
|
26
|
+
return foo(bar(value))
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def call_with_keyword_call_value():
|
|
30
|
+
return foo(value=bar())
|