deproc-python 0.1.1__py3-none-any.whl → 0.2.1__py3-none-any.whl
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.
- deproc/plugins/python/__init__.py +11 -1
- deproc/plugins/python/linker/__init__.py +1 -1
- deproc/plugins/python/linker/main.py +28 -23
- deproc/plugins/python/linker/models.py +6 -1
- deproc/plugins/python/parser/__init__.py +1 -1
- deproc/plugins/python/parser/main.py +413 -143
- deproc/plugins/python/parser/models.py +15 -3
- deproc/plugins/python/parser/utils/extraction.py +76 -43
- deproc/plugins/python/parser/utils/misc.py +0 -1
- deproc/plugins/python/parser/utils/tree_sitter_python.py +14 -10
- deproc/plugins/python/resolver/__init__.py +13 -1
- deproc/plugins/python/resolver/main.py +538 -79
- deproc/plugins/python/resolver/models.py +57 -2
- deproc/plugins/python/symbol_cache/__init__.py +1 -1
- deproc/plugins/python/symbol_cache/main.py +39 -21
- deproc/plugins/python/symbol_cache/models.py +3 -1
- deproc/plugins/python/utils/exports.py +142 -7
- deproc/plugins/python/utils/mro.py +21 -2
- deproc/plugins/python/utils/serialization.py +137 -33
- {deproc_python-0.1.1.dist-info → deproc_python-0.2.1.dist-info}/METADATA +5 -6
- deproc_python-0.2.1.dist-info/RECORD +24 -0
- {deproc_python-0.1.1.dist-info → deproc_python-0.2.1.dist-info}/WHEEL +1 -1
- deproc_python-0.1.1.dist-info/RECORD +0 -24
- {deproc_python-0.1.1.dist-info → deproc_python-0.2.1.dist-info}/top_level.txt +0 -0
|
@@ -1,9 +1,19 @@
|
|
|
1
1
|
from .linker import PythonLinker
|
|
2
2
|
from .parser import PythonSourceParser
|
|
3
|
-
from .resolver import
|
|
3
|
+
from .resolver import (
|
|
4
|
+
PythonBaseResolution,
|
|
5
|
+
PythonClassMROResult,
|
|
6
|
+
PythonInheritedMember,
|
|
7
|
+
PythonInheritedMembersResult,
|
|
8
|
+
PythonResolver,
|
|
9
|
+
)
|
|
4
10
|
from .symbol_cache import PythonSymbolCache
|
|
5
11
|
|
|
6
12
|
__all__ = [
|
|
13
|
+
"PythonBaseResolution",
|
|
14
|
+
"PythonClassMROResult",
|
|
15
|
+
"PythonInheritedMember",
|
|
16
|
+
"PythonInheritedMembersResult",
|
|
7
17
|
"PythonLinker",
|
|
8
18
|
"PythonResolver",
|
|
9
19
|
"PythonSourceParser",
|
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
import fnmatch
|
|
2
|
-
from deproc.core.interfaces import Linker
|
|
3
|
-
from deproc.core.context import Context
|
|
4
2
|
from pathlib import Path
|
|
3
|
+
|
|
4
|
+
from deproc.core.context import Context
|
|
5
|
+
from deproc.core.interfaces import Linker
|
|
6
|
+
|
|
5
7
|
from ..parser.models import PythonModule
|
|
6
|
-
from .models import
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
)
|
|
11
|
-
|
|
12
|
-
class PythonLinker(Linker[list[PythonModule], list[Node]]):
|
|
13
|
-
def _check_skip_patterns(self, path: str, skip_patterns: list[str]) -> bool:
|
|
8
|
+
from .models import Node, PythonNamespacePackage, PythonPackage
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class PythonLinker(Linker[PythonModule, Node]):
|
|
12
|
+
def _check_skip_patterns(self, path: str, skip_patterns: set[str]) -> bool:
|
|
14
13
|
return any(fnmatch.fnmatch(path, pattern) for pattern in skip_patterns)
|
|
15
14
|
|
|
16
15
|
def link_files(self, nodes: list[PythonModule], context: Context) -> list[Node]:
|
|
@@ -38,7 +37,9 @@ class PythonLinker(Linker[list[PythonModule], list[Node]]):
|
|
|
38
37
|
continue
|
|
39
38
|
if not self.validate_path(str(sub_path)):
|
|
40
39
|
continue
|
|
41
|
-
sub_node = self.traverse_path(
|
|
40
|
+
sub_node = self.traverse_path(
|
|
41
|
+
base_path, sub_path, path_to_module, has_init, context
|
|
42
|
+
)
|
|
42
43
|
if sub_node:
|
|
43
44
|
sub_node.parent_id = None
|
|
44
45
|
top_level.append(sub_node)
|
|
@@ -46,19 +47,24 @@ class PythonLinker(Linker[list[PythonModule], list[Node]]):
|
|
|
46
47
|
return top_level
|
|
47
48
|
|
|
48
49
|
def validate_path(self, path: str) -> bool:
|
|
49
|
-
return
|
|
50
|
+
return (
|
|
51
|
+
path.endswith(".py")
|
|
52
|
+
or path.endswith(".pyi")
|
|
53
|
+
or path.endswith("__init__.py")
|
|
54
|
+
or Path(path).is_dir()
|
|
55
|
+
)
|
|
50
56
|
|
|
51
57
|
def traverse_path(
|
|
52
|
-
self,
|
|
53
|
-
base_path: Path,
|
|
54
|
-
current_path: Path,
|
|
55
|
-
path_to_module: dict[str, PythonModule],
|
|
58
|
+
self,
|
|
59
|
+
base_path: Path,
|
|
60
|
+
current_path: Path,
|
|
61
|
+
path_to_module: dict[str, PythonModule],
|
|
56
62
|
has_init: dict[str, PythonModule],
|
|
57
|
-
context: Context
|
|
63
|
+
context: Context,
|
|
58
64
|
) -> Node | None:
|
|
59
65
|
if not self.validate_path(str(current_path)):
|
|
60
66
|
return None
|
|
61
|
-
|
|
67
|
+
|
|
62
68
|
relative_path = str(current_path.relative_to(base_path)).replace("\\", "/")
|
|
63
69
|
|
|
64
70
|
if relative_path.endswith(".py") or relative_path.endswith(".pyi"):
|
|
@@ -68,10 +74,7 @@ class PythonLinker(Linker[list[PythonModule], list[Node]]):
|
|
|
68
74
|
fqn = relative_path.replace("/", ".")
|
|
69
75
|
|
|
70
76
|
if relative_path in has_init:
|
|
71
|
-
package = PythonPackage(
|
|
72
|
-
submodule_ids=[],
|
|
73
|
-
**vars(has_init[relative_path])
|
|
74
|
-
)
|
|
77
|
+
package = PythonPackage(submodule_ids=[], **vars(has_init[relative_path]))
|
|
75
78
|
else:
|
|
76
79
|
package = PythonNamespacePackage(
|
|
77
80
|
path=relative_path,
|
|
@@ -84,7 +87,9 @@ class PythonLinker(Linker[list[PythonModule], list[Node]]):
|
|
|
84
87
|
continue
|
|
85
88
|
if self._check_skip_patterns(sub_path.name, context.skip_paths):
|
|
86
89
|
continue
|
|
87
|
-
sub_node = self.traverse_path(
|
|
90
|
+
sub_node = self.traverse_path(
|
|
91
|
+
base_path, sub_path, path_to_module, has_init, context
|
|
92
|
+
)
|
|
88
93
|
if sub_node:
|
|
89
94
|
sub_node.parent_id = package.id
|
|
90
95
|
package.submodule_ids.append(sub_node.id)
|
|
@@ -1,19 +1,24 @@
|
|
|
1
|
-
from deproc.core.interfaces.parser.models import Node
|
|
2
1
|
from dataclasses import dataclass, field
|
|
2
|
+
|
|
3
|
+
from deproc.core.interfaces.parser.models import Node
|
|
4
|
+
|
|
3
5
|
from ..parser.models import (
|
|
4
6
|
PythonModule,
|
|
5
7
|
SymbolID,
|
|
6
8
|
)
|
|
7
9
|
|
|
10
|
+
|
|
8
11
|
@dataclass
|
|
9
12
|
class PythonNamespacePackage(Node):
|
|
10
13
|
fqn: str
|
|
11
14
|
submodule_ids: list[SymbolID] = field(default_factory=list)
|
|
12
15
|
|
|
16
|
+
|
|
13
17
|
@dataclass(kw_only=True)
|
|
14
18
|
class PythonPackage(PythonModule):
|
|
15
19
|
submodule_ids: list[SymbolID] = field(default_factory=list)
|
|
16
20
|
|
|
21
|
+
|
|
17
22
|
__all__ = [
|
|
18
23
|
"Node",
|
|
19
24
|
"PythonNamespacePackage",
|