diff --git a/Makefile b/Makefile index 2b2f3fa6..5f3d6467 100644 --- a/Makefile +++ b/Makefile @@ -26,7 +26,7 @@ lint: flake8 $(PROJECT) tests setup.py $(isort) --check-only $(black) --check -# mypy $(PROJECT) tests + mypy $(PROJECT) tests clean: rm -rf `find . -name __pycache__` diff --git a/cuenca/resources/api_keys.py b/cuenca/resources/api_keys.py index 34aa7989..d4d5b61a 100644 --- a/cuenca/resources/api_keys.py +++ b/cuenca/resources/api_keys.py @@ -1,5 +1,5 @@ import datetime as dt -from typing import ClassVar, Optional +from typing import ClassVar, Optional, cast from pydantic.dataclasses import dataclass @@ -27,7 +27,7 @@ def active(self) -> bool: @classmethod def create(cls) -> 'ApiKey': - return cls._create() + return cast('ApiKey', cls._create()) @classmethod def deactivate(cls, api_key_id: str, minutes: int = 0) -> 'ApiKey': @@ -40,4 +40,4 @@ def deactivate(cls, api_key_id: str, minutes: int = 0) -> 'ApiKey': """ url = cls._endpoint + f'/{api_key_id}' resp = session.delete(url, dict(minutes=minutes)) - return cls._from_dict(resp) + return cast('ApiKey', cls._from_dict(resp)) diff --git a/cuenca/resources/base.py b/cuenca/resources/base.py index ba1416c9..22badfc7 100644 --- a/cuenca/resources/base.py +++ b/cuenca/resources/base.py @@ -12,6 +12,10 @@ class Resource: _endpoint: ClassVar[str] + def __init__(self, **kwargs): # pragma no cover + for attr, value in kwargs.items(): + setattr(self, attr, value) + @classmethod def _from_dict(cls, obj_dict: Dict[str, Union[str, int]]) -> 'Resource': cls._filter_excess_fields(obj_dict) diff --git a/cuenca/resources/transfers.py b/cuenca/resources/transfers.py index e4faa8ad..87bbe304 100644 --- a/cuenca/resources/transfers.py +++ b/cuenca/resources/transfers.py @@ -1,5 +1,5 @@ import datetime as dt -from typing import ClassVar, Optional +from typing import ClassVar, Optional, cast from clabe import Clabe from pydantic import BaseModel, StrictStr @@ -70,7 +70,7 @@ def create( recipient_name=recipient_name, idempotency_key=idempotency_key, ) - return cls._create(**req.dict()) + return cast('Transfer', cls._create(**req.dict())) @staticmethod def _gen_idempotency_key(account_number: str, amount: int) -> str: diff --git a/cuenca/version.py b/cuenca/version.py index 8850a2d8..bf18f21c 100644 --- a/cuenca/version.py +++ b/cuenca/version.py @@ -1,3 +1,3 @@ -__version__ = '0.1.3' +__version__ = '0.1.4' CLIENT_VERSION = __version__ API_VERSION = '2020-03-19' diff --git a/setup.cfg b/setup.cfg index 60547132..ec271f9f 100644 --- a/setup.cfg +++ b/setup.cfg @@ -15,4 +15,4 @@ force_grid_wrap=0 combine_as_imports=True [mypy-pytest] -ignore_missing_imports = true +ignore_missing_imports = True