netherframe.codec.autoid 0.3.0__tar.gz → 0.4.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.
- {netherframe_codec_autoid-0.3.0 → netherframe_codec_autoid-0.4.0}/PKG-INFO +7 -1
- {netherframe_codec_autoid-0.3.0 → netherframe_codec_autoid-0.4.0}/netherframe/codec/autoid/preprocessor.py +32 -10
- netherframe_codec_autoid-0.4.0/nf/codec/autoid/__init__.py +21 -0
- netherframe_codec_autoid-0.4.0/nf/codec/autoid/codec_registration.py +21 -0
- netherframe_codec_autoid-0.4.0/nf/codec/autoid/preprocessor.py +21 -0
- {netherframe_codec_autoid-0.3.0 → netherframe_codec_autoid-0.4.0}/pyproject.toml +11 -1
- {netherframe_codec_autoid-0.3.0 → netherframe_codec_autoid-0.4.0}/pyproject.toml.orig +10 -1
- netherframe_codec_autoid-0.3.0/nf/codec/autoid/__init__.py +0 -4
- netherframe_codec_autoid-0.3.0/nf/codec/autoid/codec_registration.py +0 -4
- netherframe_codec_autoid-0.3.0/nf/codec/autoid/preprocessor.py +0 -4
- {netherframe_codec_autoid-0.3.0 → netherframe_codec_autoid-0.4.0}/LICENSE +0 -0
- {netherframe_codec_autoid-0.3.0 → netherframe_codec_autoid-0.4.0}/README.md +0 -0
- {netherframe_codec_autoid-0.3.0 → netherframe_codec_autoid-0.4.0}/data/purelib/nf_codec_autoid_autoregister.pth +0 -0
- {netherframe_codec_autoid-0.3.0 → netherframe_codec_autoid-0.4.0}/data/purelib/nf_codec_autoid_autoregister.start +0 -0
- {netherframe_codec_autoid-0.3.0 → netherframe_codec_autoid-0.4.0}/netherframe/codec/autoid/__init__.py +0 -0
- {netherframe_codec_autoid-0.3.0 → netherframe_codec_autoid-0.4.0}/netherframe/codec/autoid/codec_registration.py +0 -0
- {netherframe_codec_autoid-0.3.0 → netherframe_codec_autoid-0.4.0}/netherframe/codec/autoid/py.typed +0 -0
- {netherframe_codec_autoid-0.3.0 → netherframe_codec_autoid-0.4.0}/nf/codec/autoid/py.typed +0 -0
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: netherframe.codec.autoid
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.4.0
|
|
4
4
|
Summary: Auto-ID codec and preprocessor for Netherframe
|
|
5
|
+
Author: Sourabh Cheedella
|
|
6
|
+
Author-email: Sourabh Cheedella <cheedella.sourabh@gmail.com>
|
|
5
7
|
License-Expression: MIT
|
|
6
8
|
License-File: LICENSE
|
|
9
|
+
Classifier: Development Status :: 4 - Beta
|
|
10
|
+
Classifier: Intended Audience :: Developers
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.15
|
|
7
13
|
Requires-Dist: libcst>=1.9.0
|
|
8
14
|
Requires-Python: >=3.14
|
|
9
15
|
Project-URL: Homepage, https://netherframe.arsenal.sh
|
|
@@ -19,18 +19,24 @@ class LibCSTTransformer(cst.CSTTransformer):
|
|
|
19
19
|
def __init__(self) -> None:
|
|
20
20
|
super().__init__()
|
|
21
21
|
|
|
22
|
+
def _is_bind_name(self, expr: cst.BaseExpression) -> bool:
|
|
23
|
+
if isinstance(expr, cst.Name):
|
|
24
|
+
return expr.value == "Bind"
|
|
25
|
+
if isinstance(expr, cst.Attribute):
|
|
26
|
+
return expr.attr.value == "Bind"
|
|
27
|
+
return False
|
|
28
|
+
|
|
22
29
|
def _has_bind_annotation(self, annotation: cst.Annotation | None) -> bool:
|
|
23
|
-
"""Check if annotation indicates Bind."""
|
|
30
|
+
"""Check if annotation indicates Bind (including qualified forms like nf.Bind or Bind[T])."""
|
|
24
31
|
if not annotation:
|
|
25
32
|
return False
|
|
26
33
|
|
|
27
34
|
ann = annotation.annotation
|
|
28
35
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
return ann.value.value == "Bind"
|
|
36
|
+
if self._is_bind_name(ann):
|
|
37
|
+
return True
|
|
38
|
+
if isinstance(ann, cst.Subscript) and self._is_bind_name(ann.value):
|
|
39
|
+
return True
|
|
34
40
|
|
|
35
41
|
return False
|
|
36
42
|
|
|
@@ -262,6 +268,10 @@ class LibCSTTransformer(cst.CSTTransformer):
|
|
|
262
268
|
# So we don't wrap these automatically
|
|
263
269
|
return updated_node
|
|
264
270
|
|
|
271
|
+
_NON_CONSTRUCT_BUILTINS = frozenset(
|
|
272
|
+
{"open", "dict", "list", "set", "tuple", "str", "int", "float", "bool", "bytes", "object", "range", "enumerate", "zip", "map", "filter", "iter"}
|
|
273
|
+
)
|
|
274
|
+
|
|
265
275
|
def leave_With(self, original_node: cst.With, updated_node: cst.With) -> cst.With:
|
|
266
276
|
"""Transform context manager assignments when BindContext is present."""
|
|
267
277
|
has_bind_context = any(self._is_bind_context(item.item) for item in updated_node.items)
|
|
@@ -270,7 +280,11 @@ class LibCSTTransformer(cst.CSTTransformer):
|
|
|
270
280
|
|
|
271
281
|
new_items = []
|
|
272
282
|
for item in updated_node.items:
|
|
273
|
-
if item.asname and isinstance(item.item, cst.Call):
|
|
283
|
+
if item.asname and isinstance(item.item, cst.Call) and not self._is_bind_context(item.item):
|
|
284
|
+
callee = item.item.func
|
|
285
|
+
if isinstance(callee, cst.Name) and callee.value in self._NON_CONSTRUCT_BUILTINS:
|
|
286
|
+
new_items.append(item)
|
|
287
|
+
continue
|
|
274
288
|
var_name = self._extract_asname(item.asname)
|
|
275
289
|
if var_name:
|
|
276
290
|
new_call = self._inject_nf_id(item.item, var_name)
|
|
@@ -321,9 +335,17 @@ def preprocess_source(source: str) -> str:
|
|
|
321
335
|
|
|
322
336
|
# Return the modified code
|
|
323
337
|
return modified_tree.code
|
|
324
|
-
except
|
|
325
|
-
#
|
|
326
|
-
|
|
338
|
+
except cst.ParserSyntaxError:
|
|
339
|
+
# Return original source so Python's own parser raises a SyntaxError with exact location.
|
|
340
|
+
return source
|
|
341
|
+
except Exception as exc:
|
|
342
|
+
import warnings
|
|
343
|
+
|
|
344
|
+
warnings.warn(
|
|
345
|
+
f"nf_autoid preprocessor failed to transform source ({type(exc).__name__}: {exc}); returning unmodified source",
|
|
346
|
+
RuntimeWarning,
|
|
347
|
+
stacklevel=2,
|
|
348
|
+
)
|
|
327
349
|
return source
|
|
328
350
|
|
|
329
351
|
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# Generated nf.* alias shim (netherframe.generation.nf_alias_shims); do not edit.
|
|
2
|
+
"""Type-checker view of ``nf.codec.autoid``; at runtime it is ``netherframe.codec.autoid`` itself."""
|
|
3
|
+
|
|
4
|
+
from typing import TYPE_CHECKING
|
|
5
|
+
|
|
6
|
+
if TYPE_CHECKING:
|
|
7
|
+
from netherframe.codec.autoid import * # noqa: F403
|
|
8
|
+
else:
|
|
9
|
+
# Runs only without the import hook (python -S, zipimport, some bundlers): install it, so
|
|
10
|
+
# nf.* imports from now on, this module's submodules included, return the netherframe.*
|
|
11
|
+
# modules, and return the netherframe.* module for this import too.
|
|
12
|
+
import importlib as _importlib
|
|
13
|
+
import sys as _sys
|
|
14
|
+
|
|
15
|
+
try:
|
|
16
|
+
import netherframe_nf_alias as _nf_alias
|
|
17
|
+
except ImportError: # netherframe.core, which ships the hook, is not installed
|
|
18
|
+
pass
|
|
19
|
+
else:
|
|
20
|
+
_nf_alias.install()
|
|
21
|
+
_sys.modules[__name__] = _importlib.import_module("netherframe.codec.autoid")
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# Generated nf.* alias shim (netherframe.generation.nf_alias_shims); do not edit.
|
|
2
|
+
"""Type-checker view of ``nf.codec.autoid.codec_registration``; at runtime it is ``netherframe.codec.autoid.codec_registration`` itself."""
|
|
3
|
+
|
|
4
|
+
from typing import TYPE_CHECKING
|
|
5
|
+
|
|
6
|
+
if TYPE_CHECKING:
|
|
7
|
+
from netherframe.codec.autoid.codec_registration import * # noqa: F403
|
|
8
|
+
else:
|
|
9
|
+
# Runs only without the import hook (python -S, zipimport, some bundlers): install it, so
|
|
10
|
+
# nf.* imports from now on, this module's submodules included, return the netherframe.*
|
|
11
|
+
# modules, and return the netherframe.* module for this import too.
|
|
12
|
+
import importlib as _importlib
|
|
13
|
+
import sys as _sys
|
|
14
|
+
|
|
15
|
+
try:
|
|
16
|
+
import netherframe_nf_alias as _nf_alias
|
|
17
|
+
except ImportError: # netherframe.core, which ships the hook, is not installed
|
|
18
|
+
pass
|
|
19
|
+
else:
|
|
20
|
+
_nf_alias.install()
|
|
21
|
+
_sys.modules[__name__] = _importlib.import_module("netherframe.codec.autoid.codec_registration")
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# Generated nf.* alias shim (netherframe.generation.nf_alias_shims); do not edit.
|
|
2
|
+
"""Type-checker view of ``nf.codec.autoid.preprocessor``; at runtime it is ``netherframe.codec.autoid.preprocessor`` itself."""
|
|
3
|
+
|
|
4
|
+
from typing import TYPE_CHECKING
|
|
5
|
+
|
|
6
|
+
if TYPE_CHECKING:
|
|
7
|
+
from netherframe.codec.autoid.preprocessor import * # noqa: F403
|
|
8
|
+
else:
|
|
9
|
+
# Runs only without the import hook (python -S, zipimport, some bundlers): install it, so
|
|
10
|
+
# nf.* imports from now on, this module's submodules included, return the netherframe.*
|
|
11
|
+
# modules, and return the netherframe.* module for this import too.
|
|
12
|
+
import importlib as _importlib
|
|
13
|
+
import sys as _sys
|
|
14
|
+
|
|
15
|
+
try:
|
|
16
|
+
import netherframe_nf_alias as _nf_alias
|
|
17
|
+
except ImportError: # netherframe.core, which ships the hook, is not installed
|
|
18
|
+
pass
|
|
19
|
+
else:
|
|
20
|
+
_nf_alias.install()
|
|
21
|
+
_sys.modules[__name__] = _importlib.import_module("netherframe.codec.autoid.preprocessor")
|
|
@@ -1,13 +1,23 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "netherframe.codec.autoid"
|
|
3
|
-
version = "0.
|
|
3
|
+
version = "0.4.0"
|
|
4
4
|
description = "Auto-ID codec and preprocessor for Netherframe"
|
|
5
5
|
readme = "README.md"
|
|
6
6
|
requires-python = ">=3.14"
|
|
7
|
+
classifiers = [
|
|
8
|
+
"Development Status :: 4 - Beta",
|
|
9
|
+
"Intended Audience :: Developers",
|
|
10
|
+
"Programming Language :: Python :: 3.14",
|
|
11
|
+
"Programming Language :: Python :: 3.15",
|
|
12
|
+
]
|
|
7
13
|
license = "MIT"
|
|
8
14
|
license-files = ["LICENSE"]
|
|
9
15
|
dependencies = ["libcst>=1.9.0"]
|
|
10
16
|
|
|
17
|
+
[[project.authors]]
|
|
18
|
+
name = "Sourabh Cheedella"
|
|
19
|
+
email = "cheedella.sourabh@gmail.com"
|
|
20
|
+
|
|
11
21
|
[project.urls]
|
|
12
22
|
Homepage = "https://netherframe.arsenal.sh"
|
|
13
23
|
Repository = "https://github.com/arsenal-sh/netherframe"
|
|
@@ -1,9 +1,18 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "netherframe.codec.autoid"
|
|
3
|
-
version = "0.
|
|
3
|
+
version = "0.4.0"
|
|
4
4
|
description = "Auto-ID codec and preprocessor for Netherframe"
|
|
5
|
+
authors = [
|
|
6
|
+
{name = "Sourabh Cheedella", email = "cheedella.sourabh@gmail.com"},
|
|
7
|
+
]
|
|
5
8
|
readme = "README.md"
|
|
6
9
|
requires-python = ">=3.14"
|
|
10
|
+
classifiers = [
|
|
11
|
+
"Development Status :: 4 - Beta",
|
|
12
|
+
"Intended Audience :: Developers",
|
|
13
|
+
"Programming Language :: Python :: 3.14",
|
|
14
|
+
"Programming Language :: Python :: 3.15",
|
|
15
|
+
]
|
|
7
16
|
license = "MIT"
|
|
8
17
|
license-files = ["LICENSE"]
|
|
9
18
|
dependencies = [
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
# Generated nf.* alias shim (netherframe.generation.nf_alias_shims); do not edit.
|
|
2
|
-
"""Type-checker view of ``nf.codec.autoid.codec_registration``; at runtime it is ``netherframe.codec.autoid.codec_registration`` itself."""
|
|
3
|
-
|
|
4
|
-
from netherframe.codec.autoid.codec_registration import * # noqa: F403
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
# Generated nf.* alias shim (netherframe.generation.nf_alias_shims); do not edit.
|
|
2
|
-
"""Type-checker view of ``nf.codec.autoid.preprocessor``; at runtime it is ``netherframe.codec.autoid.preprocessor`` itself."""
|
|
3
|
-
|
|
4
|
-
from netherframe.codec.autoid.preprocessor import * # noqa: F403
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{netherframe_codec_autoid-0.3.0 → netherframe_codec_autoid-0.4.0}/netherframe/codec/autoid/py.typed
RENAMED
|
File without changes
|
|
File without changes
|