Skip to content

Commit

Permalink
Refactor: Update type hints from 'List' to 'list'
Browse files Browse the repository at this point in the history
  • Loading branch information
gabino committed Jan 9, 2025
1 parent c95fbdc commit e0174a6
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 37 deletions.
4 changes: 1 addition & 3 deletions agave/core/filters.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
from typing import List

from cuenca_validations.types import QueryParams
from mongoengine import Q


def generic_query(query: QueryParams, excluded: List[str] = []) -> Q:
def generic_query(query: QueryParams, excluded: list[str] = []) -> Q:
filters = Q()
if query.created_before:
filters &= Q(created_at__lt=query.created_before)
Expand Down
11 changes: 5 additions & 6 deletions tests/chalice_tests/blueprint/test_blueprint.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import datetime as dt
from typing import List
from unittest.mock import MagicMock, patch
from urllib.parse import urlencode

Expand Down Expand Up @@ -143,7 +142,7 @@ def test_query_all_with_limit(client: Client) -> None:


@pytest.mark.usefixtures('accounts')
def test_query_all_resource(client: Client, accounts: List[Account]) -> None:
def test_query_all_resource(client: Client, accounts: list[Account]) -> None:
accounts = list(reversed(accounts))

items = []
Expand All @@ -160,7 +159,7 @@ def test_query_all_resource(client: Client, accounts: List[Account]) -> None:


