Skip to content

Commit

Permalink
Fix sqd preprocessing, namespace package checks (#1203)
Browse files Browse the repository at this point in the history
  • Loading branch information
droserasprout authored Jan 30, 2025
1 parent 85111d8 commit 870e605
Show file tree
Hide file tree
Showing 23 changed files with 29 additions and 12 deletions.
4 changes: 1 addition & 3 deletions scripts/demos.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
**dict(os.environ),
'POSTGRES_PASSWORD': '',
'HASURA_SECRET': '',
'DIPDUP_NO_SYMLINK': '1',
}


Expand Down Expand Up @@ -49,9 +50,6 @@ def _init_demo(path: Path) -> None:
env=DEFAULT_ENV,
)

# NOTE: We don't need magic symlinks in demo projects.
Path(package_path).joinpath(package).unlink(missing_ok=True)


def _rm_demo(path: Path) -> None:
rmtree(path, ignore_errors=True)
Expand Down
1 change: 1 addition & 0 deletions src/demo_blank/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ isort = { force-single-line = true}
[tool.mypy]
python_version = "3.12"
plugins = ["pydantic.mypy"]
explicit_package_bases = true
strict = false
exclude = "demo_blank"

Expand Down
1 change: 1 addition & 0 deletions src/demo_evm_events/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ isort = { force-single-line = true}
[tool.mypy]
python_version = "3.12"
plugins = ["pydantic.mypy"]
explicit_package_bases = true
strict = false
exclude = "demo_evm_events"

Expand Down
1 change: 1 addition & 0 deletions src/demo_evm_transactions/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ isort = { force-single-line = true}
[tool.mypy]
python_version = "3.12"
plugins = ["pydantic.mypy"]
explicit_package_bases = true
strict = false
exclude = "demo_evm_transactions"

Expand Down
1 change: 1 addition & 0 deletions src/demo_evm_uniswap/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ isort = { force-single-line = true}
[tool.mypy]
python_version = "3.12"
plugins = ["pydantic.mypy"]
explicit_package_bases = true
strict = false
exclude = "demo_evm_uniswap"

Expand Down
1 change: 1 addition & 0 deletions src/demo_starknet_events/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ isort = { force-single-line = true}
[tool.mypy]
python_version = "3.12"
plugins = ["pydantic.mypy"]
explicit_package_bases = true
strict = false
exclude = "demo_starknet_events"

Expand Down
1 change: 1 addition & 0 deletions src/demo_substrate_events/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ isort = { force-single-line = true}
[tool.mypy]
python_version = "3.12"
plugins = ["pydantic.mypy"]
explicit_package_bases = true
strict = false
exclude = "demo_substrate_events"

Expand Down
1 change: 1 addition & 0 deletions src/demo_tezos_auction/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ isort = { force-single-line = true}
[tool.mypy]
python_version = "3.12"
plugins = ["pydantic.mypy"]
explicit_package_bases = true
strict = false
exclude = "demo_tezos_auction"

Expand Down
1 change: 1 addition & 0 deletions src/demo_tezos_dao/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ isort = { force-single-line = true}
[tool.mypy]
python_version = "3.12"
plugins = ["pydantic.mypy"]
explicit_package_bases = true
strict = false
exclude = "demo_tezos_dao"

Expand Down
1 change: 1 addition & 0 deletions src/demo_tezos_dex/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ isort = { force-single-line = true}
[tool.mypy]
python_version = "3.12"
plugins = ["pydantic.mypy"]
explicit_package_bases = true
strict = false
exclude = "demo_tezos_dex"

Expand Down
1 change: 1 addition & 0 deletions src/demo_tezos_domains/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ isort = { force-single-line = true}
[tool.mypy]
python_version = "3.12"
plugins = ["pydantic.mypy"]
explicit_package_bases = true
strict = false
exclude = "demo_tezos_domains"

Expand Down
1 change: 1 addition & 0 deletions src/demo_tezos_events/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ isort = { force-single-line = true}
[tool.mypy]
python_version = "3.12"
plugins = ["pydantic.mypy"]
explicit_package_bases = true
strict = false
exclude = "demo_tezos_events"

Expand Down
1 change: 1 addition & 0 deletions src/demo_tezos_factories/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ isort = { force-single-line = true}
[tool.mypy]
python_version = "3.12"
plugins = ["pydantic.mypy"]
explicit_package_bases = true
strict = false
exclude = "demo_tezos_factories"

