Skip to content

Commit

Permalink
💄 Lint with isort
Browse files Browse the repository at this point in the history
  • Loading branch information
Guido W. Pettinari authored and coccoinomane committed Dec 17, 2022
1 parent 9e6a1c1 commit b483053
Show file tree
Hide file tree
Showing 57 changed files with 203 additions and 127 deletions.
11 changes: 0 additions & 11 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: check-yaml

- repo: https://github.com/pre-commit/mirrors-isort
rev: v5.10.1
hooks:
Expand All @@ -21,11 +16,5 @@ repos:
- id: mypy
additional_dependencies: [types-setuptools]

- repo: https://github.com/executablebooks/mdformat
rev: 0.7.14
hooks:
- id: mdformat
additional_dependencies: [mdformat-gfm, mdformat-frontmatter]

default_language_version:
python: python3
3 changes: 2 additions & 1 deletion src/web3cli/controllers/base_controller.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from cement import ex

from web3cli.controllers.controller import Controller
from web3cli.helpers.version import get_version_message
from web3cli.helpers import args
from web3cli.helpers.version import get_version_message


class BaseController(Controller):
Expand Down
4 changes: 3 additions & 1 deletion src/web3cli/controllers/config_controller.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import argparse

from cement import ex

from web3cli.controllers.controller import Controller
from web3cli.helpers.config import update_setting_in_config_file
import argparse


class ConfigController(Controller):
Expand Down
3 changes: 2 additions & 1 deletion src/web3cli/controllers/controller.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from typing import Any

from cement import App
from cement import Controller as CementController
from cement.core.config import ConfigInterface
from cement import App


class Controller(CementController):
Expand Down
3 changes: 2 additions & 1 deletion src/web3cli/controllers/db/address_controller.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from cement import ex

from web3cli.controllers.controller import Controller
from web3cli.core.models.address import Address
from web3cli.core.exceptions import Web3CliError
from web3cli.core.models.address import Address
from web3cli.helpers.render import render_table


Expand Down
1 change: 1 addition & 0 deletions src/web3cli/controllers/db/chain_controller.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from cement import ex

from web3cli.controllers.controller import Controller
from web3cli.core.exceptions import ChainNotFound, Web3CliError
from web3cli.core.models.chain import Chain
Expand Down
5 changes: 3 additions & 2 deletions src/web3cli/controllers/db/contract_controller.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
from cement import ex
from playhouse.shortcuts import model_to_dict

from web3cli.controllers.controller import Controller
from web3cli.core.exceptions import Web3CliError
from web3cli.core.helpers.os import read_json
from web3cli.core.models.contract import Contract
from web3cli.core.exceptions import Web3CliError
from web3cli.helpers.render import render_table
from playhouse.shortcuts import model_to_dict


class ContractController(Controller):
Expand Down
1 change: 1 addition & 0 deletions src/web3cli/controllers/db/db_base_controller.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from cement import ex

from web3cli.controllers.controller import Controller
from web3cli.core.helpers.input import yes_or_exit
from web3cli.helpers.database import delete_db_file, get_db_file
Expand Down
4 changes: 2 additions & 2 deletions src/web3cli/controllers/db/rpc_controller.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from cement import ex

from web3cli.controllers.controller import Controller
from web3cli.core.exceptions import ChainNotFound, Web3CliError
from web3cli.core.models.chain import Chain, Rpc, ChainRpc

from web3cli.core.models.chain import Chain, ChainRpc, Rpc
from web3cli.helpers.render import render_table


Expand Down
9 changes: 5 additions & 4 deletions src/web3cli/controllers/db/signer_controller.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import getpass

from cement import ex
from eth_account import Account

from web3cli.controllers.controller import Controller
from web3cli.core.models.signer import Signer
from web3cli.core.exceptions import KeyIsInvalid, SignerNotFound, Web3CliError
from web3cli.core.models.signer import Signer
from web3cli.helpers.crypto import encrypt_string_with_app_key
from eth_account import Account
import getpass

from web3cli.helpers.render import render_table


Expand Down
7 changes: 4 additions & 3 deletions src/web3cli/controllers/db/tx_controller.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
from cement import ex
from playhouse.shortcuts import model_to_dict

