Skip to content

Commit c8dcd86

Browse files
Minor overall performance improvements (#206)
1 parent 1f42e37 commit c8dcd86

File tree

18 files changed

+197
-105
lines changed

18 files changed

+197
-105
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,16 @@ Please use [this](https://docs.gitlab.com/ee/development/changelog.html) documen
88

99
* demos: Tezos Domains and Homebase DAO demos were updated from edo2net to mainnet contracts.
1010

11+
### Performance
12+
13+
* dipdup: Minor overall performance improvements.
14+
1115
### Other
1216

1317
* ci: Cache virtual environment in GitHub Actions.
1418
* ci: Detect CI environment and skip tests that fail in GitHub Actions.
1519
* ci: Execute tests in parallel with `pytest-xdist` when possible.
20+
* ci: More strict linting rules of `flake8`.
1621

1722
## 4.0.3 - 2022-01-09
1823

poetry.lock

Lines changed: 90 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,17 +47,21 @@ black = "^20.8b1"
4747
bump2version = "^1.0.1"
4848
diff-cover = "^5.0.1"
4949
flake8 = "3.9.0"
50+
flake8-return = "^1.1.3"
51+
flake8-comprehensions = "^3.8.0"
52+
flake8-bugbear = "^22.1.11"
53+
flake8-simplify = "^0.14.5"
5054
flakehell = "^0.9.0"
5155
isort = "^5.7.0"
5256
mypy = "^0.900"
5357
pyperf = "^2.3.0"
5458
pytest = "^6.2.5"
5559
pytest-cov = "^3.0.0"
60+
pytest-xdist = "^2.5.0"
5661
testcontainers = "^3.4.1"
5762
types-pytz = "^2021.1.2"
5863
types-tabulate = "^0.8.2"
5964
pprofile = "^2.1.0"
60-
pytest-xdist = "^2.5.0"
6165

6266
[tool.poetry.extras]
6367
pytezos = ["pytezos"]
@@ -83,6 +87,7 @@ show_source = true
8387
pyflakes = ["+*"]
8488
"flake8-*" = ["+*"]
8589
flake8-docstrings = ["-*"]
90+
flake8-simplify = ["-SIM106"]
8691

8792
[build-system]
8893
requires = ["poetry_core>=1.0.0", "cryptography==3.3.2", "wheel"]

src/demo_registrydao/handlers/on_factory_origination.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,5 @@ async def on_factory_origination(
1919
await ctx.add_index(
2020
name=name,
2121
template='registry_dao',
22-
values=dict(contract=originated_contract),
22+
values={'contract': originated_contract},
2323
)

src/demo_tezos_domains/handlers/on_storage_diff.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,19 @@ async def on_storage_diff(ctx: HandlerContext, storage: NameRegistryStorage) ->
1414
return
1515

1616
if item.level == "1":
17-
await models.TLD.update_or_create(id=record_name, defaults=dict(owner=item.owner))
17+
await models.TLD.update_or_create(id=record_name, defaults={'owner': item.owner})
1818
else:
1919
if item.level == "2":
2020
await models.Domain.update_or_create(
2121
id=record_name,
22-
defaults=dict(
23-
tld_id=record_path[-1],
24-
owner=item.owner,
25-
expiry=storage.store.expiry_map.get(item.expiry_key) if item.expiry_key else None, # type: ignore
26-
token_id=int(item.tzip12_token_id) if item.tzip12_token_id else None,
27-
),
22+
defaults={
23+
'tld_id': record_path[-1],
24+
'owner': item.owner,
25+
'expiry': storage.store.expiry_map.get(item.expiry_key) if item.expiry_key else None, # type: ignore
26+
'token_id': int(item.tzip12_token_id) if item.tzip12_token_id else None,
27+
},
2828
)
2929

30-
await models.Record.update_or_create(id=record_name, defaults=dict(domain_id='.'.join(record_path[-2:]), address=item.address))
30+
await models.Record.update_or_create(
31+
id=record_name, defaults={'domain_id': '.'.join(record_path[-2:]), 'address': item.address}
32+
)

src/demo_tezos_domains_big_map/handlers/on_update_expiry_map.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,5 @@ async def on_update_expiry_map(
1818
record_name = bytes.fromhex(store_expiry_map.key.__root__).decode()
1919
await models.Expiry.update_or_create(
2020
id=record_name,
21-
defaults=dict(timestamp=timestamp),
21+
defaults={'timestamp': timestamp},
2222
)

src/demo_tezos_domains_big_map/handlers/on_update_records.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,19 +23,19 @@ async def on_update_records(
2323
return
2424

2525
if store_records.value.level == "1":
26-
await models.TLD.update_or_create(id=record_name, defaults=dict(owner=store_records.value.owner))
26+
await models.TLD.update_or_create(id=record_name, defaults={'owner': store_records.value.owner})
2727
else:
2828
if store_records.value.level == "2":
2929
await models.Domain.update_or_create(
3030
id=record_name,
31-
defaults=dict(
32-
tld_id=record_path[-1],
33-
owner=store_records.value.owner,
34-
token_id=int(store_records.value.tzip12_token_id) if store_records.value.tzip12_token_id else None,
35-
),
31+
defaults={
32+
'tld_id': record_path[-1],
33+
'owner': store_records.value.owner,
34+
'token_id': int(store_records.value.tzip12_token_id) if store_records.value.tzip12_token_id else None,
35+
},
3636
)
3737

3838
await models.Record.update_or_create(
3939
id=record_name,
40-
defaults=dict(domain_id='.'.join(record_path[-2:]), address=store_records.value.address),
40+
defaults={'domain_id': '.'.join(record_path[-2:]), 'address': store_records.value.address},
4141
)

src/demo_tzcolors/handlers/on_create_auction.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ async def on_create_auction(
1515
token, _ = await models.Token.get_or_create(
1616
id=create_auction.parameter.token_id,
1717
address=create_auction.parameter.token_address,
18-
defaults=dict(
19-
amount=create_auction.parameter.token_amount,
20-
holder=holder,
21-
level=create_auction.data.level,
22-
timestamp=create_auction.data.timestamp,
23-
),
18+
defaults={
19+
'amount': create_auction.parameter.token_amount,
20+
'holder': holder,
21+
'level': create_auction.data.level,
22+
'timestamp': create_auction.data.timestamp,
23+
},
2424
)
2525

2626
auction = models.Auction(

src/dipdup/cli.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ def init_sentry(config: DipDupConfig) -> None:
117117
)
118118

119119

120-
@click.group(help='Docs: https://docs.dipdup.net', context_settings=dict(max_content_width=120))
120+
@click.group(help='Docs: https://docs.dipdup.net', context_settings={'max_content_width': 120})
121121
@click.version_option(__version__)
122122
@click.option('--config', '-c', type=str, multiple=True, help='Path to dipdup YAML config', default=['dipdup.yml'])
123123
@click.option('--env-file', '-e', type=str, multiple=True, help='Path to .env file', default=[])

src/dipdup/codegen.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -43,17 +43,17 @@
4343
from dipdup.utils import touch
4444
from dipdup.utils import write
4545

46-
DEFAULT_DOCKER_ENV_FILE_CONTENT = dict(
47-
POSTGRES_USER="dipdup",
48-
POSTGRES_DB="dipdup",
49-
POSTGRES_PASSWORD="changeme",
50-
HASURA_GRAPHQL_DATABASE_URL="postgres://dipdup:changeme@db:5432/dipdup",
51-
HASURA_GRAPHQL_ENABLE_CONSOLE="true",
52-
HASURA_GRAPHQL_ADMIN_INTERNAL_ERRORS="true",
53-
HASURA_GRAPHQL_ENABLED_LOG_TYPES="startup, http-log, webhook-log, websocket-log, query-log",
54-
HASURA_GRAPHQL_ADMIN_SECRET="changeme",
55-
HASURA_GRAPHQL_UNAUTHORIZED_ROLE="user",
56-
)
46+
DEFAULT_DOCKER_ENV_FILE_CONTENT = {
47+
'POSTGRES_USER': 'dipdup',
48+
'POSTGRES_DB': 'dipdup',
49+
'POSTGRES_PASSWORD': 'changeme',
50+
'HASURA_GRAPHQL_DATABASE_URL': 'postgres://dipdup:changeme@db:5432/dipdup',
51+
'HASURA_GRAPHQL_ENABLE_CONSOLE': 'true',
52+
'HASURA_GRAPHQL_ADMIN_INTERNAL_ERRORS': 'true',
53+
'HASURA_GRAPHQL_ENABLED_LOG_TYPES': 'startup, http-log, webhook-log, websocket-log, query-log',
54+
'HASURA_GRAPHQL_ADMIN_SECRET': 'changeme',
55+
'HASURA_GRAPHQL_UNAUTHORIZED_ROLE': 'user',
56+
}
5757
DEFAULT_DOCKER_IMAGE = 'dipdup/dipdup'
5858
DEFAULT_DOCKER_TAG = __version__
5959
DEFAULT_DOCKER_ENV_FILE = 'dipdup.env'

0 commit comments

Comments
 (0)