Skip to content

Commit d1ace35

Browse files
committed
Rename asset 'type' arg to 'asset_type' (Pylint W0622 redefined-builtin)
1 parent 381699d commit d1ace35

8 files changed

Lines changed: 31 additions & 26 deletions

File tree

docs/source/Eng/doc/new_features/v48_features_doc.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ Headless API
2020
from je_auto_control import AssetStore, active_environment
2121
2222
store = AssetStore("assets.json")
23-
store.set("max_retries", 3, type="int", environment="prod")
23+
store.set("max_retries", 3, asset_type="int", environment="prod")
2424
store.set("api_base", "https://prod.example.com", environment="prod")
25-
store.set("db_password", "vault_db_pw", type="credential") # value = a ref
25+
store.set("db_password", "vault_db_pw", asset_type="credential") # value = a ref
2626
2727
store.get("max_retries", environment="prod").value # -> 3 (typed)
2828
store.get("api_base", environment="staging").value # -> falls back to default

docs/source/Zh/doc/new_features/v48_features_doc.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ JSON 後端(或記憶體內);純標準函式庫;不匯入 ``PySide6``。
1717
from je_auto_control import AssetStore, active_environment
1818
1919
store = AssetStore("assets.json")
20-
store.set("max_retries", 3, type="int", environment="prod")
20+
store.set("max_retries", 3, asset_type="int", environment="prod")
2121
store.set("api_base", "https://prod.example.com", environment="prod")
22-
store.set("db_password", "vault_db_pw", type="credential") # value = 參照
22+
store.set("db_password", "vault_db_pw", asset_type="credential") # value = 參照
2323
2424
store.get("max_retries", environment="prod").value # -> 3(具型別)
2525
store.get("api_base", environment="staging").value # -> 退回 default

