Skip to content

Commit

Permalink
Replace built-in type hints (Dict, List) with dict and list
Browse files Browse the repository at this point in the history
  • Loading branch information
gabino committed Jan 17, 2025
1 parent 05cbf13 commit aef49b4
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 26 deletions.
8 changes: 4 additions & 4 deletions cuenca/resources/card_transactions.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import ClassVar, List, Optional, cast
from typing import ClassVar, Optional, cast

from cuenca_validations.types import (
CardErrorType,
Expand All @@ -19,19 +19,19 @@ class CardTransaction(Transaction):

type: CardTransactionType
network: CardNetwork
related_card_transaction_uris: List[str]
related_card_transaction_uris: list[str]
card_uri: str
card_last4: str
card_type: CardType
metadata: dict
error_type: Optional[CardErrorType] = None

@property # type: ignore
def related_card_transactions(self) -> Optional[List['CardTransaction']]:
def related_card_transactions(self) -> Optional[list['CardTransaction']]:
if not self.related_card_transaction_uris:
return []
return cast(
List['CardTransaction'],
list['CardTransaction'],
retrieve_uris(self.related_card_transaction_uris),
)

Expand Down
8 changes: 4 additions & 4 deletions cuenca/resources/file_batches.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import ClassVar, Dict, List
from typing import ClassVar

from cuenca_validations.types import BatchFileMetadata, FileBatchUploadRequest

Expand All @@ -9,14 +9,14 @@
class FileBatch(Creatable, Queryable):
_resource: ClassVar = 'file_batches'

received_files: List[BatchFileMetadata]
uploaded_files: List[BatchFileMetadata]
received_files: list[BatchFileMetadata]
uploaded_files: list[BatchFileMetadata]
user_id: str

@classmethod
def create(
cls,
files: List[Dict],
files: list[dict],
user_id: str,
*,
session: Session = global_session,
Expand Down
6 changes: 3 additions & 3 deletions cuenca/resources/kyc_validations.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import ClassVar, List, Optional
from typing import ClassVar, Optional

from cuenca_validations.types import KYCFile, KYCValidationRequest
from pydantic import ConfigDict
Expand All @@ -12,7 +12,7 @@ class KYCValidation(Creatable, Retrievable, Queryable):
platform_id: str
attemps: Optional[int] = None
verification_id: Optional[str] = None
files_uri: Optional[List[str]] = None
files_uri: Optional[list[str]] = None

model_config = ConfigDict(
json_schema_extra={
Expand All @@ -32,7 +32,7 @@ def create(
cls,
user_id: str,
force: bool = False,
documents: List[KYCFile] = [],
documents: list[KYCFile] = [],
session: Session = global_session,
) -> 'KYCValidation':
req = KYCValidationRequest(
Expand Down
3 changes: 1 addition & 2 deletions cuenca/resources/resources.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import re
from typing import Dict

from .base import Retrievable

ENDPOINT_RE = re.compile(r'.*/(?P<resource>[a-z_]+)/(?P<id>.+)$')
RESOURCES: Dict[str, Retrievable] = {} # set in ./__init__.py after imports
RESOURCES: dict[str, Retrievable] = {} # set in ./__init__.py after imports


def retrieve_uri(uri: str) -> Retrievable:
Expand Down
4 changes: 2 additions & 2 deletions cuenca/resources/service_providers.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import ClassVar, List
from typing import ClassVar

from cuenca_validations.types import ServiceProviderCategory

Expand All @@ -10,4 +10,4 @@ class ServiceProvider(Retrievable, Queryable):

name: str
provider_key: str
categories: List[ServiceProviderCategory]
categories: list[ServiceProviderCategory]
4 changes: 2 additions & 2 deletions cuenca/resources/transfers.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import datetime as dt
from typing import ClassVar, List, Optional, cast
from typing import ClassVar, Optional, cast

from cuenca_validations.types import (
TransferNetwork,
Expand Down Expand Up @@ -72,7 +72,7 @@ def create(
return cls._create(**req.model_dump())

@classmethod
def create_many(cls, requests: List[TransferRequest]) -> DictStrAny:
def create_many(cls, requests: list[TransferRequest]) -> DictStrAny:
transfers: DictStrAny = dict(submitted=[], errors=[])
for req in requests:
try:
Expand Down
4 changes: 2 additions & 2 deletions cuenca/resources/users.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import datetime as dt
from typing import ClassVar, List, Optional, cast
from typing import ClassVar, Optional, cast

from clabe import Clabe
from cuenca_validations.types import (
Expand Down Expand Up @@ -140,7 +140,7 @@ def update(
email_address: Optional[str] = None,
profession: Optional[str] = None,
address: Optional[Address] = None,
beneficiaries: Optional[List[Beneficiary]] = None,
beneficiaries: Optional[list[Beneficiary]] = None,
govt_id: Optional[KYCFile] = None,
proof_of_address: Optional[KYCFile] = None,
proof_of_life: Optional[KYCFile] = None,
Expand Down
7 changes: 3 additions & 4 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import datetime as dt
from io import BytesIO
from typing import Dict

import pytest
from cuenca_validations.types import Country, Gender, State
Expand Down Expand Up @@ -31,7 +30,7 @@ def transfer():


@pytest.fixture
def curp_validation_request() -> Dict:
def curp_validation_request() -> dict:
curp_validation = dict(
names='José',
first_surname='López',
Expand All @@ -45,7 +44,7 @@ def curp_validation_request() -> Dict:


@pytest.fixture
def user_request() -> Dict:
def user_request() -> dict:
user_dict = dict(
curp='LOHJ660606HDFPRS02',
phone_number='+525511223344',
Expand All @@ -64,7 +63,7 @@ def user_request() -> Dict:


@pytest.fixture
def user_lists_request() -> Dict:
def user_lists_request() -> dict:
user_dict = dict(
curp='LOHJ660606HDFPRS02',
names='Alejandro',
Expand Down
4 changes: 1 addition & 3 deletions tests/resources/test_sessions.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from typing import Dict

import pytest
from cuenca_validations.types import SessionType
from pydantic import ValidationError
Expand All @@ -9,7 +7,7 @@


@pytest.mark.vcr
def test_session_create(curp_validation_request: Dict, user_request: Dict):
def test_session_create(curp_validation_request: dict, user_request: dict):
curp_valdation = CurpValidation.create(**curp_validation_request)
user_request['curp'] = curp_valdation.validated_curp
user = User.create(**user_request)
Expand Down

0 comments on commit aef49b4

Please sign in to comment.