Skip to content

Commit 7cff031

Browse files
author
Matthias Zimmermann
committed
chore: improve devcontainer setup
1 parent d51a133 commit 7cff031

File tree

4 files changed

+54
-11
lines changed

4 files changed

+54
-11
lines changed

.devcontainer/devcontainer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,5 +39,5 @@
3939
]
4040
}
4141
},
42-
"postCreateCommand": "uv sync --all-groups && git config --global core.editor nano"
42+
"postCreateCommand": "bash .devcontainer/post-create.sh"
4343
}

.devcontainer/post-create.sh

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/bin/bash
2+
set -e
3+
4+
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
5+
echo "🔧 Setting up Arkiv SDK development environment..."
6+
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
7+
8+
echo ""
9+
echo "📦 Installing Python dependencies with uv..."
10+
uv sync --all-groups
11+
12+
echo ""
13+
echo "⚙️ Configuring git editor..."
14+
git config --global core.editor nano
15+
16+
echo ""
17+
echo "✅ Verifying installation..."
18+
echo " Python: $(python --version)"
19+
echo " UV: $(uv --version)"
20+
echo " Pytest: $(uv run pytest --version)"
21+
echo " Ruff: $(uv run ruff --version)"
22+
echo " Mypy: $(uv run mypy --version)"
23+
24+
echo ""
25+
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
26+
echo "🎉 Dev container is ready!"
27+
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
28+
echo ""
29+
echo "Quick start commands:"
30+
echo " • ./scripts/check-all.sh # Run all quality checks"
31+
echo " • uv run pytest -n auto # Run all tests (parallel mode)"
32+
echo " • uv run ruff check . # Lint code"
33+
echo " • uv run mypy src/ tests/ # Type check"
34+
echo ""

src/arkiv/module.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -420,17 +420,18 @@ def query_entities(
420420
raise ValueError("Must provide either query or cursor")
421421

422422
if query is not None and len(query.strip()) > 0:
423-
logger.info(f"Query: '{query}', limit={limit}, at_block={at_block}, cursor={cursor}")
423+
logger.info(
424+
f"Query: '{query}', limit={limit}, at_block={at_block}, cursor={cursor}"
425+
)
424426

425427
# Fetch raw results from RPC
426428
raw_results = self.client.eth.query_entities(query) # type: ignore[attr-defined]
427-
429+
428430
# Transform and log each result
429431
entities: list[Entity] = []
430432
for result in raw_results:
431433
entity_result = QueryEntitiesResult(
432-
entity_key=result.key,
433-
storage_value=base64.b64decode(result.value)
434+
entity_key=result.key, storage_value=base64.b64decode(result.value)
434435
)
435436
logger.info(f"Query result item: {entity_result}")
436437
entities.append(to_entity(entity_result))

tests/test_entity_query.py

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
"""Tests for entity query functionality."""
22

3-
from unittest import result
43
import uuid
54

65
import pytest
@@ -30,7 +29,9 @@ def test_query_entities_accepts_query_only(self, arkiv_client_http: Arkiv) -> No
3029
"""Test that query_entities accepts query without cursor."""
3130
# Should not raise ValueError for missing cursor
3231
# Query will execute (returns empty result since no matching entities exist)
33-
result = arkiv_client_http.arkiv.query_entities(query='owner = "0x0000000000000000000000000000000000000000"')
32+
result = arkiv_client_http.arkiv.query_entities(
33+
query='owner = "0x0000000000000000000000000000000000000000"'
34+
)
3435
assert not result # check for falsy result
3536
assert len(result) == 0 # No entities match this owner
3637

@@ -41,7 +42,9 @@ def test_query_entities_accepts_cursor_only(self, arkiv_client_http: Arkiv) -> N
4142

4243
# Should not raise ValueError for missing query
4344
# Will raise NotImplementedError since cursor-based pagination is not yet implemented
44-
with pytest.raises(NotImplementedError, match="not yet implemented for cursors"):
45+
with pytest.raises(
46+
NotImplementedError, match="not yet implemented for cursors"
47+
):
4548
arkiv_client_http.arkiv.query_entities(cursor=cursor)
4649

4750
def test_query_entities_both_query_and_cursor_not_allowed(
@@ -52,7 +55,10 @@ def test_query_entities_both_query_and_cursor_not_allowed(
5255

5356
# Should raise ValueError when both are provided
5457
with pytest.raises(ValueError, match="Cannot provide both query and cursor"):
55-
arkiv_client_http.arkiv.query_entities(query='owner = "0x0000000000000000000000000000000000000000"', cursor=cursor)
58+
arkiv_client_http.arkiv.query_entities(
59+
query='owner = "0x0000000000000000000000000000000000000000"',
60+
cursor=cursor,
61+
)
5662

5763
def test_query_entities_with_all_parameters(self, arkiv_client_http: Arkiv) -> None:
5864
"""Test that query_entities accepts all parameters."""
@@ -73,7 +79,9 @@ def test_query_entities_with_cursor_and_parameters(
7379

7480
# Should not raise ValueError
7581
# Will raise NotImplementedError since cursor-based pagination is not yet implemented
76-
with pytest.raises(NotImplementedError, match="not yet implemented for cursors"):
82+
with pytest.raises(
83+
NotImplementedError, match="not yet implemented for cursors"
84+
):
7785
arkiv_client_http.arkiv.query_entities(
7886
cursor=cursor,
7987
limit=100, # Ignored when cursor is provided
@@ -106,12 +114,12 @@ def test_query_entities_by_annotation(self, arkiv_client_http: Arkiv) -> None:
106114

107115
# Verify result basics
108116
assert result # Check __bool__()
117+
assert result.block_number > 0
109118
assert result.has_more() is False
110119
assert result.next_cursor is None # only 3 results, no pagination needed
111120

112121
# Verify we got back all 3 entities
113122
assert len(result.entities) == 3
114-
assert result.block_number > 0
115123

116124
# Verify the entity keys match (order may differ)
117125
result_keys = {entity.entity_key for entity in result.entities}

0 commit comments

Comments
 (0)