Skip to content

Commit 9879c29

Browse files
committed
Tortoise 1.0 update
1 parent 3812602 commit 9879c29

8 files changed

Lines changed: 281 additions & 287 deletions

File tree

pyproject.toml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,14 +79,14 @@ dependencies = [
7979
"strict-rfc3339~=0.7",
8080
"survey~=5.4",
8181
"tabulate~=0.9",
82-
"tortoise-orm==0.25.3", # pinned
82+
"tortoise-orm==1.0.0", # pinned
8383
"uvloop~=0.20",
8484
"web3~=7.2",
8585
]
8686

8787
[project.optional-dependencies]
8888
migrations = [
89-
"aerich~=0.9.0",
89+
"aerich",
9090
]
9191

9292
[project.urls]
@@ -163,7 +163,6 @@ build-backend = "uv_build"
163163
[dependency-groups]
164164
lint = [
165165
"mypy",
166-
"types-pytz",
167166
"types-tabulate",
168167
]
169168
test = [

requirements.txt

Lines changed: 101 additions & 98 deletions
Large diffs are not rendered by default.

src/dipdup/cli.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -730,7 +730,7 @@ async def schema(ctx: click.Context) -> None:
730730
Run `dipdup schema init` or `dipdup run` to the run the indexer and it'll be initialized automatically."""
731731
)
732732

733-
from aerich import Command as AerichCommand
733+
from aerich import Command as AerichCommand # type: ignore[import-untyped]
734734

735735
from dipdup.database import get_tortoise_config
736736

@@ -761,13 +761,13 @@ def wrapper(ctx: click.Context, /, *args: Any, **kwargs: Any) -> None:
761761
# NOTE: Saving 0.45s on imports and hiding from reference
762762
if 'schema' in sys.argv:
763763
try:
764-
from aerich.cli import cli as aerich_cli
764+
from aerich.cli import cli as aerich_cli # type: ignore[import-untyped]
765765

766-
schema.add_command(aerich_cli.commands['history']) # type: ignore
767-
schema.add_command(aerich_cli.commands['heads']) # type: ignore
768-
schema.add_command(aerich_cli.commands['migrate']) # type: ignore
769-
schema.add_command(_approve_schema_after(aerich_cli.commands['upgrade'])) # type: ignore
770-
schema.add_command(_approve_schema_after(aerich_cli.commands['downgrade'])) # type: ignore
766+
schema.add_command(aerich_cli.commands['history'])
767+
schema.add_command(aerich_cli.commands['heads'])
768+
schema.add_command(aerich_cli.commands['migrate'])
769+
schema.add_command(_approve_schema_after(aerich_cli.commands['upgrade']))
770+
schema.add_command(_approve_schema_after(aerich_cli.commands['downgrade']))
771771
except ImportError:
772772
_logger.debug('aerich is not installed, skipping database migration commands')
773773

src/dipdup/dipdup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1036,7 +1036,7 @@ async def _initialize_migrations(self) -> None:
10361036

10371037
migrations_dir = self._ctx.package.migrations
10381038
try:
1039-
from aerich import Command as AerichCommand
1039+
from aerich import Command as AerichCommand # type: ignore[import-untyped]
10401040

10411041
tortoise_config = get_tortoise_config(self._config.database.connection_string, self._config.package)
10421042
aerich_command = AerichCommand(

src/dipdup/test.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,10 @@ async def run_postgres_container() -> PostgresDatabaseConfig:
9898
)
9999
atexit.register(postgres_container.stop)
100100
postgres_container.reload()
101-
postgres_ip = postgres_container.attrs['NetworkSettings']['IPAddress']
101+
try:
102+
postgres_ip = postgres_container.attrs['NetworkSettings']['IPAddress']
103+
except KeyError:
104+
postgres_ip = postgres_container.attrs['NetworkSettings']['Networks']['bridge']['IPAddress']
102105

103106
while not postgres_container.exec_run('pg_isready').exit_code == 0:
104107
await asyncio.sleep(0.1)
@@ -126,7 +129,10 @@ async def run_hasura_container(postgres_ip: str) -> HasuraConfig:
126129
)
127130
atexit.register(hasura_container.stop)
128131
hasura_container.reload()
129-
hasura_ip = hasura_container.attrs['NetworkSettings']['IPAddress']
132+
try:
133+
hasura_ip = hasura_container.attrs['NetworkSettings']['IPAddress']
134+
except KeyError:
135+
hasura_ip = hasura_container.attrs['NetworkSettings']['Networks']['bridge']['IPAddress']
130136

131137
return HasuraConfig(
132138
url=f'http://{hasura_ip}:8080',

tests/test_dipdup.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
from contextlib import AsyncExitStack
2-
from datetime import datetime
2+
from datetime import UTC, datetime
33
from pathlib import Path
44

55
import pytest
6-
from pytz import UTC
76

87
from dipdup.config import DipDupConfig
98
from dipdup.config import SqliteDatabaseConfig

tests/test_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class SomeException(Exception): ...
2323

2424
async def test_in_global_transaction() -> None:
2525
transactions = TransactionManager()
26-
async with tortoise_wrapper('sqlite://:memory:'):
26+
async with tortoise_wrapper('sqlite://:memory:', models='demo_tezos_token.models'):
2727
await Tortoise.generate_schemas()
2828

2929
# 1. Success query without transaction

uv.lock

Lines changed: 160 additions & 173 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)