Skip to content

Commit

Permalink
Cleanup and fix Python versions in CI (#67)
Browse files Browse the repository at this point in the history
  • Loading branch information
droserasprout authored Jun 24, 2021
1 parent 2ce168b commit 4370521
Show file tree
Hide file tree
Showing 14 changed files with 117 additions and 127 deletions.
6 changes: 1 addition & 5 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,8 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.6.x'
python-version: '3.8.x'
- uses: snok/install-poetry@v1.1.1
- name: Install dependencies
run: |
sudo apt-get update -q
sudo apt-get install libsodium-dev libsecp256k1-dev libgmp-dev -y
- name: Install project
run: make install
- name: Run lint
Expand Down
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
DEV ?= 1

all: install lint test cover
lint: isort black pylint mypy
lint: isort black flake mypy

debug:
pip install . --force --no-deps
Expand All @@ -19,8 +19,8 @@ isort:
black:
poetry run black src tests

pylint:
poetry run pylint src tests || poetry run pylint-exit $$?
flake:
poetry run flakehell lint src tests

mypy:
poetry run mypy src tests
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Python SDK for developing indexers of [Tezos](https://tezos.com/) smart contract

## Quickstart

Python 3.9+ is required for dipdup to run.
Python 3.8+ is required for dipdup to run.

```shell
$ pip install dipdup
Expand Down
184 changes: 86 additions & 98 deletions poetry.lock

Large diffs are not rendered by default.

16 changes: 13 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ bump2version = "^1.0.1"
diff-cover = "^5.0.1"
isort = "^5.7.0"
mypy = "^0.812"
pylint = "^2.7.2"
pylint-exit = "^1.2.0"
pytest = "^3.0"
pytest-cov = "^2.4"
flake8 = "3.9.0"
flakehell = "^0.9.0"

[tool.poetry.scripts]
dipdup = 'dipdup.cli:cli'
Expand All @@ -53,9 +53,19 @@ line_length = 140

[tool.black]
line-length = 140
target-version = ['py37', 'py38']
target-version = ['py38']
skip-string-normalization = true

[tool.flakehell]
format = "colored"
max_line_length = 140
show_source = true

[tool.flakehell.plugins]
pyflakes = ["+*"]
"flake8-*" = ["+*"]
flake8-docstrings = ["-*"]

[build-system]
requires = ["poetry_core>=1.0.0", "cryptography==3.3.2", "wheel"]
build-backend = "poetry.core.masonry.api"
4 changes: 2 additions & 2 deletions src/demo_hic_et_nunc/handlers/on_swap.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import demo_hic_et_nunc.models as models
from demo_hic_et_nunc.types.hen_minter.parameter.swap import SwapParameter
from demo_hic_et_nunc.types.hen_minter.storage import HenMinterStorage
from dipdup.context import HandlerContext, RollbackHandlerContext
from dipdup.models import BigMapAction, BigMapData, BigMapDiff, OperationData, Origination, Transaction
from dipdup.context import HandlerContext
from dipdup.models import Transaction


async def on_swap(
Expand Down
2 changes: 1 addition & 1 deletion src/dipdup/codegen.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ async def create_package(self) -> None:
self._logger.info('Creating package `%s`', self._config.package)
try:
package_path = self._config.package_path
except (ImportError, ModuleNotFoundError):
except ImportError:
package_path = join(os.getcwd(), self._config.package)
mkdir(package_path)
with open(join(package_path, '__init__.py'), 'w'):
Expand Down
3 changes: 1 addition & 2 deletions src/dipdup/context.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
from typing import Any, Dict, List, Optional
from typing import Any, Dict, Optional

from dipdup.config import ContractConfig, DipDupConfig, StaticTemplateConfig
from dipdup.datasources import DatasourceT
from dipdup.exceptions import ConfigurationError
from dipdup.models import OperationData
from dipdup.utils import FormattedLogger, reindex, restart


Expand Down
1 change: 0 additions & 1 deletion src/dipdup/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,6 @@ async def _process_operations(self, operations: List[OperationData]) -> None:
operation_groups[key] = []
operation_groups[key].append(operation)

keys = list(operation_groups.keys())
for operation_group, operations in operation_groups.items():
self._logger.debug('Matching %s', key)

Expand Down
2 changes: 1 addition & 1 deletion tests/integration_tests/test_codegen.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def import_submodules(package, recursive=True):
if isinstance(package, str):
package = importlib.import_module(package)
results = {}
for loader, name, is_pkg in pkgutil.walk_packages(package.__path__):
for _loader, name, is_pkg in pkgutil.walk_packages(package.__path__):
full_name = package.__name__ + '.' + name
results[full_name] = importlib.import_module(full_name)
if recursive and is_pkg:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
OperationType,
)
from dipdup.context import HandlerContext
from dipdup.datasources.tzkt.datasource import TzktDatasource, dedup_operations
from dipdup.datasources.tzkt.datasource import TzktDatasource
from dipdup.dipdup import DipDup
from dipdup.models import IndexType, OperationData, State, Transaction
from dipdup.utils import tortoise_wrapper
Expand Down Expand Up @@ -130,7 +130,6 @@ async def test_on_operation_message_state(self):
async def test_on_operation_message_data(self):
with open(join(dirname(__file__), 'operations.json')) as file:
operations_message = json.load(file)
operations = [TzktDatasource.convert_operation(op) for op in operations_message['data']]
operation = TzktDatasource.convert_operation(operations_message['data'][-2])

on_operation_match_mock = AsyncMock()
Expand Down
13 changes: 7 additions & 6 deletions tests/test_dipdup/test_datasources/test_tzkt/test_matcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@
from os.path import dirname, join
from unittest import skip
from unittest.async_case import IsolatedAsyncioTestCase # type: ignore
from unittest.mock import ANY, AsyncMock, MagicMock # type: ignore
from unittest.mock import AsyncMock, MagicMock # type: ignore

from dipdup.config import ContractConfig, OperationHandlerConfig, OperationHandlerTransactionPatternConfig, OperationIndexConfig
from dipdup.datasources.tzkt.datasource import TzktDatasource
from dipdup.dipdup import DipDup
from dipdup.models import OperationData, State
from dipdup.index import OperationGroup
from dipdup.models import OperationData


@skip('FIXME')
Expand All @@ -33,10 +34,10 @@ async def asyncSetUp(self):
self.index_config.state = MagicMock()
self.index_config.state.save = AsyncMock()
self.dipdup_mock = MagicMock(spec=DipDup)
self.matcher = OperationMatcher(
self.dipdup_mock,
{'test': self.index_config},
)
# self.matcher = OperationMatcher(
# self.dipdup_mock,
# {'test': self.index_config},
# )

async def test_add(self):
with open(join(dirname(__file__), 'operations.json')) as file:
Expand Down
1 change: 0 additions & 1 deletion tests/test_dipdup/test_models.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from unittest import TestCase
from unittest.mock import MagicMock

from demo_tezos_domains.types.name_registry.storage import NameRegistryStorage
from dipdup.models import OperationData
Expand Down
1 change: 0 additions & 1 deletion tests/test_dipdup/test_utils.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from contextlib import suppress
from os.path import dirname, join
from unittest import IsolatedAsyncioTestCase

from tortoise import Tortoise
Expand Down

0 comments on commit 4370521

Please sign in to comment.