from web3cli.controllers.controller import Controller
from web3cli.core.models.tx import Tx
from web3cli.core.exceptions import Web3CliError
from web3cli.helpers.render import render_table
from web3cli.core.helpers.format import cut
from playhouse.shortcuts import model_to_dict
from web3cli.core.models.tx import Tx
from web3cli.helpers.render import render_table


class TxController(Controller):
Expand Down
6 changes: 4 additions & 2 deletions src/web3cli/controllers/key_controller.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import secrets
import sys

from cement import ex

from web3cli.controllers.controller import Controller
from web3cli.helpers.config import update_setting_in_config_file
import secrets
import sys


class KeyController(Controller):
Expand Down
2 changes: 2 additions & 0 deletions src/web3cli/controllers/misc_controller.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from pprint import pformat

from cement import ex

from web3cli.controllers.controller import Controller
from web3cli.core.models.address import Address
from web3cli.helpers.chain import chain_ready_or_raise
Expand Down
1 change: 1 addition & 0 deletions src/web3cli/controllers/send_controller.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from cement import ex

from web3cli.controllers.controller import Controller
from web3cli.core.helpers.input import yes_or_exit
from web3cli.core.models.address import Address
Expand Down
8 changes: 5 additions & 3 deletions src/web3cli/core/helpers/client_factory.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
from typing import Any, Type
from web3cli.core.models.signer import Signer
from web3cli.core.types import Logger

from web3client.base_client import BaseClient
from web3cli.core.models.chain import Chain

from web3cli.core.helpers.crypto import decrypt_string
from web3cli.core.models.chain import Chain
from web3cli.core.models.signer import Signer
from web3cli.core.types import Logger


