swarmauri_evaluator_externalimports 0.3.0.dev45__tar.gz → 0.11.0.dev1__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.
- {swarmauri_evaluator_externalimports-0.3.0.dev45 → swarmauri_evaluator_externalimports-0.11.0.dev1}/PKG-INFO +19 -22
- {swarmauri_evaluator_externalimports-0.3.0.dev45 → swarmauri_evaluator_externalimports-0.11.0.dev1}/README.md +12 -17
- {swarmauri_evaluator_externalimports-0.3.0.dev45 → swarmauri_evaluator_externalimports-0.11.0.dev1}/pyproject.toml +9 -7
- {swarmauri_evaluator_externalimports-0.3.0.dev45 → swarmauri_evaluator_externalimports-0.11.0.dev1}/swarmauri_evaluator_externalimports/ExternalImportsEvaluator.py +44 -18
- {swarmauri_evaluator_externalimports-0.3.0.dev45 → swarmauri_evaluator_externalimports-0.11.0.dev1}/LICENSE +0 -0
- {swarmauri_evaluator_externalimports-0.3.0.dev45 → swarmauri_evaluator_externalimports-0.11.0.dev1}/swarmauri_evaluator_externalimports/__init__.py +0 -0
|
@@ -1,52 +1,47 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: swarmauri_evaluator_externalimports
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.11.0.dev1
|
|
4
4
|
Summary: Evaluator that detects and penalizes non-built-in Python imports in source files
|
|
5
5
|
License-Expression: Apache-2.0
|
|
6
6
|
License-File: LICENSE
|
|
7
7
|
Keywords: swarmauri,evaluator,imports,dependencies,static analysis,code quality,external modules,standard library,sdk,standards,externalimports,evaluation
|
|
8
8
|
Author: Jacob Stewart
|
|
9
9
|
Author-email: jacob@swarmauri.com
|
|
10
|
-
Requires-Python: >=3.10,<3.
|
|
10
|
+
Requires-Python: >=3.10,<3.15
|
|
11
11
|
Classifier: License :: OSI Approved :: Apache Software License
|
|
12
12
|
Classifier: Natural Language :: English
|
|
13
|
-
Classifier: Programming Language :: Python :: 3.10
|
|
14
|
-
Classifier: Programming Language :: Python :: 3.11
|
|
15
|
-
Classifier: Programming Language :: Python :: 3.12
|
|
16
13
|
Classifier: Development Status :: 3 - Alpha
|
|
17
14
|
Classifier: Programming Language :: Python
|
|
18
15
|
Classifier: Programming Language :: Python :: 3
|
|
19
16
|
Classifier: Programming Language :: Python :: 3 :: Only
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
20
22
|
Requires-Dist: swarmauri_base
|
|
21
23
|
Requires-Dist: swarmauri_core
|
|
22
24
|
Description-Content-Type: text/markdown
|
|
23
25
|
|
|
24
|
-

