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.
Files changed (44) hide show
  1. {deproc_python-0.2.0 → deproc_python-0.3.0}/PKG-INFO +2 -2
  2. deproc_python-0.3.0/deproc/plugins/python/__init__.py +21 -0
  3. {deproc_python-0.2.0 → deproc_python-0.3.0}/deproc/plugins/python/linker/main.py +12 -5
  4. deproc_python-0.3.0/deproc/plugins/python/linker/models.py +46 -0
  5. {deproc_python-0.2.0 → deproc_python-0.3.0}/deproc/plugins/python/parser/main.py +1 -0
  6. deproc_python-0.3.0/deproc/plugins/python/resolver/__init__.py +15 -0
  7. deproc_python-0.3.0/deproc/plugins/python/resolver/main.py +686 -0
  8. deproc_python-0.3.0/deproc/plugins/python/resolver/models.py +65 -0
  9. {deproc_python-0.2.0 → deproc_python-0.3.0}/deproc/plugins/python/utils/exports.py +15 -6
  10. {deproc_python-0.2.0 → deproc_python-0.3.0}/deproc/plugins/python/utils/mro.py +18 -0
  11. deproc_python-0.3.0/deproc/plugins/python/utils/packages.py +115 -0
  12. {deproc_python-0.2.0 → deproc_python-0.3.0}/deproc/plugins/python/utils/serialization.py +14 -0
  13. {deproc_python-0.2.0 → deproc_python-0.3.0}/deproc_python.egg-info/PKG-INFO +2 -2
  14. {deproc_python-0.2.0 → deproc_python-0.3.0}/deproc_python.egg-info/SOURCES.txt +2 -0
  15. {deproc_python-0.2.0 → deproc_python-0.3.0}/deproc_python.egg-info/requires.txt +1 -1
  16. {deproc_python-0.2.0 → deproc_python-0.3.0}/pyproject.toml +2 -2
  17. {deproc_python-0.2.0 → deproc_python-0.3.0}/tests/test_exports.py +102 -0
  18. {deproc_python-0.2.0 → deproc_python-0.3.0}/tests/test_linker.py +117 -1
  19. {deproc_python-0.2.0 → deproc_python-0.3.0}/tests/test_mro.py +21 -1
  20. deproc_python-0.3.0/tests/test_package_precedence.py +130 -0
  21. deproc_python-0.3.0/tests/test_python_serialization.py +281 -0
  22. {deproc_python-0.2.0 → deproc_python-0.3.0}/tests/test_resolver.py +628 -0
  23. deproc_python-0.2.0/deproc/plugins/python/__init__.py +0 -11
  24. deproc_python-0.2.0/deproc/plugins/python/linker/models.py +0 -26
  25. deproc_python-0.2.0/deproc/plugins/python/resolver/__init__.py +0 -3
  26. deproc_python-0.2.0/deproc/plugins/python/resolver/main.py +0 -426
  27. deproc_python-0.2.0/deproc/plugins/python/resolver/models.py +0 -12
  28. deproc_python-0.2.0/tests/test_python_serialization.py +0 -97
  29. {deproc_python-0.2.0 → deproc_python-0.3.0}/deproc/plugins/python/linker/__init__.py +0 -0
  30. {deproc_python-0.2.0 → deproc_python-0.3.0}/deproc/plugins/python/parser/__init__.py +0 -0
  31. {deproc_python-0.2.0 → deproc_python-0.3.0}/deproc/plugins/python/parser/models.py +0 -0
  32. {deproc_python-0.2.0 → deproc_python-0.3.0}/deproc/plugins/python/parser/utils/extraction.py +0 -0
  33. {deproc_python-0.2.0 → deproc_python-0.3.0}/deproc/plugins/python/parser/utils/misc.py +0 -0
  34. {deproc_python-0.2.0 → deproc_python-0.3.0}/deproc/plugins/python/parser/utils/tree_sitter_python.py +0 -0
  35. {deproc_python-0.2.0 → deproc_python-0.3.0}/deproc/plugins/python/symbol_cache/__init__.py +0 -0
  36. {deproc_python-0.2.0 → deproc_python-0.3.0}/deproc/plugins/python/symbol_cache/main.py +0 -0
  37. {deproc_python-0.2.0 → deproc_python-0.3.0}/deproc/plugins/python/symbol_cache/models.py +0 -0
  38. {deproc_python-0.2.0 → deproc_python-0.3.0}/deproc/plugins/python/utils/imports.py +0 -0
  39. {deproc_python-0.2.0 → deproc_python-0.3.0}/deproc_python.egg-info/dependency_links.txt +0 -0
  40. {deproc_python-0.2.0 → deproc_python-0.3.0}/deproc_python.egg-info/top_level.txt +0 -0
  41. {deproc_python-0.2.0 → deproc_python-0.3.0}/setup.cfg +0 -0
  42. {deproc_python-0.2.0 → deproc_python-0.3.0}/tests/test_imports.py +0 -0
  43. {deproc_python-0.2.0 → deproc_python-0.3.0}/tests/test_parser.py +0 -0
  44. {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.2.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.2.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(self, nodes: list[PythonModule], context: Context) -> list[Node]:
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
- context.entity_registry.add(package)
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
+ ]
@@ -91,6 +91,7 @@ class PythonSourceParser(SourceParser):
91
91
  source_file = PythonModule(
92
92
  fqn=parent_fqn,
93
93
  path=relative_path,
94
+ source_root_id=context.source_root_id,
94
95
  docstring_range=docstring_range,
95
96
  source=source_bytes.decode("utf-8"),
96
97
  )
@@ -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
+ ]