Expand Down
1 change: 1 addition & 0 deletions src/demo_tezos_head/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ isort = { force-single-line = true}
[tool.mypy]
python_version = "3.12"
plugins = ["pydantic.mypy"]
explicit_package_bases = true
strict = false
exclude = "demo_tezos_head"

Expand Down
1 change: 1 addition & 0 deletions src/demo_tezos_nft_marketplace/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ isort = { force-single-line = true}
[tool.mypy]
python_version = "3.12"
plugins = ["pydantic.mypy"]
explicit_package_bases = true
strict = false
exclude = "demo_tezos_nft_marketplace"

Expand Down
1 change: 1 addition & 0 deletions src/demo_tezos_raw/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ isort = { force-single-line = true}
[tool.mypy]
python_version = "3.12"
plugins = ["pydantic.mypy"]
explicit_package_bases = true
strict = false
exclude = "demo_tezos_raw"

Expand Down
1 change: 1 addition & 0 deletions src/demo_tezos_token/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ isort = { force-single-line = true}
[tool.mypy]
python_version = "3.12"
plugins = ["pydantic.mypy"]
explicit_package_bases = true
strict = false
exclude = "demo_tezos_token"

Expand Down
1 change: 1 addition & 0 deletions src/demo_tezos_token_balances/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ isort = { force-single-line = true}
[tool.mypy]
python_version = "3.12"
plugins = ["pydantic.mypy"]
explicit_package_bases = true
strict = false
exclude = "demo_tezos_token_balances"

Expand Down
1 change: 1 addition & 0 deletions src/demo_tezos_token_transfers/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ isort = { force-single-line = true}
[tool.mypy]
python_version = "3.12"
plugins = ["pydantic.mypy"]
explicit_package_bases = true
strict = false
exclude = "demo_tezos_token_transfers"

Expand Down
11 changes: 7 additions & 4 deletions src/dipdup/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ def __init__(self, root: Path, quiet: bool = False) -> None:
self.name = root.name

# NOTE: Paths expected to exist in package root
self.pyproject = root.parent / 'pyproject.toml'
self.root_config = root.parent / 'dipdup.yaml'
self.pyproject = root / 'pyproject.toml'
self.root_config = root / 'dipdup.yaml'

# NOTE: Package sections with .keep markers
self.abi = root / 'abi'
Expand Down Expand Up @@ -130,7 +130,6 @@ def skel(self) -> dict[Path, str | None]:
self.types: '**/*.py',
# NOTE: Python metadata
Path(PEP_561_MARKER): None,
Path(PACKAGE_MARKER): None,
}

def in_migration(self) -> bool:
Expand Down Expand Up @@ -180,7 +179,11 @@ def act(x: str) -> None:

def _post_init(self) -> None:
# NOTE: Allows plain package structure to be imported
if self.root != Path.cwd() or env.NO_SYMLINK:
if env.NO_SYMLINK:
touch(self.root / PACKAGE_MARKER)
return

if self.root != Path.cwd():
return

symlink_path = self.root.joinpath(self.name)
Expand Down
1 change: 1 addition & 0 deletions src/dipdup/projects/base/pyproject.toml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ isort = { force-single-line = true}
[tool.mypy]
python_version = "3.12"
plugins = ["pydantic.mypy"]
explicit_package_bases = true
strict = false
exclude = "{{ project.package }}"

Expand Down
5 changes: 1 addition & 4 deletions src/dipdup/runtimes.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,11 +281,8 @@ def extract_subsquid_payload(data: Any) -> Any:
if 'value' in data:
value = data['value']
if isinstance(value, list | tuple):
# Handle list of values
value = tuple(extract_subsquid_payload(item) for item in value)
# FIXME: We probably shouldn't do this
elif isinstance(value, str):
value = int(value)

return {kind: value}

# NOTE: Special case
Expand Down
2 changes: 1 addition & 1 deletion tests/test_datasources/test_substrate.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
'interior': {
'X2': (
{'PalletInstance': 50},
{'GeneralIndex': 1337},
{'GeneralIndex': '1337'},
),
},
},
Expand Down

0 comments on commit 870e605

Please sign in to comment.