|
|
25
27
|
|
|
26
28
|
<p align="center">
|
|
27
|
-
<a href="https://
|
|
28
|
-
<img src="https://
|
|
29
|
-
</a>
|
|
29
|
+
<a href="https://pepy.tech/project/swarmauri_evaluator_externalimports/">
|
|
30
|
+
<img src="https://static.pepy.tech/badge/swarmauri_evaluator_externalimports/month" alt="PyPI - Downloads"/></a>
|
|
30
31
|
<a href="https://hits.sh/github.com/swarmauri/swarmauri-sdk/tree/master/pkgs/standards/swarmauri_evaluator_externalimports/">
|
|
31
|
-
<img alt="Hits" src="https://hits.sh/github.com/swarmauri/swarmauri-sdk/tree/master/pkgs/standards/swarmauri_evaluator_externalimports.svg"
|
|
32
|
-
</a>
|
|
32
|
+
<img alt="Hits" src="https://hits.sh/github.com/swarmauri/swarmauri-sdk/tree/master/pkgs/standards/swarmauri_evaluator_externalimports.svg"/></a>
|
|
33
33
|
<a href="https://pypi.org/project/swarmauri_evaluator_externalimports/">
|
|
34
|
-
<img src="https://img.shields.io/
|
|
35
|
-
</a>
|
|
34
|
+
<img src="https://img.shields.io/badge/python-3.10%20%7C%203.11%20%7C%203.12%20%7C%203.13%20%7C%203.14-blue" alt="PyPI - Python Version"/></a>
|
|
36
35
|
<a href="https://pypi.org/project/swarmauri_evaluator_externalimports/">
|
|
37
|
-
<img src="https://img.shields.io/pypi/l/swarmauri_evaluator_externalimports" alt="PyPI - License"
|
|
38
|
-
</a>
|
|
39
|
-
<br />
|
|
36
|
+
<img src="https://img.shields.io/pypi/l/swarmauri_evaluator_externalimports" alt="PyPI - License"/></a>
|
|
40
37
|
<a href="https://pypi.org/project/swarmauri_evaluator_externalimports/">
|
|
41
|
-
<img src="https://img.shields.io/pypi/v/swarmauri_evaluator_externalimports?label=swarmauri_evaluator_externalimports&color=green" alt="PyPI - swarmauri_evaluator_externalimports"
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
---
|
|
38
|
+
<img src="https://img.shields.io/pypi/v/swarmauri_evaluator_externalimports?label=swarmauri_evaluator_externalimports&color=green" alt="PyPI - swarmauri_evaluator_externalimports"/></a>
|
|
39
|
+
<a href="https://discord.gg/N4UpBuQv8T">
|
|
40
|
+
<img src="https://img.shields.io/badge/Discord-Join%20Chat-5865F2?logo=discord&logoColor=white" alt="Discord"/></a></p>
|
|
46
41
|
|
|
47
42
|
# Swarmauri Evaluator External Imports
|
|
48
43
|
|
|
49
|
-
Evaluator that detects and penalizes non
|
|
44
|
+
Evaluator that detects and penalizes non?standard-library imports in Python source files.
|
|
50
45
|
|
|
51
46
|
## Purpose
|
|
52
47
|
|
|
@@ -161,3 +156,5 @@ if __name__ == "__main__":
|
|
|
161
156
|
|
|
162
157
|
If you want to contribute to swarmauri-sdk, read up on our [guidelines for contributing](https://github.com/swarmauri/swarmauri-sdk/blob/master/CONTRIBUTING.md).
|
|
163
158
|
|
|
159
|
+
|
|
160
|
+
|
|
@@ -1,29 +1,22 @@
|
|
|
1
|
-

|
|
2
2
|
|
|
3
3
|
<p align="center">
|
|
4
|
-
<a href="https://
|
|
5
|
-
<img src="https://
|
|
6
|
-
</a>
|
|
4
|
+
<a href="https://pepy.tech/project/swarmauri_evaluator_externalimports/">
|
|
5
|
+
<img src="https://static.pepy.tech/badge/swarmauri_evaluator_externalimports/month" alt="PyPI - Downloads"/></a>
|
|
7
6
|
<a href="https://hits.sh/github.com/swarmauri/swarmauri-sdk/tree/master/pkgs/standards/swarmauri_evaluator_externalimports/">
|
|
8
|
-
<img alt="Hits" src="https://hits.sh/github.com/swarmauri/swarmauri-sdk/tree/master/pkgs/standards/swarmauri_evaluator_externalimports.svg"
|
|
9
|
-
</a>
|
|
7
|
+
<img alt="Hits" src="https://hits.sh/github.com/swarmauri/swarmauri-sdk/tree/master/pkgs/standards/swarmauri_evaluator_externalimports.svg"/></a>
|
|
10
8
|
<a href="https://pypi.org/project/swarmauri_evaluator_externalimports/">
|
|
11
|
-
<img src="https://img.shields.io/
|
|
12
|
-
</a>
|
|
9
|
+
<img src="https://img.shields.io/badge/python-3.10%20%7C%203.11%20%7C%203.12%20%7C%203.13%20%7C%203.14-blue" alt="PyPI - Python Version"/></a>
|
|
13
10
|
<a href="https://pypi.org/project/swarmauri_evaluator_externalimports/">
|
|
14
|
-
<img src="https://img.shields.io/pypi/l/swarmauri_evaluator_externalimports" alt="PyPI - License"
|
|
15
|
-
</a>
|
|
16
|
-
<br />
|
|
11
|
+
<img src="https://img.shields.io/pypi/l/swarmauri_evaluator_externalimports" alt="PyPI - License"/></a>
|
|
17
12
|
<a href="https://pypi.org/project/swarmauri_evaluator_externalimports/">
|
|
18
|
-
<img src="https://img.shields.io/pypi/v/swarmauri_evaluator_externalimports?label=swarmauri_evaluator_externalimports&color=green" alt="PyPI - swarmauri_evaluator_externalimports"
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
---
|
|
13
|
+
<img src="https://img.shields.io/pypi/v/swarmauri_evaluator_externalimports?label=swarmauri_evaluator_externalimports&color=green" alt="PyPI - swarmauri_evaluator_externalimports"/></a>
|
|
14
|
+
<a href="https://discord.gg/N4UpBuQv8T">
|
|
15
|
+
<img src="https://img.shields.io/badge/Discord-Join%20Chat-5865F2?logo=discord&logoColor=white" alt="Discord"/></a></p>
|
|
23
16
|
|
|
24
17
|
# Swarmauri Evaluator External Imports
|
|
25
18
|
|
|
26
|
-
Evaluator that detects and penalizes non
|
|
19
|
+
Evaluator that detects and penalizes non?standard-library imports in Python source files.
|
|
27
20
|
|
|
28
21
|
## Purpose
|
|
29
22
|
|
|
@@ -137,3 +130,5 @@ if __name__ == "__main__":
|
|
|
137
130
|
## Want to help?
|
|
138
131
|
|
|
139
132
|
If you want to contribute to swarmauri-sdk, read up on our [guidelines for contributing](https://github.com/swarmauri/swarmauri-sdk/blob/master/CONTRIBUTING.md).
|
|
133
|
+
|
|
134
|
+
|
|
@@ -1,21 +1,23 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "swarmauri_evaluator_externalimports"
|
|
3
|
-
version = "0.
|
|
3
|
+
version = "0.11.0.dev1"
|
|
4
4
|
description = "Evaluator that detects and penalizes non-built-in Python imports in source files"
|
|
5
5
|
license = "Apache-2.0"
|
|
6
6
|
readme = "README.md"
|
|
7
7
|
repository = "https://github.com/swarmauri/swarmauri-sdk/pkgs/standards/swarmauri_evaluator_externalimports/"
|
|
8
|
-
requires-python = ">=3.10,<3.
|
|
8
|
+
requires-python = ">=3.10,<3.15"
|
|
9
9
|
classifiers = [
|
|
10
10
|
"License :: OSI Approved :: Apache Software License",
|
|
11
11
|
"Natural Language :: English",
|
|
12
|
-
"Programming Language :: Python :: 3.10",
|
|
13
|
-
"Programming Language :: Python :: 3.11",
|
|
14
|
-
"Programming Language :: Python :: 3.12",
|
|
15
12
|
"Development Status :: 3 - Alpha",
|
|
16
13
|
"Programming Language :: Python",
|
|
17
14
|
"Programming Language :: Python :: 3",
|
|
18
|
-
"Programming Language :: Python :: 3 :: Only"
|
|
15
|
+
"Programming Language :: Python :: 3 :: Only",
|
|
16
|
+
"Programming Language :: Python :: 3.10",
|
|
17
|
+
"Programming Language :: Python :: 3.11",
|
|
18
|
+
"Programming Language :: Python :: 3.12",
|
|
19
|
+
"Programming Language :: Python :: 3.13",
|
|
20
|
+
"Programming Language :: Python :: 3.14",
|
|
19
21
|
]
|
|
20
22
|
authors = [{ name = "Jacob Stewart", email = "jacob@swarmauri.com" }]
|
|
21
23
|
keywords = [
|
|
@@ -75,7 +77,7 @@ dev = [
|
|
|
75
77
|
"pytest-xdist>=3.6.1",
|
|
76
78
|
"pytest-json-report>=1.5.0",
|
|
77
79
|
"python-dotenv",
|
|
78
|
-
"
|
|
80
|
+
"httpx>=0.27",
|
|
79
81
|
"flake8>=7.0",
|
|
80
82
|
"pytest-timeout>=2.3.1",
|
|
81
83
|
"ruff>=0.9.9",
|
|
@@ -15,14 +15,18 @@ logger = logging.getLogger(__name__)
|
|
|
15
15
|
@ComponentBase.register_model()
|
|
16
16
|
class ExternalImportsEvaluator(EvaluatorBase):
|
|
17
17
|
"""
|
|
18
|
-
Evaluator that detects and penalizes non-built-in Python imports in source
|
|
18
|
+
Evaluator that detects and penalizes non-built-in Python imports in source
|
|
19
|
+
files.
|
|
19
20
|
|
|
20
|
-
This evaluator analyzes import statements to identify modules that are not
|
|
21
|
-
|
|
21
|
+
This evaluator analyzes import statements to identify modules that are not
|
|
22
|
+
part of
|
|
23
|
+
the Python standard library. It helps to assess the external dependencies
|
|
24
|
+
of a program.
|
|
22
25
|
|
|
23
26
|
Attributes:
|
|
24
27
|
type: The literal type identifier for this evaluator.
|
|
25
|
-
standard_modules: A set of module names that are part of the Python
|
|
28
|
+
standard_modules: A set of module names that are part of the Python
|
|
29
|
+
standard library.
|
|
26
30
|
"""
|
|
27
31
|
|
|
28
32
|
type: Literal["ExternalImportsEvaluator"] = "ExternalImportsEvaluator"
|
|
@@ -43,12 +47,14 @@ class ExternalImportsEvaluator(EvaluatorBase):
|
|
|
43
47
|
"""
|
|
44
48
|
Initialize the set of standard library modules.
|
|
45
49
|
|
|
46
|
-
This method populates the standard_modules set with names of all
|
|
50
|
+
This method populates the standard_modules set with names of all
|
|
51
|
+
modules
|
|
47
52
|
from the Python standard library.
|
|
48
53
|
"""
|
|
49
54
|
# Get all standard library modules
|
|
50
55
|
self.standard_modules = {
|
|
51
|
-
module.name
|
|
56
|
+
module.name
|
|
57
|
+
for module in pkgutil.iter_modules(sys.stdlib_module_names)
|
|
52
58
|
}
|
|
53
59
|
|
|
54
60
|
# Add built-in modules
|
|
@@ -108,7 +114,10 @@ class ExternalImportsEvaluator(EvaluatorBase):
|
|
|
108
114
|
self.standard_modules.update(additional_std_libs)
|
|
109
115
|
|
|
110
116
|
logger.debug(
|
|
111
|
-
|
|
117
|
+
(
|
|
118
|
+
f"Initialized with {len(self.standard_modules)} standard "
|
|
119
|
+
f"library modules"
|
|
120
|
+
)
|
|
112
121
|
)
|
|
113
122
|
|
|
114
123
|
def _is_standard_module(self, module_name: str) -> bool:
|
|
@@ -119,7 +128,8 @@ class ExternalImportsEvaluator(EvaluatorBase):
|
|
|
119
128
|
module_name: The name of the module to check.
|
|
120
129
|
|
|
121
130
|
Returns:
|
|
122
|
-
True if the module is part of the standard library, False
|
|
131
|
+
True if the module is part of the standard library, False
|
|
132
|
+
otherwise.
|
|
123
133
|
"""
|
|
124
134
|
# Check if the base module name is in standard modules
|
|
125
135
|
base_module = module_name.split(".")[0]
|
|
@@ -153,7 +163,9 @@ class ExternalImportsEvaluator(EvaluatorBase):
|
|
|
153
163
|
"module": name.name,
|
|
154
164
|
"alias": name.asname,
|
|
155
165
|
"line": node.lineno,
|
|
156
|
-
"is_standard": self._is_standard_module(
|
|
166
|
+
"is_standard": self._is_standard_module(
|
|
167
|
+
name.name
|
|
168
|
+
),
|
|
157
169
|
"type": "import",
|
|
158
170
|
}
|
|
159
171
|
)
|
|
@@ -171,7 +183,9 @@ class ExternalImportsEvaluator(EvaluatorBase):
|
|
|
171
183
|
"name": name.name,
|
|
172
184
|
"alias": name.asname,
|
|
173
185
|
"line": node.lineno,
|
|
174
|
-
"is_standard": self._is_standard_module(
|
|
186
|
+
"is_standard": self._is_standard_module(
|
|
187
|
+
module
|
|
188
|
+
),
|
|
175
189
|
"type": "importfrom",
|
|
176
190
|
}
|
|
177
191
|
)
|
|
@@ -190,10 +204,13 @@ class ExternalImportsEvaluator(EvaluatorBase):
|
|
|
190
204
|
self, program: Program, **kwargs
|
|
191
205
|
) -> Tuple[float, Dict[str, Any]]:
|
|
192
206
|
"""
|
|
193
|
-
Analyze a program's source files for external imports and compute a
|
|
207
|
+
Analyze a program's source files for external imports and compute a
|
|
208
|
+
score.
|
|
194
209
|
|
|
195
|
-
The score is inversely proportional to the number of external
|
|
196
|
-
|
|
210
|
+
The score is inversely proportional to the number of external
|
|
211
|
+
dependencies.
|
|
212
|
+
A program with no external dependencies receives a perfect score of
|
|
213
|
+
1.0.
|
|
197
214
|
|
|
198
215
|
Args:
|
|
199
216
|
program: The program to evaluate.
|
|
@@ -201,8 +218,10 @@ class ExternalImportsEvaluator(EvaluatorBase):
|
|
|
201
218
|
|
|
202
219
|
Returns:
|
|
203
220
|
A tuple containing:
|
|
204
|
-
- float: A scalar fitness score (1.0 is best, lower for more
|
|
205
|
-
|
|
221
|
+
- float: A scalar fitness score (1.0 is best, lower for more
|
|
222
|
+
external imports)
|
|
223
|
+
- Dict[str, Any]: Metadata about the evaluation, including
|
|
224
|
+
detected imports
|
|
206
225
|
"""
|
|
207
226
|
# Get all Python files in the program
|
|
208
227
|
python_files = []
|
|
@@ -211,7 +230,9 @@ class ExternalImportsEvaluator(EvaluatorBase):
|
|
|
211
230
|
if file.endswith(".py"):
|
|
212
231
|
python_files.append(os.path.join(root, file))
|
|
213
232
|
|
|
214
|
-
logger.info(
|
|
233
|
+
logger.info(
|
|
234
|
+
f"Analyzing {len(python_files)} Python files for external imports"
|
|
235
|
+
)
|
|
215
236
|
|
|
216
237
|
# Extract imports from all files
|
|
217
238
|
all_imports = []
|
|
@@ -243,7 +264,9 @@ class ExternalImportsEvaluator(EvaluatorBase):
|
|
|
243
264
|
elif imp["type"] == "importfrom":
|
|
244
265
|
# Extract the base module name for "from" statements
|
|
245
266
|
module_name = (
|
|
246
|
-
imp["parent_module"].split(".")[0]
|
|
267
|
+
imp["parent_module"].split(".")[0]
|
|
268
|
+
if imp["parent_module"]
|
|
269
|
+
else ""
|
|
247
270
|
)
|
|
248
271
|
if module_name:
|
|
249
272
|
unique_external_modules.add(module_name)
|
|
@@ -269,7 +292,10 @@ class ExternalImportsEvaluator(EvaluatorBase):
|
|
|
269
292
|
}
|
|
270
293
|
|
|
271
294
|
logger.info(
|
|
272
|
-
|
|
295
|
+
(
|
|
296
|
+
f"Found {len(external_imports)} external imports from "
|
|
297
|
+
f"{len(unique_external_modules)} unique modules"
|
|
298
|
+
)
|
|
273
299
|
)
|
|
274
300
|
|
|
275
301
|
return score, metadata
|
|
File without changes
|