codeanalyzer-python 0.3.0__py3-none-any.whl → 1.0.0__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.
Files changed (46) hide show
  1. codeanalyzer/__main__.py +77 -4
  2. codeanalyzer/core.py +174 -72
  3. codeanalyzer/dataflow/__init__.py +35 -0
  4. codeanalyzer/dataflow/access_paths.py +563 -0
  5. codeanalyzer/dataflow/alias.py +93 -0
  6. codeanalyzer/dataflow/builder.py +688 -0
  7. codeanalyzer/dataflow/cfg.py +605 -0
  8. codeanalyzer/dataflow/defuse.py +113 -0
  9. codeanalyzer/dataflow/dominance.py +140 -0
  10. codeanalyzer/dataflow/identity.py +91 -0
  11. codeanalyzer/dataflow/pdg.py +100 -0
  12. codeanalyzer/dataflow/scalpel_oracle.py +269 -0
  13. codeanalyzer/dataflow/scc.py +91 -0
  14. codeanalyzer/dataflow/sdg.py +424 -0
  15. codeanalyzer/dataflow/slicing.py +93 -0
  16. codeanalyzer/dataflow/summaries.py +217 -0
  17. codeanalyzer/dataflow/syntactic.py +26 -0
  18. codeanalyzer/neo4j/__init__.py +1 -1
  19. codeanalyzer/neo4j/bolt.py +19 -4
  20. codeanalyzer/neo4j/cypher.py +9 -3
  21. codeanalyzer/neo4j/emit.py +10 -5
  22. codeanalyzer/neo4j/project.py +307 -60
  23. codeanalyzer/neo4j/rows.py +18 -15
  24. codeanalyzer/neo4j/schema.py +297 -15
  25. codeanalyzer/options/options.py +4 -0
  26. codeanalyzer/provenance.py +61 -0
  27. codeanalyzer/schema/__init__.py +19 -0
  28. codeanalyzer/schema/assign_ids.py +37 -0
  29. codeanalyzer/schema/call_graph_ids.py +12 -0
  30. codeanalyzer/schema/ids.py +23 -0
  31. codeanalyzer/schema/l1_body.py +29 -0
  32. codeanalyzer/schema/l2_callees.py +36 -0
  33. codeanalyzer/schema/py_schema.py +175 -26
  34. codeanalyzer/semantic_analysis/call_graph.py +24 -27
  35. codeanalyzer/semantic_analysis/pycg/pycg_analysis.py +10 -10
  36. codeanalyzer/semantic_analysis/pycg/shard_planner.py +7 -7
  37. codeanalyzer/syntactic_analysis/import_resolver.py +67 -0
  38. codeanalyzer/syntactic_analysis/symbol_table_builder.py +103 -20
  39. {codeanalyzer_python-0.3.0.dist-info → codeanalyzer_python-1.0.0.dist-info}/METADATA +233 -43
  40. codeanalyzer_python-1.0.0.dist-info/RECORD +59 -0
  41. {codeanalyzer_python-0.3.0.dist-info → codeanalyzer_python-1.0.0.dist-info}/WHEEL +1 -1
  42. codeanalyzer/neo4j/catalog.py +0 -245
  43. codeanalyzer_python-0.3.0.dist-info/RECORD +0 -38
  44. {codeanalyzer_python-0.3.0.dist-info → codeanalyzer_python-1.0.0.dist-info}/entry_points.txt +0 -0
  45. {codeanalyzer_python-0.3.0.dist-info → codeanalyzer_python-1.0.0.dist-info}/licenses/LICENSE +0 -0
  46. {codeanalyzer_python-0.3.0.dist-info → codeanalyzer_python-1.0.0.dist-info}/licenses/NOTICE +0 -0