def make_base_client(
Expand Down
1 change: 1 addition & 0 deletions src/web3cli/core/helpers/crypto.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import secrets

from cryptography.hazmat.primitives.ciphers.aead import AESGCM


Expand Down
8 changes: 5 additions & 3 deletions src/web3cli/core/helpers/database.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
import os
from typing import List, Type

from playhouse.sqlite_ext import SqliteExtDatabase
from web3cli.core.models.base_model import BaseModel, db

from web3cli.core.helpers.os import create_folder
from web3cli.core.models.address import Address
from web3cli.core.models.base_model import BaseModel, db
from web3cli.core.models.chain import Chain, ChainRpc, Rpc
from web3cli.core.models.contract import Contract
from web3cli.core.models.signer import Signer
from web3cli.core.models.tx import Tx
from web3cli.core.helpers.os import create_folder
import os

tables: List[Type[BaseModel]] = [Signer, Address, Chain, Rpc, ChainRpc, Tx, Contract]

Expand Down
3 changes: 2 additions & 1 deletion src/web3cli/core/helpers/input.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from typing import Any
import sys
from typing import Any

from web3cli.core.types import Logger


Expand Down
1 change: 0 additions & 1 deletion src/web3cli/core/helpers/rpc.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from urllib.parse import urlparse


HTTP_SCHEMES = {"http", "https"}
WS_SCHEMES = {"ws", "wss"}

Expand Down
4 changes: 3 additions & 1 deletion src/web3cli/core/helpers/yaml.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import os
from typing import Any

import ruamel.yaml
import os

from web3cli.core.types import Logger


Expand Down
13 changes: 6 additions & 7 deletions src/web3cli/core/models/address.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
from __future__ import annotations

from typing import Type

import web3
from peewee import TextField
from playhouse.signals import pre_save

from web3cli.core.exceptions import AddressIsInvalid, AddressNotResolved, RecordNotFound
from web3cli.core.models.base_model import BaseModel
from web3cli.core.exceptions import (
AddressIsInvalid,
RecordNotFound,
AddressNotResolved,
)
import web3
from web3cli.core.models.types import AddressFields
from playhouse.signals import pre_save
from web3cli.core.types import Logger


Expand Down
9 changes: 6 additions & 3 deletions src/web3cli/core/models/base_model.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
from __future__ import annotations
from peewee import SqliteDatabase, Field

from typing import Any, Dict, List, Type, TypeVar

from peewee import Field, SqliteDatabase
from playhouse.shortcuts import update_model_from_dict
from playhouse.signals import Model
from typing import List, Dict, Any, Type, TypeVar

from web3cli.core.exceptions import RecordNotFound
from playhouse.shortcuts import update_model_from_dict
from web3cli.core.types import Logger

db = SqliteDatabase(None, pragmas={"foreign_keys": 1})
Expand Down
13 changes: 8 additions & 5 deletions src/web3cli/core/models/chain.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
from __future__ import annotations

from typing import List
from peewee import TextField, IntegerField, ForeignKeyField

from peewee import ForeignKeyField, IntegerField, TextField
from playhouse.shortcuts import dict_to_model
from web3.middleware import geth_poa_middleware
from web3.types import Middleware

from web3cli.core.exceptions import (
ChainNotResolved,
RpcIsInvalid,
Expand All @@ -9,12 +15,9 @@
)
from web3cli.core.helpers.rpc import is_rpc_uri_valid
from web3cli.core.models.base_model import BaseModel
from web3.types import Middleware
from web3.middleware import geth_poa_middleware
from web3cli.core.models.types import ChainFields
from web3cli.core.types import Logger
from playhouse.shortcuts import dict_to_model
from web3cli.core.seeds import chain_seeds
from web3cli.core.types import Logger


class Chain(BaseModel):
Expand Down
7 changes: 5 additions & 2 deletions src/web3cli/core/models/contract.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
from __future__ import annotations

from typing import Type

from peewee import TextField
from playhouse.signals import pre_save
from playhouse.sqlite_ext import JSONField
from web3._utils.validation import validate_abi

from web3cli.core.exceptions import ContractIsInvalid, ContractNotFound
from web3cli.core.models.address import Address
from web3cli.core.models.base_model import BaseModel
from playhouse.sqlite_ext import JSONField
from web3._utils.validation import validate_abi
from web3cli.core.models.types import ContractFields
from web3cli.core.types import Logger

Expand Down
6 changes: 4 additions & 2 deletions src/web3cli/core/models/signer.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
from __future__ import annotations
from peewee import TextField, BlobField

from peewee import BlobField, TextField
from web3 import Account

from web3cli.core.exceptions import SignerNotFound
from web3cli.core.helpers.crypto import encrypt_string
from web3cli.core.models.base_model import BaseModel
from web3cli.core.exceptions import SignerNotFound


class Signer(BaseModel):
Expand Down
2 changes: 2 additions & 0 deletions src/web3cli/core/models/timestamps_model.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import datetime as dt
from typing import Type

from playhouse.signals import pre_save

from web3cli.core.models.base_model import BaseModel


Expand Down
9 changes: 6 additions & 3 deletions src/web3cli/core/models/tx.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
from __future__ import annotations

import re
from typing import Type
from peewee import TextField, DateTimeField, BigIntegerField

from peewee import BigIntegerField, DateTimeField, TextField
from playhouse.signals import pre_save

from web3cli.core.exceptions import AddressIsInvalid, TxIsInvalid, TxNotFound
from web3cli.core.models.address import Address
from web3cli.core.models.timestamps_model import TimestampsModel
from playhouse.signals import pre_save
from web3cli.core.models.types import TxFields
from web3cli.core.types import Logger
import re


class Tx(TimestampsModel):
Expand Down
1 change: 1 addition & 0 deletions src/web3cli/core/models/types.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from typing import Any, Dict, List, TypedDict

from typing_extensions import NotRequired
from web3.types import ABI

Expand Down
2 changes: 1 addition & 1 deletion src/web3cli/core/seeds/chain_seeds.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import List
from web3cli.core.models.types import ChainFields

from web3cli.core.models.types import ChainFields

# Ethereum
eth: ChainFields = {
Expand Down
1 change: 1 addition & 0 deletions src/web3cli/helpers/args.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from cement import App

from web3cli.core.exceptions import RpcIsInvalid, Web3CliError
from web3cli.core.helpers.rpc import is_rpc_uri_valid
from web3cli.core.models.chain import Chain
Expand Down
1 change: 1 addition & 0 deletions src/web3cli/helpers/chain.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from cement import App

from web3cli.core.exceptions import ChainNotFound
from web3cli.core.models.chain import Chain

Expand Down
3 changes: 2 additions & 1 deletion src/web3cli/helpers/client_factory.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from cement import App
from web3cli.core.helpers.client_factory import make_base_client, make_base_wallet
from web3client.base_client import BaseClient

from web3cli.core.exceptions import SignerNotFound
from web3cli.core.helpers.client_factory import make_base_client, make_base_wallet


def make_client(app: App, log: bool = False) -> BaseClient:
Expand Down
Loading

0 comments on commit b483053

Please sign in to comment.