je_auto_control/gui/script_builder/command_schema.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1072,7 +1072,8 @@ def _add_misc_specs(specs: List[CommandSpec]) -> None:
10721072
fields=(
10731073
FieldSpec("name", FieldType.STRING),
10741074
FieldSpec("value", FieldType.STRING),
1075-
FieldSpec("type", FieldType.ENUM, optional=True, default="text",
1075+
FieldSpec("asset_type", FieldType.ENUM, optional=True,
1076+
default="text",
10761077
choices=("text", "int", "bool", "credential")),
10771078
FieldSpec("environment", FieldType.STRING, optional=True,
10781079
default="default"),

je_auto_control/utils/assets/assets.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,11 @@ def _flush(self) -> None:
7575
if self._path is not None:
7676
write_json_dict(self._path, self._data)
7777

78-
def set(self, name: str, value: Any, *, type: str = TYPE_TEXT,
78+
def set(self, name: str, value: Any, *, asset_type: str = TYPE_TEXT,
7979
environment: str = DEFAULT_ENV) -> None:
8080
"""Store ``value`` for ``name`` under ``environment`` with a type tag."""
8181
self._data.setdefault(environment, {})[name] = {
82-
"type": type, "value": value}
82+
"type": asset_type, "value": value}
8383
self._flush()
8484

8585
def _lookup(self, name: str, environment: str,
@@ -125,11 +125,12 @@ def list(self, *, environment: Optional[str] = None) -> List[Asset]:
125125
]
126126

127127

128-
def store_set(name: str, value: Any, *, type: str = TYPE_TEXT,
128+
def store_set(name: str, value: Any, *, asset_type: str = TYPE_TEXT,
129129
environment: str = DEFAULT_ENV,
130130
db: Optional[str] = None) -> Dict[str, Any]:
131131
"""Set an asset and return a result dict (shared by executor/MCP layers)."""
132-
AssetStore(db).set(name, value, type=type, environment=environment)
132+
AssetStore(db).set(name, value, asset_type=asset_type,
133+
environment=environment)
133134
return {"ok": True, "name": name, "environment": environment}
134135

135136

je_auto_control/utils/executor/action_executor.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3245,12 +3245,13 @@ def _mine_actions(actions: Any, min_len: int = 2, max_len: int = 5,
32453245
}
32463246

32473247

3248-
def _set_asset(name: str, value: Any, type: str = "text",
3248+
def _set_asset(name: str, value: Any, asset_type: str = "text",
32493249
environment: str = "default",
32503250
db: Optional[str] = None) -> Dict[str, Any]:
32513251
"""Adapter: store a typed, environment-scoped asset."""
32523252
from je_auto_control.utils.assets.assets import store_set
3253-
return store_set(name, value, type=type, environment=environment, db=db)
3253+
return store_set(name, value, asset_type=asset_type,
3254+
environment=environment, db=db)
32543255

32553256

32563257
def _get_asset(name: str, environment: str = "default",

je_auto_control/utils/mcp_server/tools/_factories.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3126,13 +3126,14 @@ def asset_tools() -> List[MCPTool]:
31263126
return [
31273127
MCPTool(
31283128
name="ac_set_asset",
3129-
description=("Store a typed, environment-scoped asset. 'type' is "
3130-
"text/int/bool/credential (credential 'value' is a "
3129+
description=("Store a typed, environment-scoped asset. 'asset_type' "
3130+
"is text/int/bool/credential (credential 'value' is a "
31313131
"secret name, not the secret). Returns {ok}."),
31323132
input_schema=schema(
31333133
{"name": {"type": "string"}, "value": {},
3134-
"type": {"type": "string",
3135-
"enum": ["text", "int", "bool", "credential"]},
3134+
"asset_type": {"type": "string",
3135+
"enum": ["text", "int", "bool",
3136+
"credential"]},
31363137
**_ENV}, ["name", "value"]),
31373138
handler=h.set_asset,
31383139
annotations=SIDE_EFFECT_ONLY,

je_auto_control/utils/mcp_server/tools/_handlers.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1512,9 +1512,10 @@ def mine_actions(actions, min_len=2, max_len=5, min_count=3):
15121512
}
15131513

15141514

1515-
def set_asset(name, value, type="text", environment="default", db=None):
1515+
def set_asset(name, value, asset_type="text", environment="default", db=None):
15161516
from je_auto_control.utils.assets.assets import store_set
1517-
return store_set(name, value, type=type, environment=environment, db=db)
1517+
return store_set(name, value, asset_type=asset_type,
1518+
environment=environment, db=db)
15181519

15191520

15201521
def get_asset(name, environment="default", db=None):

test/unit_test/headless/test_assets_batch.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99

1010
def test_typed_coercion():
1111
store = AssetStore()
12-
store.set("retries", "3", type="int")
13-
store.set("enabled", "yes", type="bool")
14-
store.set("title", "Hi", type="text")
12+
store.set("retries", "3", asset_type="int")
13+
store.set("enabled", "yes", asset_type="bool")
14+
store.set("title", "Hi", asset_type="text")
1515
assert store.get("retries").value == 3
1616
assert store.get("enabled").value is True
1717
assert store.get("title").value == "Hi"
@@ -31,23 +31,23 @@ def test_environment_override_and_fallback():
3131

3232
def test_credential_get_returns_reference_not_secret():
3333
store = AssetStore()
34-
store.set("db_pw", "vault_db_ref", type="credential")
34+
store.set("db_pw", "vault_db_ref", asset_type="credential")
3535
asset = store.get("db_pw")
3636
assert asset.type == "credential"
3737
assert asset.value == "vault_db_ref" # the reference, not a secret
3838

3939

4040
def test_credential_resolve_uses_injected_resolver():
4141
store = AssetStore(secret_resolver={"vault_db_ref": "s3cr3t"}.get)
42-
store.set("db_pw", "vault_db_ref", type="credential")
42+
store.set("db_pw", "vault_db_ref", asset_type="credential")
4343
assert store.resolve("db_pw") == "s3cr3t"
44-
store.set("plain", "visible", type="text")
44+
store.set("plain", "visible", asset_type="text")
4545
assert store.resolve("plain") == "visible" # non-credential returns value
4646

4747

4848
def test_resolve_without_resolver_raises():
4949
store = AssetStore()
50-
store.set("db_pw", "ref", type="credential")
50+
store.set("db_pw", "ref", asset_type="credential")
5151
with pytest.raises(RuntimeError):
5252
store.resolve("db_pw")
5353

@@ -64,7 +64,7 @@ def test_list_and_delete():
6464

6565
def test_persists_across_instances(tmp_path):
6666
db = str(tmp_path / "assets.json")
67-
AssetStore(db).set("token", "42", type="int", environment="prod")
67+
AssetStore(db).set("token", "42", asset_type="int", environment="prod")
6868
assert AssetStore(db).get("token", environment="prod").value == 42
6969

7070

@@ -80,7 +80,7 @@ def test_active_environment(monkeypatch):
8080
def test_executor_round_trip(tmp_path):
8181
db = str(tmp_path / "a.json")
8282
ac.execute_action([["AC_set_asset",
83-
{"name": "n", "value": "5", "type": "int",
83+
{"name": "n", "value": "5", "asset_type": "int",
8484
"environment": "prod", "db": db}]])
8585
rec = ac.execute_action([["AC_get_asset",
8686
{"name": "n", "environment": "prod", "db": db}]])

0 commit comments

Comments
 (0)