@@ -1,245 +0,0 @@
1
- ################################################################################
2
- # Copyright IBM Corporation 2025
3
- #
4
- # Licensed under the Apache License, Version 2.0 (the "License");
5
- # you may not use this file except in compliance with the License.
6
- # You may obtain a copy of the License at
7
- #
8
- # http://www.apache.org/licenses/LICENSE-2.0
9
- #
10
- # Unless required by applicable law or agreed to in writing, software
11
- # distributed under the License is distributed on an "AS IS" BASIS,
12
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- # See the License for the specific language governing permissions and
14
- # limitations under the License.
15
- ################################################################################
16
-
17
- """The declarative Neo4j schema catalog — the single in-repo source of truth for
18
- the graph contract (node labels, their keys and typed properties, relationship
19
- types and their endpoints). ``--emit schema`` serializes this (with the DDL from
20
- :mod:`codeanalyzer.neo4j.schema`) to a machine-readable ``schema.json``, and the
21
- conformance test (``test/test_neo4j_schema.py``) asserts the real emitter never
22
- produces a label / relationship / property that isn't declared here — so this
23
- file cannot silently drift from :mod:`codeanalyzer.neo4j.project`.
24
-
25
- SCHEMA_VERSION is the contract version: bump MAJOR on a breaking change
26
- (renamed/removed label, relationship or key), MINOR on an additive change (new
27
- label/rel/property). It is stamped onto the ``:PyApplication`` node of every
28
- emitted graph so any consumer can detect a producer/consumer mismatch at runtime.
29
- """
30
- from __future__ import annotations
31
-
32
- from dataclasses import dataclass, field
33
- from typing import Dict, List
34
-
35
- from codeanalyzer.neo4j.schema import CONSTRAINTS, INDEXES
36
-
37
- SCHEMA_VERSION = "1.1.0"
38
-
39
- # PropType ∈ {"string", "integer", "float", "boolean", "string[]", "integer[]"}.
40
-
41
-
42
- @dataclass
43
- class NodeLabel:
44
- label: str # the specific label (also the catalog key)
45
- merge_label: str # the label the uniqueness constraint / MERGE is on
46
- key: str
47
- properties: Dict[str, str]
48
-
49
-
50
- @dataclass
51
- class RelType:
52
- type: str
53
- from_labels: List[str]
54
- to_labels: List[str]
55
- properties: Dict[str, str] = field(default_factory=dict)
56
-
57
-
58
- # Labels layered onto a node in addition to its primary/specific label.
59
- MARKER_LABELS: List[str] = []
60
-
61
- _SPAN = {"start_line": "integer", "end_line": "integer"}
62
-
63
-
64
- NODE_LABELS: List[NodeLabel] = [
65
- NodeLabel(
66
- "PyApplication",
67
- "PyApplication",
68
- "name",
69
- {"name": "string", "schema_version": "string"},
70
- ),
71
- NodeLabel(
72
- "PyModule",
73
- "PyModule",
74
- "file_key",
75
- {
76
- "file_key": "string",
77
- "module_name": "string",
78
- "content_hash": "string",
79
- "last_modified": "float",
80
- "file_size": "integer",
81
- "_module": "string",
82
- },
83
- ),
84
- NodeLabel(
85
- "PyClass",
86
- "PySymbol",
87
- "signature",
88
- {
89
- "signature": "string",
90
- "name": "string",
91
- "code": "string",
92
- "base_classes": "string[]",
93
- "docstring": "string",
94
- **_SPAN,
95
- "_module": "string",
96
- },
97
- ),
98
- NodeLabel(
99
- "PyCallable",
100
- "PySymbol",
101
- "signature",
102
- {
103
- "signature": "string",
104
- "name": "string",
105
- "path": "string",
106
- "return_type": "string",
107
- "cyclomatic_complexity": "integer",
108
- "code": "string",
109
- "code_start_line": "integer",
110
- **_SPAN,
111
- "docstring": "string",
112
- "decorators": "string[]",
113
- "parameters_json": "string",
114
- "accessed_symbols_json": "string",
115
- "_module": "string",
116
- },
117
- ),
118
- NodeLabel(
119
- "PyExternal",
120
- "PySymbol",
121
- "signature",
122
- {"signature": "string", "name": "string", "module": "string"},
123
- ),
124
- NodeLabel("PyPackage", "PyPackage", "name", {"name": "string"}),
125
- NodeLabel(
126
- "PyDecorator",
127
- "PyDecorator",
128
- "name",
129
- {"name": "string"},
130
- ),
131
- NodeLabel(
132
- "PyCallSite",
133
- "PyCallSite",
134
- "id",
135
- {
136
- "id": "string",
137
- "method_name": "string",
138
- "receiver_expr": "string",
139
- "receiver_type": "string",
140
- "argument_types": "string[]",
141
- "return_type": "string",
142
- "callee_signature": "string",
143
- "is_constructor_call": "boolean",
144
- "start_line": "integer",
145
- "start_column": "integer",
146
- "end_line": "integer",
147
- "end_column": "integer",
148
- "_module": "string",
149
- },
150
- ),
151
- NodeLabel(
152
- "PyAttribute",
153
- "PyAttribute",
154
- "id",
155
- {
156
- "id": "string",
157
- "name": "string",
158
- "type": "string",
159
- "docstring": "string",
160
- **_SPAN,
161
- "_module": "string",
162
- },
163
- ),
164
- NodeLabel(
165
- "PyVariable",
166
- "PyVariable",
167
- "id",
168
- {
169
- "id": "string",
170
- "name": "string",
171
- "type": "string",
172
- "initializer": "string",
173
- "scope": "string",
174
- **_SPAN,
175
- "_module": "string",
176
- },
177
- ),
178
- ]
179
-
180
- _DECL_TARGETS = ["PyClass", "PyCallable"]
181
-
182
-
183
- REL_TYPES: List[RelType] = [
184
- RelType("PY_HAS_MODULE", ["PyApplication"], ["PyModule"]),
185
- RelType("PY_DECLARES", ["PyModule", "PyClass", "PyCallable"], _DECL_TARGETS),
186
- RelType("PY_HAS_METHOD", ["PyClass"], ["PyCallable"]),
187
- RelType("PY_HAS_ATTRIBUTE", ["PyClass"], ["PyAttribute"]),
188
- RelType("PY_DECLARES_VAR", ["PyModule", "PyCallable"], ["PyVariable"]),
189
- RelType("PY_HAS_CALLSITE", ["PyCallable"], ["PyCallSite"]),
190
- RelType("PY_RESOLVES_TO", ["PyCallSite"], ["PyCallable", "PyExternal"]),
191
- RelType(
192
- "PY_CALLS",
193
- ["PyCallable", "PyExternal"],
194
- ["PyCallable", "PyExternal"],
195
- {"weight": "integer", "provenance": "string[]"},
196
- ),
197
- RelType("PY_EXTENDS", ["PyClass"], ["PyClass"]),
198
- RelType(
199
- "PY_IMPORTS",
200
- ["PyModule"],
201
- ["PyPackage"],
202
- {"imported_names": "string[]", "aliases": "string[]"},
203
- ),
204
- RelType("PY_DECORATED_BY", ["PyCallable"], ["PyDecorator"]),
205
- ]
206
-
207
-
208
- @dataclass
209
- class SchemaDocument:
210
- schema_version: str
211
- generator: str
212
- marker_labels: List[str]
213
- node_labels: List[NodeLabel]
214
- relationship_types: List[RelType]
215
- constraints: List[str]
216
- indexes: List[str]
217
-
218
-
219
- def build_schema_document() -> dict:
220
- """Build the full machine-readable schema document emitted by ``--emit schema``."""
221
- return {
222
- "schema_version": SCHEMA_VERSION,
223
- "generator": "codeanalyzer-python",
224
- "marker_labels": list(MARKER_LABELS),
225
- "node_labels": [
226
- {
227
- "label": n.label,
228
- "merge_label": n.merge_label,
229
- "key": n.key,
230
- "properties": n.properties,
231
- }
232
- for n in NODE_LABELS
233
- ],
234
- "relationship_types": [
235
- {
236
- "type": r.type,
237
- "from": r.from_labels,
238
- "to": r.to_labels,
239
- "properties": r.properties,
240
- }
241
- for r in REL_TYPES
242
- ],
243
- "constraints": list(CONSTRAINTS),
244
- "indexes": list(INDEXES),
245
- }
@@ -1,38 +0,0 @@
1
- codeanalyzer/__init__.py,sha256=BZ3Kuwl-F_F-8H8cepLnVJ4Ku4NNUjjqg0Y6ujPQSsI,108
2
- codeanalyzer/__main__.py,sha256=-los-YRXrmZsISNrWh8EjgUcUSkUbSGqEX7yadZuvB8,11920
3
- codeanalyzer/core.py,sha256=rUKEa4jAbQFtvAnkDKinBGznLpb6VquULLlMVoFjMTU,29533
4
- codeanalyzer/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
- codeanalyzer/config/__init__.py,sha256=9XBxAn1oWGRuhg3bEBUuVGs3hFNXEAKrr-Ce7tq9a2k,61
6
- codeanalyzer/config/config.py,sha256=ZiKzc5uEUCIvih58-6BDtLLI1hPij41wGQjBcj9KNQM,188
7
- codeanalyzer/jedi/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
8
- codeanalyzer/jedi/jedi.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
9
- codeanalyzer/neo4j/__init__.py,sha256=AcbFNAMuXwkMFWH4h_HCmla6PCKTF3Xe5yNqg8F_kYk,1575
10
- codeanalyzer/neo4j/bolt.py,sha256=-IFDb_d67IkGwxvmmbLNI6AvSQHY-XsutI3szibWidw,9635
11
- codeanalyzer/neo4j/catalog.py,sha256=VQWtwcueck2Ug_cu8sitvAoRwbVZ-6KRiexRN8q1Wak,7418
12
- codeanalyzer/neo4j/cypher.py,sha256=2zIWXA1AADrwCMhSTeqKjEXRgBjbob6o3bme_cwLu0s,5024
13
- codeanalyzer/neo4j/emit.py,sha256=WtCndN6mA6PIzfzdgv9Xc5S5WP4rHUXCtB_r3G16rkg,3101
14
- codeanalyzer/neo4j/project.py,sha256=2GDHkFjmWibrpMaOiDMo21K6Lnj3aefl2QPCM7ANA7g,12485
15
- codeanalyzer/neo4j/rows.py,sha256=5xI3X-l-vwPe_gmKYUg7VuUQARcOlVAZnGmiQr9QyRk,7326
16
- codeanalyzer/neo4j/schema.py,sha256=5xz8cZVuL73GAF-vs9QtN2TuKxIty0rHEe68nwQmLTY,2136
17
- codeanalyzer/options/__init__.py,sha256=Ki4qhHFqpyuUWVsntO-NYJMVWrkeFOzPW4nQ7oxiUVI,155
18
- codeanalyzer/options/options.py,sha256=5w3DZYlAv-0LVPavF1P5EEJp8XBRrSXidbDusdbXQAo,1976
19
- codeanalyzer/schema/__init__.py,sha256=cLPjvowrnz8xzi7tZAsKQeIOjdOKRGHy4I7wbG0jHk8,2024
20
- codeanalyzer/schema/py_schema.py,sha256=6hISjVzoWTq-SHLjT7FsL__uzHT5DY0NYqlpJTLsc9s,12314
21
- codeanalyzer/semantic_analysis/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
22
- codeanalyzer/semantic_analysis/call_graph.py,sha256=H3IkfGp1VCkDxI75JPyLSSA-wOaJp_I-NYPsjCY04Bg,11185
23
- codeanalyzer/semantic_analysis/pycg/__init__.py,sha256=Lsgz25iFM_RGGu_i2psY-LN-KwvYIZQPnKgRPL1JsjU,928
24
- codeanalyzer/semantic_analysis/pycg/pycg_analysis.py,sha256=22kiZ2Kjpds024iFLu2bPEcCtAKAivdp1Xlr9rfP9lM,45205
25
- codeanalyzer/semantic_analysis/pycg/pycg_exceptions.py,sha256=n4tRderrSYw9cUYgR2wsn64UqozY56nD1YfDNnaVcAk,968
26
- codeanalyzer/semantic_analysis/pycg/shard_planner.py,sha256=PTXMG9YcrZX9hgnlnIlpQx6xmWkizP3aQrf0elcrnmw,15865
27
- codeanalyzer/syntactic_analysis/__init__.py,sha256=EUQkJEh6wHjWx2qTTKbTbUgwSbfKeNieKHNy7RknVXA,476
28
- codeanalyzer/syntactic_analysis/exceptions.py,sha256=whs_n0vIu655Jkk1a7iOoXY6iIca4pZqJnU40V9Ejaw,537
29
- codeanalyzer/syntactic_analysis/symbol_table_builder.py,sha256=zmHFt8pN50jG-Ex4fnisvbLmn1XaW05jwbV_xSG4qfU,38177
30
- codeanalyzer/utils/__init__.py,sha256=hC6VWdR5rerSqBxzu9KQHTASWqwrrYJv-CMDwrTlzkc,137
31
- codeanalyzer/utils/logging.py,sha256=Fw0tattPAOMs3o0JMjjXhRVLIF64f-SCcygUXF9jqeg,904
32
- codeanalyzer/utils/progress_bar.py,sha256=C9JtzVdd10lIxTv-KA6PebqjKWueC_vMGwVzAtHuHIw,2818
33
- codeanalyzer_python-0.3.0.dist-info/METADATA,sha256=l7oUfSjJiPF1mvfQQOmm6JyzIWOBveKKp8xHJF0dw-E,33777
34
- codeanalyzer_python-0.3.0.dist-info/WHEEL,sha256=mffPy8wBnZQn2VnJUU5jE99KsxaSfiyMHV9Yt0aLVxs,87
35
- codeanalyzer_python-0.3.0.dist-info/entry_points.txt,sha256=v4Vux0Nnx7sOntVk_CH7W9RX6SkIkvR1FQYq73oVlCQ,105
36
- codeanalyzer_python-0.3.0.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
37
- codeanalyzer_python-0.3.0.dist-info/licenses/NOTICE,sha256=YU0Z9NDWqKY-2jfFcbxeZ6fbnzz0oZeKmnUcO8a-bcQ,901
38
- codeanalyzer_python-0.3.0.dist-info/RECORD,,