deproc-python 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.
- {deproc_python-0.2.0 → deproc_python-0.3.0}/PKG-INFO +2 -2
- deproc_python-0.3.0/deproc/plugins/python/__init__.py +21 -0
- {deproc_python-0.2.0 → deproc_python-0.3.0}/deproc/plugins/python/linker/main.py +12 -5
- deproc_python-0.3.0/deproc/plugins/python/linker/models.py +46 -0
- {deproc_python-0.2.0 → deproc_python-0.3.0}/deproc/plugins/python/parser/main.py +1 -0
- deproc_python-0.3.0/deproc/plugins/python/resolver/__init__.py +15 -0
- deproc_python-0.3.0/deproc/plugins/python/resolver/main.py +686 -0
- deproc_python-0.3.0/deproc/plugins/python/resolver/models.py +65 -0
- {deproc_python-0.2.0 → deproc_python-0.3.0}/deproc/plugins/python/utils/exports.py +15 -6
- {deproc_python-0.2.0 → deproc_python-0.3.0}/deproc/plugins/python/utils/mro.py +18 -0
- deproc_python-0.3.0/deproc/plugins/python/utils/packages.py +115 -0
- {deproc_python-0.2.0 → deproc_python-0.3.0}/deproc/plugins/python/utils/serialization.py +14 -0
- {deproc_python-0.2.0 → deproc_python-0.3.0}/deproc_python.egg-info/PKG-INFO +2 -2
- {deproc_python-0.2.0 → deproc_python-0.3.0}/deproc_python.egg-info/SOURCES.txt +2 -0
- {deproc_python-0.2.0 → deproc_python-0.3.0}/deproc_python.egg-info/requires.txt +1 -1
- {deproc_python-0.2.0 → deproc_python-0.3.0}/pyproject.toml +2 -2
- {deproc_python-0.2.0 → deproc_python-0.3.0}/tests/test_exports.py +102 -0
- {deproc_python-0.2.0 → deproc_python-0.3.0}/tests/test_linker.py +117 -1
- {deproc_python-0.2.0 → deproc_python-0.3.0}/tests/test_mro.py +21 -1
- deproc_python-0.3.0/tests/test_package_precedence.py +130 -0
- deproc_python-0.3.0/tests/test_python_serialization.py +281 -0
- {deproc_python-0.2.0 → deproc_python-0.3.0}/tests/test_resolver.py +628 -0
- deproc_python-0.2.0/deproc/plugins/python/__init__.py +0 -11
- deproc_python-0.2.0/deproc/plugins/python/linker/models.py +0 -26
- deproc_python-0.2.0/deproc/plugins/python/resolver/__init__.py +0 -3
- deproc_python-0.2.0/deproc/plugins/python/resolver/main.py +0 -426
- deproc_python-0.2.0/deproc/plugins/python/resolver/models.py +0 -12
- deproc_python-0.2.0/tests/test_python_serialization.py +0 -97
- {deproc_python-0.2.0 → deproc_python-0.3.0}/deproc/plugins/python/linker/__init__.py +0 -0
- {deproc_python-0.2.0 → deproc_python-0.3.0}/deproc/plugins/python/parser/__init__.py +0 -0
- {deproc_python-0.2.0 → deproc_python-0.3.0}/deproc/plugins/python/parser/models.py +0 -0
- {deproc_python-0.2.0 → deproc_python-0.3.0}/deproc/plugins/python/parser/utils/extraction.py +0 -0
- {deproc_python-0.2.0 → deproc_python-0.3.0}/deproc/plugins/python/parser/utils/misc.py +0 -0
- {deproc_python-0.2.0 → deproc_python-0.3.0}/deproc/plugins/python/parser/utils/tree_sitter_python.py +0 -0
- {deproc_python-0.2.0 → deproc_python-0.3.0}/deproc/plugins/python/symbol_cache/__init__.py +0 -0
- {deproc_python-0.2.0 → deproc_python-0.3.0}/deproc/plugins/python/symbol_cache/main.py +0 -0
- {deproc_python-0.2.0 → deproc_python-0.3.0}/deproc/plugins/python/symbol_cache/models.py +0 -0
- {deproc_python-0.2.0 → deproc_python-0.3.0}/deproc/plugins/python/utils/imports.py +0 -0
- {deproc_python-0.2.0 → deproc_python-0.3.0}/deproc_python.egg-info/dependency_links.txt +0 -0
- {deproc_python-0.2.0 → deproc_python-0.3.0}/deproc_python.egg-info/top_level.txt +0 -0
- {deproc_python-0.2.0 → deproc_python-0.3.0}/setup.cfg +0 -0
- {deproc_python-0.2.0 → deproc_python-0.3.0}/tests/test_imports.py +0 -0
- {deproc_python-0.2.0 → deproc_python-0.3.0}/tests/test_parser.py +0 -0
- {deproc_python-0.2.0 → deproc_python-0.3.0}/tests/test_symbol_cache.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: deproc-python
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.3.0
|
|
4
4
|
Summary: Python language plugin for deproc.
|
|
5
5
|
Author-email: Gurveer Singh Virk <gurveervirk.15517@gmail.com>
|
|
6
6
|
License: Apache-2.0
|
|
@@ -16,7 +16,7 @@ Classifier: Programming Language :: Python :: 3.12
|
|
|
16
16
|
Classifier: Programming Language :: Python :: 3.13
|
|
17
17
|
Classifier: Topic :: Software Development :: Libraries
|
|
18
18
|
Requires-Python: >=3.12
|
|
19
|
-
Requires-Dist: deproc-core>=0.
|
|
19
|
+
Requires-Dist: deproc-core>=0.4.0
|
|
20
20
|
Requires-Dist: deproc-utils-tree-sitter>=0.1.2
|
|
21
21
|
Requires-Dist: tree-sitter>=0.25.2
|
|
22
22
|
Requires-Dist: tree-sitter-python>=0.25.0
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
from .linker import PythonLinker
|
|
2
|
+
from .parser import PythonSourceParser
|
|
3
|
+
from .resolver import (
|
|
4
|
+
PythonBaseResolution,
|
|
5
|
+
PythonClassMROResult,
|
|
6
|
+
PythonInheritedMember,
|
|
7
|
+
PythonInheritedMembersResult,
|
|
8
|
+
PythonResolver,
|
|
9
|
+
)
|
|
10
|
+
from .symbol_cache import PythonSymbolCache
|
|
11
|
+
|
|
12
|
+
__all__ = [
|
|
13
|
+
"PythonBaseResolution",
|
|
14
|
+
"PythonClassMROResult",
|
|
15
|
+
"PythonInheritedMember",
|
|
16
|
+
"PythonInheritedMembersResult",
|
|
17
|
+
"PythonLinker",
|
|
18
|
+
"PythonResolver",
|
|
19
|
+
"PythonSourceParser",
|
|
20
|
+
"PythonSymbolCache",
|
|
21
|
+
]
|
|
@@ -3,16 +3,19 @@ from pathlib import Path
|
|
|
3
3
|
|
|
4
4
|
from deproc.core.context import Context
|
|
5
5
|
from deproc.core.interfaces import Linker
|
|
6
|
+
from deproc.core.interfaces.parser.models import SemanticContainer
|
|
6
7
|
|
|
7
8
|
from ..parser.models import PythonModule
|
|
8
9
|
from .models import Node, PythonNamespacePackage, PythonPackage
|
|
9
10
|
|
|
10
11
|
|
|
11
|
-
class PythonLinker(Linker[PythonModule, Node]):
|
|
12
|
+
class PythonLinker(Linker[PythonModule, Node | SemanticContainer]):
|
|
12
13
|
def _check_skip_patterns(self, path: str, skip_patterns: set[str]) -> bool:
|
|
13
14
|
return any(fnmatch.fnmatch(path, pattern) for pattern in skip_patterns)
|
|
14
15
|
|
|
15
|
-
def link_files(
|
|
16
|
+
def link_files(
|
|
17
|
+
self, nodes: list[PythonModule], context: Context
|
|
18
|
+
) -> list[Node | SemanticContainer]:
|
|
16
19
|
base_path = Path(context.base_path)
|
|
17
20
|
|
|
18
21
|
path_to_module: dict[str, PythonModule] = {}
|
|
@@ -29,7 +32,7 @@ class PythonLinker(Linker[PythonModule, Node]):
|
|
|
29
32
|
path_to_module[relative_path] = node
|
|
30
33
|
|
|
31
34
|
skip_patterns = context.skip_paths
|
|
32
|
-
top_level: list[Node] = []
|
|
35
|
+
top_level: list[Node | SemanticContainer] = []
|
|
33
36
|
for sub_path in base_path.iterdir():
|
|
34
37
|
if sub_path.name == "__pycache__":
|
|
35
38
|
continue
|
|
@@ -61,7 +64,7 @@ class PythonLinker(Linker[PythonModule, Node]):
|
|
|
61
64
|
path_to_module: dict[str, PythonModule],
|
|
62
65
|
has_init: dict[str, PythonModule],
|
|
63
66
|
context: Context,
|
|
64
|
-
) -> Node | None:
|
|
67
|
+
) -> Node | SemanticContainer | None:
|
|
65
68
|
if not self.validate_path(str(current_path)):
|
|
66
69
|
return None
|
|
67
70
|
|
|
@@ -94,5 +97,9 @@ class PythonLinker(Linker[PythonModule, Node]):
|
|
|
94
97
|
sub_node.parent_id = package.id
|
|
95
98
|
package.submodule_ids.append(sub_node.id)
|
|
96
99
|
|
|
97
|
-
|
|
100
|
+
if isinstance(package, SemanticContainer):
|
|
101
|
+
package.submodule_ids = sorted(set(package.submodule_ids))
|
|
102
|
+
package = context.entity_registry.merge_semantic_container(package)
|
|
103
|
+
else:
|
|
104
|
+
context.entity_registry.add(package)
|
|
98
105
|
return package
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
from dataclasses import dataclass, field
|
|
2
|
+
|
|
3
|
+
from deproc.core.interfaces.parser.models import Node, SemanticContainer
|
|
4
|
+
|
|
5
|
+
from ..parser.models import (
|
|
6
|
+
PythonModule,
|
|
7
|
+
SymbolID,
|
|
8
|
+
)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
@dataclass
|
|
12
|
+
class PythonNamespacePackage(SemanticContainer):
|
|
13
|
+
path: str
|
|
14
|
+
fqn: str
|
|
15
|
+
submodule_ids: list[SymbolID] = field(default_factory=list)
|
|
16
|
+
|
|
17
|
+
@property
|
|
18
|
+
def semantic_type(self) -> str:
|
|
19
|
+
return "python.namespace-package"
|
|
20
|
+
|
|
21
|
+
def __post_init__(self) -> None:
|
|
22
|
+
super().__post_init__()
|
|
23
|
+
self.submodule_ids = sorted(set(self.submodule_ids))
|
|
24
|
+
|
|
25
|
+
@property
|
|
26
|
+
def contribution_ids(self) -> list[SymbolID]:
|
|
27
|
+
return self.submodule_ids
|
|
28
|
+
|
|
29
|
+
def _merge_contributions(self, other: SemanticContainer) -> None:
|
|
30
|
+
if not isinstance(other, PythonNamespacePackage):
|
|
31
|
+
raise ValueError(
|
|
32
|
+
"Namespace packages can only merge with namespace packages"
|
|
33
|
+
)
|
|
34
|
+
self.submodule_ids = sorted(set(self.submodule_ids) | set(other.submodule_ids))
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
@dataclass(kw_only=True)
|
|
38
|
+
class PythonPackage(PythonModule):
|
|
39
|
+
submodule_ids: list[SymbolID] = field(default_factory=list)
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
__all__ = [
|
|
43
|
+
"Node",
|
|
44
|
+
"PythonNamespacePackage",
|
|
45
|
+
"PythonPackage",
|
|
46
|
+
]
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
from .main import PythonResolver
|
|
2
|
+
from .models import (
|
|
3
|
+
PythonBaseResolution,
|
|
4
|
+
PythonClassMROResult,
|
|
5
|
+
PythonInheritedMember,
|
|
6
|
+
PythonInheritedMembersResult,
|
|
7
|
+
)
|
|
8
|
+
|
|
9
|
+
__all__ = [
|
|
10
|
+
"PythonBaseResolution",
|
|
11
|
+
"PythonClassMROResult",
|
|
12
|
+
"PythonInheritedMember",
|
|
13
|
+
"PythonInheritedMembersResult",
|
|
14
|
+
"PythonResolver",
|
|
15
|
+
]
|