kopia lustrzana https://github.com/bugout-dev/moonstream
Mypy fixes for backend
rodzic
356f4ff05e
commit
c8fc3aecf3
|
@ -19,9 +19,9 @@ jobs:
|
||||||
- name: Install test requirements
|
- name: Install test requirements
|
||||||
working-directory: ./backend
|
working-directory: ./backend
|
||||||
run: pip install -r requirements.txt
|
run: pip install -r requirements.txt
|
||||||
# - name: Mypy type check
|
- name: Mypy type check
|
||||||
# working-directory: ./backend
|
working-directory: ./backend
|
||||||
# run: mypy moonstream/
|
run: mypy moonstream/
|
||||||
- name: Black syntax check
|
- name: Black syntax check
|
||||||
working-directory: ./backend
|
working-directory: ./backend
|
||||||
run: black --check moonstream/
|
run: black --check moonstream/
|
||||||
|
|
|
@ -1,14 +1,11 @@
|
||||||
from datetime import datetime
|
import json
|
||||||
import logging
|
import logging
|
||||||
|
from typing import Dict, Any, List, Optional
|
||||||
|
|
||||||
|
import boto3 # type: ignore
|
||||||
from typing import Dict, Any, List, Optional, Union
|
|
||||||
|
|
||||||
from sqlalchemy.engine.base import Transaction
|
|
||||||
from moonstreamdb.models import (
|
from moonstreamdb.models import (
|
||||||
EthereumBlock,
|
EthereumBlock,
|
||||||
EthereumTransaction,
|
EthereumTransaction,
|
||||||
EthereumPendingTransaction,
|
|
||||||
EthereumAddress,
|
EthereumAddress,
|
||||||
EthereumLabel,
|
EthereumLabel,
|
||||||
)
|
)
|
||||||
|
@ -16,10 +13,7 @@ from sqlalchemy import or_, and_, text
|
||||||
from sqlalchemy.orm import Session
|
from sqlalchemy.orm import Session
|
||||||
|
|
||||||
from . import data
|
from . import data
|
||||||
|
|
||||||
from .settings import DEFAULT_STREAM_TIMEINTERVAL, ETHERSCAN_SMARTCONTRACTS_BUCKET
|
from .settings import DEFAULT_STREAM_TIMEINTERVAL, ETHERSCAN_SMARTCONTRACTS_BUCKET
|
||||||
import boto3
|
|
||||||
import json
|
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
@ -299,8 +293,8 @@ def get_source_code(
|
||||||
|
|
||||||
|
|
||||||
def get_address_labels(
|
def get_address_labels(
|
||||||
db_session: Session, start: int, limit: int, addresses: Optional[List[str]] = None
|
db_session: Session, start: int, limit: int, addresses: Optional[str] = None
|
||||||
) -> List[EthereumAddress]:
|
) -> data.AddressListLabelsResponse:
|
||||||
"""
|
"""
|
||||||
Attach labels to addresses.
|
Attach labels to addresses.
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -97,8 +97,8 @@ async def txinfo_ethereum_blockchain_handler(
|
||||||
)
|
)
|
||||||
async def addresses_labels_handler(
|
async def addresses_labels_handler(
|
||||||
addresses: Optional[str] = Query(None),
|
addresses: Optional[str] = Query(None),
|
||||||
start: Optional[int] = Query(0),
|
start: int = Query(0),
|
||||||
limit: Optional[int] = Query(100),
|
limit: int = Query(100),
|
||||||
db_session: Session = Depends(yield_db_session),
|
db_session: Session = Depends(yield_db_session),
|
||||||
) -> data.AddressListLabelsResponse:
|
) -> data.AddressListLabelsResponse:
|
||||||
"""
|
"""
|
||||||
|
@ -110,11 +110,11 @@ async def addresses_labels_handler(
|
||||||
status_code=406, detail="The limit cannot exceed 100 addresses"
|
status_code=406, detail="The limit cannot exceed 100 addresses"
|
||||||
)
|
)
|
||||||
try:
|
try:
|
||||||
addresses = actions.get_address_labels(
|
addresses_response = actions.get_address_labels(
|
||||||
db_session=db_session, start=start, limit=limit, addresses=addresses
|
db_session=db_session, start=start, limit=limit, addresses=addresses
|
||||||
)
|
)
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
logger.error(f"Unable to get info about Ethereum addresses {err}")
|
logger.error(f"Unable to get info about Ethereum addresses {err}")
|
||||||
raise HTTPException(status_code=500)
|
raise HTTPException(status_code=500)
|
||||||
|
|
||||||
return addresses
|
return addresses_response
|
||||||
|
|
|
@ -16,8 +16,8 @@ MOONSTREAM_DATA_JOURNAL_ID = os.environ.get("MOONSTREAM_DATA_JOURNAL_ID")
|
||||||
if MOONSTREAM_DATA_JOURNAL_ID is None:
|
if MOONSTREAM_DATA_JOURNAL_ID is None:
|
||||||
raise ValueError("MOONSTREAM_DATA_JOURNAL_ID environment variable must be set")
|
raise ValueError("MOONSTREAM_DATA_JOURNAL_ID environment variable must be set")
|
||||||
|
|
||||||
MOONSTREAM_ADMIN_ACCESS_TOKEN = os.environ.get("MOONSTREAM_ADMIN_ACCESS_TOKEN")
|
MOONSTREAM_ADMIN_ACCESS_TOKEN = os.environ.get("MOONSTREAM_ADMIN_ACCESS_TOKEN", "")
|
||||||
if MOONSTREAM_ADMIN_ACCESS_TOKEN is None:
|
if MOONSTREAM_ADMIN_ACCESS_TOKEN == "":
|
||||||
raise ValueError("MOONSTREAM_ADMIN_ACCESS_TOKEN environment variable must be set")
|
raise ValueError("MOONSTREAM_ADMIN_ACCESS_TOKEN environment variable must be set")
|
||||||
|
|
||||||
# Origin
|
# Origin
|
||||||
|
|
Ładowanie…
Reference in New Issue