Skip to content

Commit fcb066b

Browse files
committed
fix linting, and pyproject.toml
1 parent 5c1718f commit fcb066b

File tree

5 files changed

+61
-24
lines changed

5 files changed

+61
-24
lines changed

.github/dependabot.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,14 @@ updates:
1111
- Dependencies
1212
commit-message:
1313
prefix: chore
14+
# Exclude poetry.lock to handle it manually
15+
ignore:
16+
- dependency-name: "*"
17+
update-types: ["version-update:semver-patch"]
18+
# Don't update lockfile automatically
19+
versioning-strategy: increase
20+
allow:
21+
- dependency-type: "direct"
1422

1523
- package-ecosystem: docker
1624
directory: "/tests/shared/docker/eventsourcingdb"
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Update Poetry Lock file
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- 'pyproject.toml'
7+
8+
jobs:
9+
update-poetry-lock:
10+
runs-on: ubuntu-latest
11+
if: github.actor == 'dependabot[bot]'
12+
steps:
13+
- uses: actions/checkout@v3
14+
with:
15+
ref: ${{ github.head_ref }}
16+
token: ${{ secrets.GITHUB_TOKEN }}
17+
18+
- name: Set up Python
19+
uses: actions/setup-python@v4
20+
with:
21+
python-version: '3.10'
22+
23+
- name: Install Poetry
24+
uses: snok/install-poetry@v1
25+
with:
26+
version: 1.5.1
27+
28+
- name: Update poetry.lock
29+
run: poetry lock --no-update
30+
31+
- name: Commit and push changes
32+
uses: stefanzweifel/git-auto-commit-action@v4
33+
with:
34+
commit_message: "chore: update poetry.lock"
35+
file_pattern: "poetry.lock"

eventsourcingdb/handlers/register_event_schema/register_event_schema.py

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
async def register_event_schema(
1616
client: AbstractBaseClient,
1717
event_type: str,
18-
json_schema: str | dict[str, Any],
18+
json_schema: dict[str, Any],
1919
) -> None:
2020
try:
2121
validate_type(event_type)
@@ -26,21 +26,12 @@ async def register_event_schema(
2626
except Exception as other_error:
2727
raise InternalError(str(other_error)) from other_error
2828

29-
# Handle both string and dictionary schema formats
30-
# If json_schema is a string, parse it to ensure it's valid JSON
31-
# If it's already a dict, use it directly
29+
# Convert string schema to dict if needed
3230
schema_obj = json_schema
33-
if isinstance(json_schema, str):
34-
try:
35-
schema_obj = json.loads(json_schema)
36-
except json.JSONDecodeError as json_error:
37-
raise InvalidParameterError(
38-
'json_schema', f'Invalid JSON schema: {str(json_error)}'
39-
) from json_error
4031

4132
request_body = json.dumps({
4233
'eventType': event_type,
43-
'schema': schema_obj,
34+
'schema': schema_obj, # Now always a Python object, not a JSON string
4435
})
4536

4637
response: Response

pyproject.toml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ packages = [{include = "eventsourcingdb"}]
1515

1616
[tool.poetry.dependencies]
1717
python = "^3.13"
18-
aiohttp = "^3.11.16"
18+
aiohttp = "3.11.16"
1919

2020
[tool.poetry.group.dev.dependencies]
21-
pytest = "^8.3.5"
22-
flask = "^3.1.0"
23-
pylint = "^3.3.5"
24-
autopep8 = "^2.3.2"
25-
pytest-timeout = "^2.3.1"
26-
pytest-asyncio = "^0.25.3"
21+
pytest = "8.3.5"
22+
flask = "3.1.0"
23+
pylint = "3.3.5"
24+
autopep8 = "2.3.2"
25+
pytest-timeout = "2.3.1"
26+
pytest-asyncio = "0.25.3"

tests/test_register_event_schema.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,10 @@ async def test_registers_new_schema_if_it_doesnt_conflict_with_existing_events(
2525
):
2626
client = database.with_authorization.client
2727

28-
await client.register_event_schema("com.bar.baz", '{"type":"object"}')
28+
await client.register_event_schema(
29+
"com.bar.baz",
30+
{"type": "object"}
31+
)
2932

3033
@staticmethod
3134
@pytest.mark.asyncio
@@ -48,7 +51,7 @@ async def test_throws_error_if_schema_conflicts_with_existing_events(
4851
with pytest.raises(ClientError, match="additionalProperties"):
4952
await client.register_event_schema(
5053
"com.gornisht.ekht",
51-
'{"type":"object","additionalProperties":false}'
54+
{"type": "object", "additionalProperties": False}
5255
)
5356

5457
@staticmethod
@@ -60,13 +63,13 @@ async def test_throws_error_if_schema_already_exists(
6063

6164
await client.register_event_schema(
6265
"com.gornisht.ekht",
63-
'{"type":"object","additionalProperties":false}'
66+
{"type": "object", "additionalProperties": False}
6467
)
6568

6669
with pytest.raises(ClientError, match="schema already exists"):
6770
await client.register_event_schema(
6871
"com.gornisht.ekht",
69-
'{"type":"object","additionalProperties":false}'
72+
{"type": "object", "additionalProperties": False}
7073
)
7174

7275
@staticmethod
@@ -77,7 +80,7 @@ async def test_throws_error_if_schema_is_invalid(
7780
client = database.with_authorization.client
7881

7982
with pytest.raises(ClientError, match="'/type' does not validate"):
80-
await client.register_event_schema("com.gornisht.ekht", '{"type":"gurkenwasser"}')
83+
await client.register_event_schema("com.gornisht.ekht", {"type": "gurkenwasser"})
8184

8285

8386
class TestRegisterEventSchemaWithMockServer:

0 commit comments

Comments
 (0)