Skip to content

Commit 45466ec

Browse files
rogelioLpzmatin
andauthored
Fix mypy (#12)
* mypy * typing cast * ignore __init__ * already fixed this with new version of clabe-python * version bump Co-authored-by: Matin Tamizi <matin@cuenca.com>
1 parent bfa13cb commit 45466ec

File tree

6 files changed

+12
-8
lines changed

6 files changed

+12
-8
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ lint:
2626
flake8 $(PROJECT) tests setup.py
2727
$(isort) --check-only
2828
$(black) --check
29-
# mypy $(PROJECT) tests
29+
mypy $(PROJECT) tests
3030

3131
clean:
3232
rm -rf `find . -name __pycache__`

cuenca/resources/api_keys.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import datetime as dt
2-
from typing import ClassVar, Optional
2+
from typing import ClassVar, Optional, cast
33

44
from pydantic.dataclasses import dataclass
55

@@ -27,7 +27,7 @@ def active(self) -> bool:
2727

2828
@classmethod
2929
def create(cls) -> 'ApiKey':
30-
return cls._create()
30+
return cast('ApiKey', cls._create())
3131

3232
@classmethod
3333
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':
4040
"""
4141
url = cls._endpoint + f'/{api_key_id}'
4242
resp = session.delete(url, dict(minutes=minutes))
43-
return cls._from_dict(resp)
43+
return cast('ApiKey', cls._from_dict(resp))

cuenca/resources/base.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
1212
class Resource:
1313
_endpoint: ClassVar[str]
1414

15+
def __init__(self, **kwargs): # pragma no cover
16+
for attr, value in kwargs.items():
17+
setattr(self, attr, value)
18+
1519
@classmethod
1620
def _from_dict(cls, obj_dict: Dict[str, Union[str, int]]) -> 'Resource':
1721
cls._filter_excess_fields(obj_dict)

cuenca/resources/transfers.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import datetime as dt
2-
from typing import ClassVar, Optional
2+
from typing import ClassVar, Optional, cast
33

44
from clabe import Clabe
55
from pydantic import BaseModel, StrictStr
@@ -70,7 +70,7 @@ def create(
7070
recipient_name=recipient_name,
7171
idempotency_key=idempotency_key,
7272
)
73-
return cls._create(**req.dict())
73+
return cast('Transfer', cls._create(**req.dict()))
7474

7575
@staticmethod
7676
def _gen_idempotency_key(account_number: str, amount: int) -> str:

cuenca/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
__version__ = '0.1.3'
1+
__version__ = '0.1.4'
22
CLIENT_VERSION = __version__
33
API_VERSION = '2020-03-19'

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@ force_grid_wrap=0
1515
combine_as_imports=True
1616
1717
[mypy-pytest]
18-
ignore_missing_imports = true
18+
ignore_missing_imports = True

0 commit comments

Comments
 (0)