def test_query_all_filter_active(
client: Client, account: Account, accounts: List[Account]
client: Client, account: Account, accounts: list[Account]
) -> None:
query_params = dict(active=True)
# Query active items
Expand Down Expand Up @@ -188,7 +187,7 @@ def test_query_all_filter_active(


def test_query_all_created_after(
client: Client, accounts: List[Account]
client: Client, accounts: list[Account]
) -> None:
created_at = dt.datetime(2020, 2, 1)
expected_length = len([a for a in accounts if a.created_at > created_at])
Expand All @@ -202,7 +201,7 @@ def test_query_all_created_after(

@patch(PLATFORM_ID_FILTER_REQUIRED, MagicMock(return_value=True))
def test_query_platform_id_filter_required(
client: Client, accounts: List[Account]
client: Client, accounts: list[Account]
) -> None:
accounts = list(
reversed(
Expand All @@ -226,7 +225,7 @@ def test_query_platform_id_filter_required(

@patch(USER_ID_FILTER_REQUIRED, MagicMock(return_value=True))
def test_query_user_id_filter_required(
client: Client, accounts: List[Account]
client: Client, accounts: list[Account]
) -> None:
accounts = list(
reversed([a for a in accounts if a.user_id == TEST_DEFAULT_USER_ID])
Expand Down
22 changes: 11 additions & 11 deletions tests/chalice_tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import datetime as dt
import functools
from typing import Callable, Generator, List
from typing import Callable, Generator

import pytest
from chalice.test import Client
Expand All @@ -22,7 +22,7 @@
def collection_fixture(model: Document) -> Callable[..., FuncDecorator]:
def collection_decorator(func: Callable) -> FuncDecorator:
@functools.wraps(func)
def wrapper(*args, **kwargs) -> Generator[List, None, None]:
def wrapper(*args, **kwargs) -> Generator[list, None, None]:
items = func(*args, **kwargs)
for item in items:
item.save()
Expand Down Expand Up @@ -54,7 +54,7 @@ def client() -> Generator[Client, None, None]:

@pytest.fixture
@collection_fixture(Account)
def accounts() -> List[Account]:
def accounts() -> list[Account]:
return [
Account(
name='Frida Kahlo',
Expand Down Expand Up @@ -96,18 +96,18 @@ def accounts() -> List[Account]:


@pytest.fixture
def account(accounts: List[Account]) -> Generator[Account, None, None]:
def account(accounts: list[Account]) -> Generator[Account, None, None]:
yield accounts[0]


@pytest.fixture
def other_account(accounts: List[Account]) -> Generator[Account, None, None]:
def other_account(accounts: list[Account]) -> Generator[Account, None, None]:
yield accounts[-1]


@pytest.fixture
@collection_fixture(File)
def files() -> List[File]:
def files() -> list[File]:
return [
File(
name='Frida Kahlo',
Expand All @@ -117,13 +117,13 @@ def files() -> List[File]:


@pytest.fixture
def file(files: List[File]) -> Generator[File, None, None]:
def file(files: list[File]) -> Generator[File, None, None]:
yield files[0]


@pytest.fixture
@collection_fixture(Card)
def cards() -> List[Card]:
def cards() -> list[Card]:
return [
Card(
number='5434000000000001',
Expand All @@ -149,13 +149,13 @@ def cards() -> List[Card]:


@pytest.fixture
def card(cards: List[Card]) -> Generator[Card, None, None]:
def card(cards: list[Card]) -> Generator[Card, None, None]:
yield cards[0]


@pytest.fixture
@collection_fixture(User)
def users() -> List[User]:
def users() -> list[User]:
return [
User(name='User1', platform_id=TEST_DEFAULT_PLATFORM_ID),
User(name='User2', platform_id=TEST_SECOND_PLATFORM_ID),
Expand All @@ -164,7 +164,7 @@ def users() -> List[User]:

@pytest.fixture
@collection_fixture(Biller)
def billers() -> List[Biller]:
def billers() -> list[Biller]:
return [
Biller(name='Telcel'),
Biller(name='ATT'),
Expand Down
9 changes: 4 additions & 5 deletions tests/fast_tests/blueprint/test_blueprint.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import datetime as dt
from tempfile import TemporaryFile
from typing import List
from unittest.mock import MagicMock, patch
from urllib.parse import urlencode

Expand Down Expand Up @@ -139,7 +138,7 @@ def test_query_all_with_limit(client: TestClient) -> None:


def test_query_all_resource(
client: TestClient, accounts: List[Account]
client: TestClient, accounts: list[Account]
) -> None:
accounts = list(reversed(accounts))

Expand All @@ -158,7 +157,7 @@ def test_query_all_resource(


def test_query_all_created_after(
client: TestClient, accounts: List[Account]
client: TestClient, accounts: list[Account]
) -> None:
created_at = dt.datetime(2020, 2, 1)
expected_length = len([a for a in accounts if a.created_at > created_at])
Expand All @@ -173,7 +172,7 @@ def test_query_all_created_after(

@patch(PLATFORM_ID_FILTER_REQUIRED, MagicMock(return_value=True))
def test_query_platform_id_filter_required(
client: TestClient, accounts: List[Account]
client: TestClient, accounts: list[Account]
) -> None:
accounts = list(
reversed(
Expand All @@ -197,7 +196,7 @@ def test_query_platform_id_filter_required(

@patch(USER_ID_FILTER_REQUIRED, MagicMock(return_value=True))
def test_query_user_id_filter_required(
client: TestClient, accounts: List[Account]
client: TestClient, accounts: list[Account]
) -> None:
accounts = list(
reversed([a for a in accounts if a.user_id == TEST_DEFAULT_USER_ID])
Expand Down
24 changes: 12 additions & 12 deletions tests/fast_tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import functools
import os
from functools import partial
from typing import Callable, Generator, List
from typing import Callable, Generator

import aiobotocore
import boto3
Expand All @@ -28,7 +28,7 @@
def collection_fixture(model: Document) -> Callable[..., FuncDecorator]:
def collection_decorator(func: Callable) -> FuncDecorator:
@functools.wraps(func)
def wrapper(*args, **kwargs) -> Generator[List, None, None]:
def wrapper(*args, **kwargs) -> Generator[list, None, None]:
items = func(*args, **kwargs)
for item in items:
item.save()
Expand All @@ -48,7 +48,7 @@ def client() -> Generator[TestClient, None, None]:

@pytest.fixture
@collection_fixture(Account)
def accounts() -> List[Account]:
def accounts() -> list[Account]:
return [
Account(
name='Frida Kahlo',
Expand Down Expand Up @@ -90,23 +90,23 @@ def accounts() -> List[Account]:


@pytest.fixture
def account(accounts: List[Account]) -> Generator[Account, None, None]:
def account(accounts: list[Account]) -> Generator[Account, None, None]:
yield accounts[0]


@pytest.fixture
def user(users: List[User]) -> Generator[User, None, None]:
def user(users: list[User]) -> Generator[User, None, None]:
yield users[0]


@pytest.fixture
def other_account(accounts: List[Account]) -> Generator[Account, None, None]:
def other_account(accounts: list[Account]) -> Generator[Account, None, None]:
yield accounts[-1]


@pytest.fixture
@collection_fixture(File)
def files() -> List[File]:
def files() -> list[File]:
return [
File(
name='Frida Kahlo',
Expand All @@ -116,13 +116,13 @@ def files() -> List[File]:


@pytest.fixture
def file(files: List[File]) -> Generator[File, None, None]:
def file(files: list[File]) -> Generator[File, None, None]:
yield files[0]


@pytest.fixture
@collection_fixture(Card)
def cards() -> List[Card]:
def cards() -> list[Card]:
return [
Card(
number='5434000000000001',
Expand All @@ -148,13 +148,13 @@ def cards() -> List[Card]:


@pytest.fixture
def card(cards: List[Card]) -> Generator[Card, None, None]:
def card(cards: list[Card]) -> Generator[Card, None, None]:
yield cards[0]


@pytest.fixture
@collection_fixture(User)
def users() -> List[User]:
def users() -> list[User]:
return [
User(name='User1', platform_id=TEST_DEFAULT_PLATFORM_ID),
User(name='User2', platform_id=TEST_SECOND_PLATFORM_ID),
Expand All @@ -163,7 +163,7 @@ def users() -> List[User]:

@pytest.fixture
@collection_fixture(Biller)
def billers() -> List[Biller]:
def billers() -> list[Biller]:
return [
Biller(name='Telcel'),
Biller(name='ATT'),
Expand Down

0 comments on commit e0174a6

Please sign in to comment.