Mypy fixes for backend

pull/159/head
kompotkot 2021-08-24 13:50:36 +00:00
rodzic 356f4ff05e
commit c8fc3aecf3
4 zmienionych plików z 14 dodań i 20 usunięć

Wyświetl plik

@ -19,9 +19,9 @@ jobs:
- name: Install test requirements
working-directory: ./backend
run: pip install -r requirements.txt
# - name: Mypy type check
# working-directory: ./backend
# run: mypy moonstream/
- name: Mypy type check
working-directory: ./backend
run: mypy moonstream/
- name: Black syntax check
working-directory: ./backend
run: black --check moonstream/

Wyświetl plik

@ -1,14 +1,11 @@
from datetime import datetime
import json
import logging
from typing import Dict, Any, List, Optional
from typing import Dict, Any, List, Optional, Union
from sqlalchemy.engine.base import Transaction
import boto3 # type: ignore
from moonstreamdb.models import (
EthereumBlock,
EthereumTransaction,
EthereumPendingTransaction,
EthereumAddress,
EthereumLabel,
)
@ -16,10 +13,7 @@ from sqlalchemy import or_, and_, text
from sqlalchemy.orm import Session
from . import data
from .settings import DEFAULT_STREAM_TIMEINTERVAL, ETHERSCAN_SMARTCONTRACTS_BUCKET
import boto3
import json
logger = logging.getLogger(__name__)
@ -299,8 +293,8 @@ def get_source_code(
def get_address_labels(
db_session: Session, start: int, limit: int, addresses: Optional[List[str]] = None
) -> List[EthereumAddress]:
db_session: Session, start: int, limit: int, addresses: Optional[str] = None
) -> data.AddressListLabelsResponse:
"""
Attach labels to addresses.
"""

Wyświetl plik

@ -97,8 +97,8 @@ async def txinfo_ethereum_blockchain_handler(
)
async def addresses_labels_handler(
addresses: Optional[str] = Query(None),
start: Optional[int] = Query(0),
limit: Optional[int] = Query(100),
start: int = Query(0),
limit: int = Query(100),
db_session: Session = Depends(yield_db_session),
) -> data.AddressListLabelsResponse:
"""
@ -110,11 +110,11 @@ async def addresses_labels_handler(
status_code=406, detail="The limit cannot exceed 100 addresses"
)
try:
addresses = actions.get_address_labels(
addresses_response = actions.get_address_labels(
db_session=db_session, start=start, limit=limit, addresses=addresses
)
except Exception as err:
logger.error(f"Unable to get info about Ethereum addresses {err}")
raise HTTPException(status_code=500)
return addresses
return addresses_response

Wyświetl plik

@ -16,8 +16,8 @@ MOONSTREAM_DATA_JOURNAL_ID = os.environ.get("MOONSTREAM_DATA_JOURNAL_ID")
if MOONSTREAM_DATA_JOURNAL_ID is None:
raise ValueError("MOONSTREAM_DATA_JOURNAL_ID environment variable must be set")
MOONSTREAM_ADMIN_ACCESS_TOKEN = os.environ.get("MOONSTREAM_ADMIN_ACCESS_TOKEN")
if MOONSTREAM_ADMIN_ACCESS_TOKEN is None:
MOONSTREAM_ADMIN_ACCESS_TOKEN = os.environ.get("MOONSTREAM_ADMIN_ACCESS_TOKEN", "")
if MOONSTREAM_ADMIN_ACCESS_TOKEN == "":
raise ValueError("MOONSTREAM_ADMIN_ACCESS_TOKEN environment variable must be set")
# Origin