aboutsummaryrefslogtreecommitdiff
path: root/generalresearch/models/thl
diff options
context:
space:
mode:
Diffstat (limited to 'generalresearch/models/thl')
-rw-r--r--generalresearch/models/thl/category.py5
-rw-r--r--generalresearch/models/thl/contest/__init__.py10
-rw-r--r--generalresearch/models/thl/contest/contest.py12
-rw-r--r--generalresearch/models/thl/contest/contest_entry.py10
-rw-r--r--generalresearch/models/thl/contest/leaderboard.py10
-rw-r--r--generalresearch/models/thl/contest/milestone.py6
-rw-r--r--generalresearch/models/thl/contest/raffle.py12
-rw-r--r--generalresearch/models/thl/demographics.py3
-rw-r--r--generalresearch/models/thl/finance.py4
-rw-r--r--generalresearch/models/thl/ipinfo.py11
-rw-r--r--generalresearch/models/thl/leaderboard.py7
-rw-r--r--generalresearch/models/thl/ledger.py19
-rw-r--r--generalresearch/models/thl/offerwall/base.py26
-rw-r--r--generalresearch/models/thl/offerwall/cache.py19
-rw-r--r--generalresearch/models/thl/payout.py25
-rw-r--r--generalresearch/models/thl/product.py16
-rw-r--r--generalresearch/models/thl/profiling/marketplace.py21
-rw-r--r--generalresearch/models/thl/profiling/question.py17
-rw-r--r--generalresearch/models/thl/profiling/upk_property.py7
-rw-r--r--generalresearch/models/thl/profiling/upk_question.py6
-rw-r--r--generalresearch/models/thl/profiling/upk_question_answer.py14
-rw-r--r--generalresearch/models/thl/profiling/user_info.py15
-rw-r--r--generalresearch/models/thl/profiling/user_question_answer.py13
-rw-r--r--generalresearch/models/thl/report_task.py5
-rw-r--r--generalresearch/models/thl/session.py23
-rw-r--r--generalresearch/models/thl/soft_pair.py12
-rw-r--r--generalresearch/models/thl/survey/__init__.py21
-rw-r--r--generalresearch/models/thl/survey/buyer.py14
-rw-r--r--generalresearch/models/thl/survey/model.py25
-rw-r--r--generalresearch/models/thl/survey/penalty.py13
-rw-r--r--generalresearch/models/thl/survey/task_collection.py4
-rw-r--r--generalresearch/models/thl/task_adjustment.py8
-rw-r--r--generalresearch/models/thl/task_status.py33
-rw-r--r--generalresearch/models/thl/user.py12
-rw-r--r--generalresearch/models/thl/user_iphistory.py17
-rw-r--r--generalresearch/models/thl/user_profile.py10
-rw-r--r--generalresearch/models/thl/user_quality_event.py10
-rw-r--r--generalresearch/models/thl/user_streak.py5
-rw-r--r--generalresearch/models/thl/wallet/cashout_method.py23
-rw-r--r--generalresearch/models/thl/wallet/payout.py12
-rw-r--r--generalresearch/models/thl/wallet/user_wallet.py7
41 files changed, 321 insertions, 221 deletions
diff --git a/generalresearch/models/thl/category.py b/generalresearch/models/thl/category.py
index ebfc840..32841a5 100644
--- a/generalresearch/models/thl/category.py
+++ b/generalresearch/models/thl/category.py
@@ -1,11 +1,12 @@
from __future__ import annotations
-from typing import Any, Self
+from typing import TYPE_CHECKING, Any, Self
from uuid import uuid4
from pydantic import BaseModel, Field, PositiveInt, model_validator
-from generalresearch.models.custom_types import UUIDStr
+if TYPE_CHECKING:
+ from generalresearch.models.custom_types import UUIDStr
class Category(BaseModel, frozen=True):
diff --git a/generalresearch/models/thl/contest/__init__.py b/generalresearch/models/thl/contest/__init__.py
index 65b28f4..f243ce4 100644
--- a/generalresearch/models/thl/contest/__init__.py
+++ b/generalresearch/models/thl/contest/__init__.py
@@ -1,7 +1,7 @@
from __future__ import annotations
from datetime import UTC, datetime
-from typing import Any, Self
+from typing import TYPE_CHECKING, Any, Self
from uuid import uuid4
from pydantic import (
@@ -12,10 +12,12 @@ from pydantic import (
model_validator,
)
-from generalresearch.currency import USDCent
-from generalresearch.models.custom_types import AwareDatetimeISO, UUIDStr
from generalresearch.models.thl.contest.definitions import ContestPrizeKind
-from generalresearch.models.thl.user import User
+
+if TYPE_CHECKING:
+ from generalresearch.currency import USDCent
+ from generalresearch.models.custom_types import AwareDatetimeISO, UUIDStr
+ from generalresearch.models.thl.user import User
class ContestEntryRule(BaseModel):
diff --git a/generalresearch/models/thl/contest/contest.py b/generalresearch/models/thl/contest/contest.py
index 6fc60f6..173d486 100644
--- a/generalresearch/models/thl/contest/contest.py
+++ b/generalresearch/models/thl/contest/contest.py
@@ -3,7 +3,7 @@ from __future__ import annotations
import json
from abc import ABC, abstractmethod
from datetime import UTC, datetime
-from typing import Any, Self
+from typing import TYPE_CHECKING, Any, Self
from uuid import uuid4
from pydantic import (
@@ -15,18 +15,22 @@ from pydantic import (
model_validator,
)
-from generalresearch.models.custom_types import AwareDatetimeISO, UUIDStr
from generalresearch.models.thl.contest import (
ContestEndCondition,
ContestPrize,
- ContestWinner,
)
from generalresearch.models.thl.contest.definitions import (
ContestEndReason,
ContestStatus,
ContestType,
)
-from generalresearch.models.thl.locales import CountryISOs
+
+if TYPE_CHECKING:
+ from generalresearch.models.custom_types import AwareDatetimeISO, UUIDStr
+ from generalresearch.models.thl.contest import (
+ ContestWinner,
+ )
+ from generalresearch.models.thl.locales import CountryISOs
class ContestBase(BaseModel, ABC):
diff --git a/generalresearch/models/thl/contest/contest_entry.py b/generalresearch/models/thl/contest/contest_entry.py
index b5f0ac3..a57b2df 100644
--- a/generalresearch/models/thl/contest/contest_entry.py
+++ b/generalresearch/models/thl/contest/contest_entry.py
@@ -1,7 +1,7 @@
from __future__ import annotations
from datetime import UTC, datetime
-from typing import Any
+from typing import TYPE_CHECKING, Any
from uuid import uuid4
from pydantic import (
@@ -12,9 +12,11 @@ from pydantic import (
)
from generalresearch.currency import USDCent
-from generalresearch.models.custom_types import AwareDatetimeISO, UUIDStr
-from generalresearch.models.thl.contest.definitions import ContestEntryType
-from generalresearch.models.thl.user import User
+
+if TYPE_CHECKING:
+ from generalresearch.models.custom_types import AwareDatetimeISO, UUIDStr
+ from generalresearch.models.thl.contest.definitions import ContestEntryType
+ from generalresearch.models.thl.user import User
class ContestEntryCreate(BaseModel):
diff --git a/generalresearch/models/thl/contest/leaderboard.py b/generalresearch/models/thl/contest/leaderboard.py
index 080f356..efbbd0a 100644
--- a/generalresearch/models/thl/contest/leaderboard.py
+++ b/generalresearch/models/thl/contest/leaderboard.py
@@ -1,7 +1,7 @@
from __future__ import annotations
from datetime import UTC, datetime, timedelta
-from typing import Any, Literal, Self
+from typing import TYPE_CHECKING, Any, Literal, Self
from pydantic import (
ConfigDict,
@@ -16,9 +16,6 @@ from generalresearch.currency import USDCent
from generalresearch.decorators import LOG
from generalresearch.managers.leaderboard import country_timezone
from generalresearch.managers.leaderboard.manager import LeaderboardManager
-from generalresearch.managers.thl.user_manager.user_manager import (
- UserManager,
-)
from generalresearch.models.thl.contest import (
ContestEndCondition,
ContestPrize,
@@ -42,6 +39,11 @@ from generalresearch.models.thl.leaderboard import (
LeaderboardFrequency,
)
+if TYPE_CHECKING:
+ from generalresearch.managers.thl.user_manager.user_manager import (
+ UserManager,
+ )
+
class LeaderboardContestCreate(ContestBase):
model_config = ConfigDict(
diff --git a/generalresearch/models/thl/contest/milestone.py b/generalresearch/models/thl/contest/milestone.py
index db5ba2f..e2ff2bc 100644
--- a/generalresearch/models/thl/contest/milestone.py
+++ b/generalresearch/models/thl/contest/milestone.py
@@ -2,7 +2,7 @@ from __future__ import annotations
import logging
from datetime import timedelta
-from typing import Any, Literal, Self
+from typing import TYPE_CHECKING, Any, Literal, Self
from pydantic import (
BaseModel,
@@ -13,7 +13,6 @@ from pydantic import (
)
from generalresearch.currency import USDCent
-from generalresearch.models.custom_types import AwareDatetimeISO
from generalresearch.models.thl.contest import (
ContestPrize,
)
@@ -32,6 +31,9 @@ from generalresearch.models.thl.contest.definitions import (
ContestType,
)
+if TYPE_CHECKING:
+ from generalresearch.models.custom_types import AwareDatetimeISO
+
logging.basicConfig()
LOG = logging.getLogger()
LOG.setLevel(logging.INFO)
diff --git a/generalresearch/models/thl/contest/raffle.py b/generalresearch/models/thl/contest/raffle.py
index 14b3fb6..b944740 100644
--- a/generalresearch/models/thl/contest/raffle.py
+++ b/generalresearch/models/thl/contest/raffle.py
@@ -4,7 +4,7 @@ import logging
import random
from collections import defaultdict
from datetime import UTC, datetime
-from typing import Any, Literal, Self
+from typing import TYPE_CHECKING, Any, Literal, Self
from pydantic import (
ConfigDict,
@@ -20,7 +20,6 @@ from generalresearch.models.thl.contest import (
ContestEndCondition,
ContestEntryRule,
ContestPrize,
- ContestWinner,
)
from generalresearch.models.thl.contest.contest import (
Contest,
@@ -28,7 +27,6 @@ from generalresearch.models.thl.contest.contest import (
ContestUserView,
)
from generalresearch.models.thl.contest.contest_entry import (
- ContestEntry,
ContestEntryType,
)
from generalresearch.models.thl.contest.definitions import (
@@ -38,6 +36,14 @@ from generalresearch.models.thl.contest.definitions import (
ContestType,
)
+if TYPE_CHECKING:
+ from generalresearch.models.thl.contest import (
+ ContestWinner,
+ )
+ from generalresearch.models.thl.contest.contest_entry import (
+ ContestEntry,
+ )
+
logging.basicConfig()
LOG = logging.getLogger()
LOG.setLevel(logging.INFO)
diff --git a/generalresearch/models/thl/demographics.py b/generalresearch/models/thl/demographics.py
index c11f8b2..ce4939c 100644
--- a/generalresearch/models/thl/demographics.py
+++ b/generalresearch/models/thl/demographics.py
@@ -8,9 +8,8 @@ from typing import TYPE_CHECKING, Any, Literal
import numpy as np
-from generalresearch.models.thl.locales import CountryISO
-
if TYPE_CHECKING:
+ from generalresearch.models.thl.locales import CountryISO
from generalresearch.models.thl.survey import MarketplaceTask
diff --git a/generalresearch/models/thl/finance.py b/generalresearch/models/thl/finance.py
index 79a74a7..4b750da 100644
--- a/generalresearch/models/thl/finance.py
+++ b/generalresearch/models/thl/finance.py
@@ -18,17 +18,17 @@ from pydantic import (
from pydantic.json_schema import SkipJsonSchema
from generalresearch.config import is_debug
-from generalresearch.currency import USDCent
from generalresearch.decorators import LOG
from generalresearch.models.custom_types import AwareDatetimeISO, UUIDStr
from generalresearch.models.thl.definitions import SessionAdjustedStatus
-from generalresearch.pg_helper import PostgresConfig
payout_example = random.randint(150, 750 * 100)
adjustment_example = random.randint(-1_000, 50 * 100)
if TYPE_CHECKING:
+ from generalresearch.currency import USDCent
from generalresearch.models.thl.ledger import LedgerAccount
+ from generalresearch.pg_helper import PostgresConfig
class AdjustmentType(BaseModel):
diff --git a/generalresearch/models/thl/ipinfo.py b/generalresearch/models/thl/ipinfo.py
index 8fbae4c..8322c7d 100644
--- a/generalresearch/models/thl/ipinfo.py
+++ b/generalresearch/models/thl/ipinfo.py
@@ -15,14 +15,13 @@ from pydantic import (
field_validator,
)
-from generalresearch.models.custom_types import (
- AwareDatetimeISO,
- CountryISOLike,
- IPvAnyAddressStr,
-)
-
if TYPE_CHECKING:
from generalresearch.managers.thl.ipinfo import IPGeonameManager
+ from generalresearch.models.custom_types import (
+ AwareDatetimeISO,
+ CountryISOLike,
+ IPvAnyAddressStr,
+ )
fake = Faker()
diff --git a/generalresearch/models/thl/leaderboard.py b/generalresearch/models/thl/leaderboard.py
index 4d116a5..3b33fe6 100644
--- a/generalresearch/models/thl/leaderboard.py
+++ b/generalresearch/models/thl/leaderboard.py
@@ -4,7 +4,7 @@ import logging
import math
from datetime import UTC, datetime, timedelta
from enum import StrEnum
-from typing import Literal
+from typing import TYPE_CHECKING, Literal
from uuid import UUID, uuid3
from zoneinfo import ZoneInfo
@@ -21,9 +21,12 @@ from pydantic import (
from generalresearch.models.custom_types import AwareDatetimeISO, UUIDStr
from generalresearch.models.legacy.api_status import StatusResponse
-from generalresearch.models.thl.locales import CountryISO
from generalresearch.utils.enum import ReprEnumMeta
+if TYPE_CHECKING:
+ from generalresearch.models.thl.locales import CountryISO
+
+
logger = logging.getLogger()
diff --git a/generalresearch/models/thl/ledger.py b/generalresearch/models/thl/ledger.py
index 518e390..c38e83b 100644
--- a/generalresearch/models/thl/ledger.py
+++ b/generalresearch/models/thl/ledger.py
@@ -2,7 +2,7 @@ from __future__ import annotations
from datetime import UTC, datetime
from enum import IntEnum, StrEnum
-from typing import Annotated, Any, Literal, Self
+from typing import TYPE_CHECKING, Annotated, Any, Literal, Self
from uuid import uuid4
from pydantic import (
@@ -16,12 +16,7 @@ from pydantic import (
model_validator,
)
-from generalresearch.models.custom_types import (
- AwareDatetimeISO,
- HttpsUrlStr,
- UUIDStr,
- check_valid_uuid,
-)
+from generalresearch.models.custom_types import check_valid_uuid
from generalresearch.models.thl.pagination import Page
from generalresearch.models.thl.payout_format import (
PayoutFormatType,
@@ -29,6 +24,16 @@ from generalresearch.models.thl.payout_format import (
)
from generalresearch.utils.enum import ReprEnumMeta
+if TYPE_CHECKING:
+ from generalresearch.models.custom_types import (
+ AwareDatetimeISO,
+ HttpsUrlStr,
+ UUIDStr,
+ )
+ from generalresearch.models.thl.payout_format import (
+ PayoutFormatType,
+ )
+
def _example_user_tx_payout(schema: dict[str, Any]) -> None:
diff --git a/generalresearch/models/thl/offerwall/base.py b/generalresearch/models/thl/offerwall/base.py
index 33b9847..1d41ef2 100644
--- a/generalresearch/models/thl/offerwall/base.py
+++ b/generalresearch/models/thl/offerwall/base.py
@@ -4,7 +4,7 @@ import statistics
from datetime import timedelta
from decimal import Decimal
from string import Formatter
-from typing import Annotated, Any, Self
+from typing import TYPE_CHECKING, Annotated, Any, Self
from uuid import uuid4
import numpy as np
@@ -20,31 +20,37 @@ from pydantic import (
)
from generalresearch.models import Source
-from generalresearch.models.custom_types import HttpsUrl, UUIDStr
from generalresearch.models.legacy.bucket import (
Bucket as LegacyBucket,
)
from generalresearch.models.legacy.bucket import (
- CategoryAssociation,
DurationSummary,
- Eligibility,
PayoutSummary,
PayoutSummaryDecimal,
- SurveyEligibilityCriterion,
)
from generalresearch.models.legacy.definitions import OfferwallReason
-from generalresearch.models.thl.locales import CountryISO
from generalresearch.models.thl.offerwall import (
OFFERWALL_TYPE_CLASS,
- OfferWallType,
- OfferWallTypeClass,
)
from generalresearch.models.thl.offerwall.bucket import (
generate_offerwall_entry_url,
)
-from generalresearch.models.thl.profiling.upk_question import UpkQuestion
from generalresearch.models.thl.soft_pair import SoftPairResultType
-from generalresearch.models.thl.user import User
+
+if TYPE_CHECKING:
+ from generalresearch.models.custom_types import HttpsUrl, UUIDStr
+ from generalresearch.models.legacy.bucket import (
+ CategoryAssociation,
+ Eligibility,
+ SurveyEligibilityCriterion,
+ )
+ from generalresearch.models.thl.locales import CountryISO
+ from generalresearch.models.thl.offerwall import (
+ OfferWallType,
+ OfferWallTypeClass,
+ )
+ from generalresearch.models.thl.profiling.upk_question import UpkQuestion
+ from generalresearch.models.thl.user import User
class MergeTableFeatures(BaseModel):
diff --git a/generalresearch/models/thl/offerwall/cache.py b/generalresearch/models/thl/offerwall/cache.py
index 97546b2..aa18014 100644
--- a/generalresearch/models/thl/offerwall/cache.py
+++ b/generalresearch/models/thl/offerwall/cache.py
@@ -1,18 +1,19 @@
from __future__ import annotations
from datetime import UTC, datetime
-from typing import Any
+from typing import TYPE_CHECKING, Any
from pydantic import BaseModel, Field
-from generalresearch.models import Source
-from generalresearch.models.custom_types import AwareDatetimeISO, UUIDStr
-from generalresearch.models.thl.offerwall import OfferWallRequest
-from generalresearch.models.thl.offerwall.base import (
- OfferwallBase,
- ScoredTaskResult,
- TaskResult,
-)
+if TYPE_CHECKING:
+ from generalresearch.models import Source
+ from generalresearch.models.custom_types import AwareDatetimeISO, UUIDStr
+ from generalresearch.models.thl.offerwall import OfferWallRequest
+ from generalresearch.models.thl.offerwall.base import (
+ OfferwallBase,
+ ScoredTaskResult,
+ TaskResult,
+ )
class GetOfferWallCache(BaseModel):
diff --git a/generalresearch/models/thl/payout.py b/generalresearch/models/thl/payout.py
index ce8a809..9902af3 100644
--- a/generalresearch/models/thl/payout.py
+++ b/generalresearch/models/thl/payout.py
@@ -2,7 +2,7 @@ from __future__ import annotations
import json
from datetime import UTC, datetime
-from typing import Self
+from typing import TYPE_CHECKING, Self
from uuid import uuid4
from pydantic import (
@@ -17,12 +17,18 @@ from pydantic import (
from pydantic.json_schema import SkipJsonSchema
from generalresearch.currency import USDCent
-from generalresearch.models.custom_types import AwareDatetimeISO, UUIDStr, UUIDStrCoerce
from generalresearch.models.thl.definitions import PayoutStatus
from generalresearch.models.thl.wallet import PayoutType
-from generalresearch.models.thl.wallet.cashout_method import (
- CashMailOrderData,
-)
+
+if TYPE_CHECKING:
+ from generalresearch.models.custom_types import (
+ AwareDatetimeISO,
+ UUIDStr,
+ UUIDStrCoerce,
+ )
+ from generalresearch.models.thl.wallet.cashout_method import (
+ CashMailOrderData,
+ )
class PayoutEvent(BaseModel):
@@ -59,9 +65,7 @@ class PayoutEvent(BaseModel):
examples=["a6dc1fc1bf934557b952f253dee12813"],
)
- created: AwareDatetimeISO = Field(
- default_factory=lambda: datetime.now(tz=UTC)
- )
+ created: AwareDatetimeISO = Field(default_factory=lambda: datetime.now(tz=UTC))
# In the smallest unit of the currency being transacted. For USD, this
# is cents.
@@ -233,9 +237,7 @@ class BusinessPayoutEventCreate(BaseModel):
examples=[uuid4().hex],
)
- created: AwareDatetimeISO = Field(
- default_factory=lambda: datetime.now(tz=UTC)
- )
+ created: AwareDatetimeISO = Field(default_factory=lambda: datetime.now(tz=UTC))
# In the smallest unit of the currency being transacted. For USD, this
# is cents.
@@ -351,5 +353,6 @@ class BusinessPayoutEventCreate(BaseModel):
)
return d
+
class BusinessPayoutEvent(BusinessPayoutEventCreate):
id: SkipJsonSchema[PositiveInt] = Field(exclude=True)
diff --git a/generalresearch/models/thl/product.py b/generalresearch/models/thl/product.py
index 83955a6..988b72d 100644
--- a/generalresearch/models/thl/product.py
+++ b/generalresearch/models/thl/product.py
@@ -45,7 +45,13 @@ from generalresearch.models.custom_types import (
HttpsUrlStr,
UUIDStr,
)
-from generalresearch.models.thl.ledger import LedgerAccount
+from generalresearch.models.thl.finance import (
+ POPFinancial,
+ ProductBalances,
+)
+from generalresearch.models.thl.payout import (
+ BrokerageProductPayoutEvent,
+)
from generalresearch.models.thl.payout_format import (
PayoutFormatType,
format_payout_format,
@@ -70,13 +76,7 @@ if TYPE_CHECKING:
from generalresearch.managers.thl.payout import (
BrokerageProductPayoutEventManager,
)
- from generalresearch.models.thl.finance import (
- POPFinancial,
- ProductBalances,
- )
- from generalresearch.models.thl.payout import (
- BrokerageProductPayoutEvent,
- )
+ from generalresearch.models.thl.ledger import LedgerAccount
# fmt: off
diff --git a/generalresearch/models/thl/profiling/marketplace.py b/generalresearch/models/thl/profiling/marketplace.py
index 0129e38..0c1e39b 100644
--- a/generalresearch/models/thl/profiling/marketplace.py
+++ b/generalresearch/models/thl/profiling/marketplace.py
@@ -3,18 +3,21 @@ from __future__ import annotations
from abc import ABC, abstractmethod
from datetime import UTC, datetime
from functools import cached_property
-from typing import Any
+from typing import TYPE_CHECKING, Any
from pydantic import BaseModel, ConfigDict, Field, PositiveInt, computed_field
-from generalresearch.models import MAX_INT32, Source
-from generalresearch.models.custom_types import (
- AwareDatetimeISO,
- CountryISOLike,
- LanguageISOLike,
- UUIDStr,
-)
-from generalresearch.models.thl.locales import CountryISO, LanguageISO
+from generalresearch.models import MAX_INT32
+
+if TYPE_CHECKING:
+ from generalresearch.models import Source
+ from generalresearch.models.custom_types import (
+ AwareDatetimeISO,
+ CountryISOLike,
+ LanguageISOLike,
+ UUIDStr,
+ )
+ from generalresearch.models.thl.locales import CountryISO, LanguageISO
class MarketplaceQuestion(BaseModel, ABC):
diff --git a/generalresearch/models/thl/profiling/question.py b/generalresearch/models/thl/profiling/question.py
index 3e2984a..920dd3a 100644
--- a/generalresearch/models/thl/profiling/question.py
+++ b/generalresearch/models/thl/profiling/question.py
@@ -1,6 +1,6 @@
from __future__ import annotations
-from typing import Any
+from typing import TYPE_CHECKING, Any
from pydantic import (
BaseModel,
@@ -9,13 +9,14 @@ from pydantic import (
computed_field,
)
-from generalresearch.models.custom_types import (
- AwareDatetimeISO,
- CountryISOLike,
- LanguageISOLike,
- UUIDStr,
-)
-from generalresearch.models.thl.profiling.upk_question import UpkQuestion
+if TYPE_CHECKING:
+ from generalresearch.models.custom_types import (
+ AwareDatetimeISO,
+ CountryISOLike,
+ LanguageISOLike,
+ UUIDStr,
+ )
+ from generalresearch.models.thl.profiling.upk_question import UpkQuestion
class Question(BaseModel):
diff --git a/generalresearch/models/thl/profiling/upk_property.py b/generalresearch/models/thl/profiling/upk_property.py
index e46e00a..922f5a4 100644
--- a/generalresearch/models/thl/profiling/upk_property.py
+++ b/generalresearch/models/thl/profiling/upk_property.py
@@ -2,14 +2,17 @@ from __future__ import annotations
from enum import StrEnum
from functools import cached_property
+from typing import TYPE_CHECKING
from uuid import uuid4
from pydantic import BaseModel, ConfigDict, Field, TypeAdapter
-from generalresearch.models.custom_types import CountryISOLike, UUIDStr
-from generalresearch.models.thl.category import Category
from generalresearch.utils.enum import ReprEnumMeta
+if TYPE_CHECKING:
+ from generalresearch.models.custom_types import CountryISOLike, UUIDStr
+ from generalresearch.models.thl.category import Category
+
class PropertyType(StrEnum, metaclass=ReprEnumMeta):
# UserProfileKnowledge Item
diff --git a/generalresearch/models/thl/profiling/upk_question.py b/generalresearch/models/thl/profiling/upk_question.py
index 3bb0733..a73683c 100644
--- a/generalresearch/models/thl/profiling/upk_question.py
+++ b/generalresearch/models/thl/profiling/upk_question.py
@@ -5,7 +5,7 @@ import json
import re
from enum import StrEnum
from functools import cached_property
-from typing import Annotated, Any, Literal
+from typing import TYPE_CHECKING, Annotated, Any, Literal
from pydantic import (
BaseModel,
@@ -18,9 +18,11 @@ from pydantic import (
)
from generalresearch.models import Source
-from generalresearch.models.custom_types import UUIDStr
from generalresearch.models.thl.category import Category
+if TYPE_CHECKING:
+ from generalresearch.models.custom_types import UUIDStr
+
class UPKImportance(BaseModel):
task_count: int | None = Field(
diff --git a/generalresearch/models/thl/profiling/upk_question_answer.py b/generalresearch/models/thl/profiling/upk_question_answer.py
index d8323ad..41895b1 100644
--- a/generalresearch/models/thl/profiling/upk_question_answer.py
+++ b/generalresearch/models/thl/profiling/upk_question_answer.py
@@ -1,7 +1,7 @@
from __future__ import annotations
from datetime import UTC, datetime
-from typing import Any, Self
+from typing import TYPE_CHECKING, Any, Self
from uuid import uuid4
from pydantic import (
@@ -14,16 +14,18 @@ from pydantic import (
)
from generalresearch.models import MAX_INT32
-from generalresearch.models.custom_types import (
- AwareDatetimeISO,
- CountryISOLike,
- UUIDStr,
-)
from generalresearch.models.thl.profiling.upk_property import (
Cardinality,
PropertyType,
)
+if TYPE_CHECKING:
+ from generalresearch.models.custom_types import (
+ AwareDatetimeISO,
+ CountryISOLike,
+ UUIDStr,
+ )
+
class UpkQuestionAnswer(BaseModel):
diff --git a/generalresearch/models/thl/profiling/user_info.py b/generalresearch/models/thl/profiling/user_info.py
index 32af704..c82e2d2 100644
--- a/generalresearch/models/thl/profiling/user_info.py
+++ b/generalresearch/models/thl/profiling/user_info.py
@@ -1,14 +1,17 @@
from __future__ import annotations
+from typing import TYPE_CHECKING
+
from pydantic import BaseModel, ConfigDict, Field
from pydantic.json_schema import SkipJsonSchema
-from generalresearch.models import Source
-from generalresearch.models.custom_types import AwareDatetimeISO
-from generalresearch.models.thl.profiling.user_question_answer import (
- MarketplaceResearchProfileQuestion,
-)
-from generalresearch.models.thl.user import User
+if TYPE_CHECKING:
+ from generalresearch.models import Source
+ from generalresearch.models.custom_types import AwareDatetimeISO
+ from generalresearch.models.thl.profiling.user_question_answer import (
+ MarketplaceResearchProfileQuestion,
+ )
+ from generalresearch.models.thl.user import User
class UserProfileKnowledgeAnswer(BaseModel):
diff --git a/generalresearch/models/thl/profiling/user_question_answer.py b/generalresearch/models/thl/profiling/user_question_answer.py
index 378345e..b1868b3 100644
--- a/generalresearch/models/thl/profiling/user_question_answer.py
+++ b/generalresearch/models/thl/profiling/user_question_answer.py
@@ -3,7 +3,7 @@ from __future__ import annotations
import json
from collections.abc import Iterator
from datetime import UTC, datetime, timedelta
-from typing import Any, Literal
+from typing import TYPE_CHECKING, Any, Literal
from pydantic import (
BaseModel,
@@ -14,10 +14,13 @@ from pydantic import (
model_validator,
)
-from generalresearch.models import MAX_INT32, Source
-from generalresearch.models.custom_types import AwareDatetimeISO, UUIDStr
-from generalresearch.models.thl.locales import CountryISO, LanguageISO
-from generalresearch.models.thl.profiling.upk_question import UpkQuestion
+from generalresearch.models import MAX_INT32
+
+if TYPE_CHECKING:
+ from generalresearch.models import Source
+ from generalresearch.models.custom_types import AwareDatetimeISO, UUIDStr
+ from generalresearch.models.thl.locales import CountryISO, LanguageISO
+ from generalresearch.models.thl.profiling.upk_question import UpkQuestion
class UserQuestionAnswer(BaseModel):
diff --git a/generalresearch/models/thl/report_task.py b/generalresearch/models/thl/report_task.py
index 299ba90..e4a8f48 100644
--- a/generalresearch/models/thl/report_task.py
+++ b/generalresearch/models/thl/report_task.py
@@ -3,11 +3,14 @@ from __future__ import annotations
import random
from collections import defaultdict
from collections.abc import Collection
+from typing import TYPE_CHECKING
from pydantic import BaseModel, ConfigDict, Field
from generalresearch.models.thl.definitions import ReportValue
-from generalresearch.models.thl.user import BPUIDStr
+
+if TYPE_CHECKING:
+ from generalresearch.models.thl.user import BPUIDStr
# If a report is made with multiple values, we'll take the one with the
# highest priority
diff --git a/generalresearch/models/thl/session.py b/generalresearch/models/thl/session.py
index 31dc668..871e5c4 100644
--- a/generalresearch/models/thl/session.py
+++ b/generalresearch/models/thl/session.py
@@ -18,14 +18,7 @@ from pydantic import (
model_validator,
)
-from generalresearch.models import DeviceType, Source
-from generalresearch.models.custom_types import (
- AwareDatetimeISO,
- EnumNameSerializer,
- IPvAnyAddressStr,
- UUIDStr,
-)
-from generalresearch.models.legacy.bucket import Bucket
+from generalresearch.models import Source
from generalresearch.models.thl import (
decimal_to_int_cents,
int_cents_to_decimal,
@@ -33,9 +26,7 @@ from generalresearch.models.thl import (
from generalresearch.models.thl.definitions import (
WALL_ALLOWED_STATUS_CODE_1_2,
WALL_ALLOWED_STATUS_STATUS_CODE,
- ReportValue,
SessionAdjustedStatus,
- SessionStatusCode2,
Status,
StatusCode1,
WallAdjustedStatus,
@@ -46,6 +37,18 @@ if TYPE_CHECKING:
from generalresearch.managers.thl.ledger_manager.thl_ledger import (
ThlLedgerManager,
)
+ from generalresearch.models import DeviceType
+ from generalresearch.models.custom_types import (
+ AwareDatetimeISO,
+ EnumNameSerializer,
+ IPvAnyAddressStr,
+ UUIDStr,
+ )
+ from generalresearch.models.legacy.bucket import Bucket
+ from generalresearch.models.thl.definitions import (
+ ReportValue,
+ SessionStatusCode2,
+ )
from generalresearch.models.thl.product import Product
from generalresearch.models.thl.user import User
diff --git a/generalresearch/models/thl/soft_pair.py b/generalresearch/models/thl/soft_pair.py
index 7c2f36e..313d374 100644
--- a/generalresearch/models/thl/soft_pair.py
+++ b/generalresearch/models/thl/soft_pair.py
@@ -2,12 +2,14 @@ from __future__ import annotations
from dataclasses import dataclass
from enum import Enum
+from typing import TYPE_CHECKING
-from generalresearch.models import Source
-from generalresearch.models.dynata.survey import DynataCondition
-from generalresearch.models.thl.survey.condition import (
- MarketplaceCondition,
-)
+if TYPE_CHECKING:
+ from generalresearch.models import Source
+ from generalresearch.models.dynata.survey import DynataCondition
+ from generalresearch.models.thl.survey.condition import (
+ MarketplaceCondition,
+ )
class SoftPairResultType(int, Enum):
diff --git a/generalresearch/models/thl/survey/__init__.py b/generalresearch/models/thl/survey/__init__.py
index 6e6b475..d0f2b33 100644
--- a/generalresearch/models/thl/survey/__init__.py
+++ b/generalresearch/models/thl/survey/__init__.py
@@ -3,27 +3,32 @@ from __future__ import annotations
from abc import ABC, abstractmethod
from decimal import Decimal
from itertools import product
+from typing import TYPE_CHECKING
from more_itertools import flatten
from pydantic import BaseModel, Field
-from generalresearch.models import Source
from generalresearch.models.thl.demographics import (
AgeGroup,
DemographicTarget,
Gender,
)
-from generalresearch.models.thl.locales import (
- CountryISO,
- CountryISOs,
- LanguageISO,
- LanguageISOs,
-)
from generalresearch.models.thl.survey.condition import (
ConditionValueType,
- MarketplaceCondition,
)
+if TYPE_CHECKING:
+ from generalresearch.models import Source
+ from generalresearch.models.thl.locales import (
+ CountryISO,
+ CountryISOs,
+ LanguageISO,
+ LanguageISOs,
+ )
+ from generalresearch.models.thl.survey.condition import (
+ MarketplaceCondition,
+ )
+
class MarketplaceTask(BaseModel, ABC):
"""This is called a "Task" even though generally it represents a survey
diff --git a/generalresearch/models/thl/survey/buyer.py b/generalresearch/models/thl/survey/buyer.py
index b888007..26846d3 100644
--- a/generalresearch/models/thl/survey/buyer.py
+++ b/generalresearch/models/thl/survey/buyer.py
@@ -3,7 +3,7 @@ from __future__ import annotations
from datetime import UTC, datetime
from decimal import Decimal
from math import log
-from typing import Annotated
+from typing import TYPE_CHECKING, Annotated
from pydantic import (
BaseModel,
@@ -17,11 +17,13 @@ from pydantic import (
from scipy.stats import beta as beta_dist
from generalresearch.models import Source
-from generalresearch.models.custom_types import (
- AwareDatetimeISO,
- CountryISOLike,
- UUIDStr,
-)
+
+if TYPE_CHECKING:
+ from generalresearch.models.custom_types import (
+ AwareDatetimeISO,
+ CountryISOLike,
+ UUIDStr,
+ )
class Buyer(BaseModel):
diff --git a/generalresearch/models/thl/survey/model.py b/generalresearch/models/thl/survey/model.py
index 2eed8f7..9fa3d8e 100644
--- a/generalresearch/models/thl/survey/model.py
+++ b/generalresearch/models/thl/survey/model.py
@@ -2,7 +2,7 @@ from __future__ import annotations
from datetime import UTC, datetime
from decimal import Decimal
-from typing import Annotated, Any
+from typing import TYPE_CHECKING, Annotated, Any
from pydantic import (
BaseModel,
@@ -17,18 +17,21 @@ from pydantic import (
)
from generalresearch.managers.thl.buyer import Buyer
-from generalresearch.models import Source
-from generalresearch.models.custom_types import (
- AwareDatetimeISO,
- CountryISOLike,
- EnumNameSerializer,
- PropertyCode,
- SurveyKey,
-)
-from generalresearch.models.thl.category import Category
-from generalresearch.models.thl.definitions import Status, StatusCode1
+from generalresearch.models.thl.definitions import StatusCode1
from generalresearch.models.thl.pagination import Page
+if TYPE_CHECKING:
+ from generalresearch.models import Source
+ from generalresearch.models.custom_types import (
+ AwareDatetimeISO,
+ CountryISOLike,
+ EnumNameSerializer,
+ PropertyCode,
+ SurveyKey,
+ )
+ from generalresearch.models.thl.category import Category
+ from generalresearch.models.thl.definitions import Status
+
class SurveyCategoryModel(BaseModel):
model_config = ConfigDict(from_attributes=True)
diff --git a/generalresearch/models/thl/survey/penalty.py b/generalresearch/models/thl/survey/penalty.py
index 755d25c..54edb94 100644
--- a/generalresearch/models/thl/survey/penalty.py
+++ b/generalresearch/models/thl/survey/penalty.py
@@ -2,15 +2,16 @@ from __future__ import annotations
import abc
from datetime import UTC, datetime
-from typing import Annotated, Literal
+from typing import TYPE_CHECKING, Annotated, Literal
from pydantic import BaseModel, ConfigDict, Field, TypeAdapter
-from generalresearch.models import Source
-from generalresearch.models.custom_types import (
- AwareDatetimeISO,
- UUIDStr,
-)
+if TYPE_CHECKING:
+ from generalresearch.models import Source
+ from generalresearch.models.custom_types import (
+ AwareDatetimeISO,
+ UUIDStr,
+ )
class SurveyPenalty(BaseModel, abc.ABC):
diff --git a/generalresearch/models/thl/survey/task_collection.py b/generalresearch/models/thl/survey/task_collection.py
index d8db0d1..c9614d5 100644
--- a/generalresearch/models/thl/survey/task_collection.py
+++ b/generalresearch/models/thl/survey/task_collection.py
@@ -3,12 +3,14 @@ from __future__ import annotations
import copy
import json
import logging
+from typing import TYPE_CHECKING
import pandas as pd
import pandera.pandas as pa
from pydantic import BaseModel, ConfigDict, Field, model_validator
-from generalresearch.models.thl.survey import MarketplaceTask
+if TYPE_CHECKING:
+ from generalresearch.models.thl.survey import MarketplaceTask
logging.basicConfig()
logger = logging.getLogger()
diff --git a/generalresearch/models/thl/task_adjustment.py b/generalresearch/models/thl/task_adjustment.py
index 27c47d4..fa5592e 100644
--- a/generalresearch/models/thl/task_adjustment.py
+++ b/generalresearch/models/thl/task_adjustment.py
@@ -2,16 +2,20 @@ from __future__ import annotations
from datetime import UTC, datetime
from decimal import Decimal
+from typing import TYPE_CHECKING
from uuid import uuid4
from pydantic import BaseModel, ConfigDict, Field, PositiveInt, model_validator
-from generalresearch.models import MAX_INT32, Source
-from generalresearch.models.custom_types import AwareDatetimeISO, UUIDStr
+from generalresearch.models import MAX_INT32
from generalresearch.models.thl.definitions import (
WallAdjustedStatus,
)
+if TYPE_CHECKING:
+ from generalresearch.models import Source
+ from generalresearch.models.custom_types import AwareDatetimeISO, UUIDStr
+
class TaskAdjustmentEvent(BaseModel):
"""
diff --git a/generalresearch/models/thl/task_status.py b/generalresearch/models/thl/task_status.py
index 7719b18..817f4c5 100644
--- a/generalresearch/models/thl/task_status.py
+++ b/generalresearch/models/thl/task_status.py
@@ -1,7 +1,7 @@
from __future__ import annotations
from datetime import datetime
-from typing import Annotated, Any, Literal
+from typing import TYPE_CHECKING, Annotated, Any, Literal
from pydantic import (
BaseModel,
@@ -13,11 +13,6 @@ from pydantic import (
model_validator,
)
-from generalresearch.models.custom_types import (
- AwareDatetimeISO,
- EnumNameSerializer,
- UUIDStr,
-)
from generalresearch.models.thl import decimal_to_int_cents
from generalresearch.models.thl.definitions import (
SessionAdjustedStatus,
@@ -28,13 +23,23 @@ from generalresearch.models.thl.definitions import (
from generalresearch.models.thl.pagination import Page
from generalresearch.models.thl.payout_format import (
PayoutFormatOptionalField,
- PayoutFormatType,
-)
-from generalresearch.models.thl.product import (
- PayoutTransformation,
- Product,
)
-from generalresearch.models.thl.session import Session, WallOut
+from generalresearch.models.thl.session import WallOut
+
+if TYPE_CHECKING:
+ from generalresearch.models.custom_types import (
+ AwareDatetimeISO,
+ EnumNameSerializer,
+ UUIDStr,
+ )
+ from generalresearch.models.thl.payout_format import (
+ PayoutFormatType,
+ )
+ from generalresearch.models.thl.product import (
+ PayoutTransformation,
+ Product,
+ )
+ from generalresearch.models.thl.session import Session
# API uses the ints, b/c this is what the grpc returned originally ...
STATUS_MAP = {
@@ -171,12 +176,12 @@ class TaskStatusResponse(BaseModel):
# Serialize enum → int
@field_serializer("status", return_type=int)
- def serialize_status(self, v: Status | None, _info):
+ def serialize_status(self, v: Status | None):
return STATUS_MAP[v]
# Accept int OR string for input, but internally store a Status enum
@field_validator("status", mode="before")
- def deserialize_status(cls, v):
+ def deserialize_status(cls, v: Status | None):
# int → enum
if isinstance(v, int):
return REVERSE_STATUS_MAP[v]
diff --git a/generalresearch/models/thl/user.py b/generalresearch/models/thl/user.py
index d3ffb0d..302aa72 100644
--- a/generalresearch/models/thl/user.py
+++ b/generalresearch/models/thl/user.py
@@ -21,18 +21,18 @@ from pydantic import (
from sentry_sdk import set_tag, set_user
from generalresearch.models import MAX_INT32
-from generalresearch.models.custom_types import AwareDatetimeISO, UUIDStr
-from generalresearch.models.thl.ipinfo import GeoIPInformation
-from generalresearch.models.thl.ledger import LedgerTransaction
-from generalresearch.models.thl.product import Product
-from generalresearch.models.thl.userhealth import AuditLog
-from generalresearch.pg_helper import PostgresConfig
if TYPE_CHECKING:
from generalresearch.managers.thl.ledger_manager.thl_ledger import (
ThlLedgerManager,
)
from generalresearch.managers.thl.userhealth import AuditLogManager
+ from generalresearch.models.custom_types import AwareDatetimeISO, UUIDStr
+ from generalresearch.models.thl.ipinfo import GeoIPInformation
+ from generalresearch.models.thl.ledger import LedgerTransaction
+ from generalresearch.models.thl.product import Product
+ from generalresearch.models.thl.userhealth import AuditLog
+ from generalresearch.pg_helper import PostgresConfig
# from generalresearch.managers.thl.userhealth import UserIpHistoryManager
diff --git a/generalresearch/models/thl/user_iphistory.py b/generalresearch/models/thl/user_iphistory.py
index 812c18f..0d25322 100644
--- a/generalresearch/models/thl/user_iphistory.py
+++ b/generalresearch/models/thl/user_iphistory.py
@@ -5,7 +5,6 @@ from datetime import UTC, datetime, timedelta
from typing import TYPE_CHECKING, Self
from faker import Faker
-from grip_client.enums import AccessType
from pydantic import (
BaseModel,
ConfigDict,
@@ -14,18 +13,20 @@ from pydantic import (
field_validator,
)
-from generalresearch.models.custom_types import (
- AwareDatetimeISO,
- CountryISOLike,
- IPvAnyAddressStr,
-)
from generalresearch.models.thl.ipinfo import normalize_ip
-from generalresearch.pg_helper import PostgresConfig
-from generalresearch.redis_helper import RedisConfig
if TYPE_CHECKING:
+ from grip_client.enums import AccessType
+
+ from generalresearch.models.custom_types import (
+ AwareDatetimeISO,
+ CountryISOLike,
+ IPvAnyAddressStr,
+ )
from generalresearch.models.thl.ipinfo import GeoIPInformation
from generalresearch.models.thl.user import User
+ from generalresearch.pg_helper import PostgresConfig
+ from generalresearch.redis_helper import RedisConfig
fake = Faker()
diff --git a/generalresearch/models/thl/user_profile.py b/generalresearch/models/thl/user_profile.py
index 0ec605a..2dc19b7 100644
--- a/generalresearch/models/thl/user_profile.py
+++ b/generalresearch/models/thl/user_profile.py
@@ -1,7 +1,7 @@
from __future__ import annotations
import hashlib
-from typing import Annotated, Any, Self
+from typing import TYPE_CHECKING, Annotated, Any, Self
from pydantic import (
BaseModel,
@@ -14,9 +14,11 @@ from pydantic import (
from pydantic.json_schema import SkipJsonSchema
from generalresearch.models import MAX_INT32, Source
-from generalresearch.models.custom_types import UUIDStr
-from generalresearch.models.thl.user import User
-from generalresearch.models.thl.user_streak import UserStreak
+
+if TYPE_CHECKING:
+ from generalresearch.models.custom_types import UUIDStr
+ from generalresearch.models.thl.user import User
+ from generalresearch.models.thl.user_streak import UserStreak
class UserMetadata(BaseModel):
diff --git a/generalresearch/models/thl/user_quality_event.py b/generalresearch/models/thl/user_quality_event.py
index cfb4ff3..5438740 100644
--- a/generalresearch/models/thl/user_quality_event.py
+++ b/generalresearch/models/thl/user_quality_event.py
@@ -3,16 +3,18 @@ from __future__ import annotations
from datetime import UTC, datetime
from decimal import Decimal
from enum import StrEnum
-from typing import Literal
+from typing import TYPE_CHECKING, Literal
from pydantic import BaseModel, Field, PositiveInt
from generalresearch.models import MAX_INT32, Source
-from generalresearch.models.custom_types import AwareDatetimeISO, UUIDStr
-from generalresearch.models.thl.definitions import WallAdjustedStatus
-from generalresearch.models.thl.user import BPUIDStr
from generalresearch.utils.enum import ReprEnumMeta
+if TYPE_CHECKING:
+ from generalresearch.models.custom_types import AwareDatetimeISO, UUIDStr
+ from generalresearch.models.thl.definitions import WallAdjustedStatus
+ from generalresearch.models.thl.user import BPUIDStr
+
"""
Typically used internally. These affect a user's quality standing.
"""
diff --git a/generalresearch/models/thl/user_streak.py b/generalresearch/models/thl/user_streak.py
index cc4d643..6cd853a 100644
--- a/generalresearch/models/thl/user_streak.py
+++ b/generalresearch/models/thl/user_streak.py
@@ -2,6 +2,7 @@ from __future__ import annotations
from datetime import date, datetime, timedelta
from enum import StrEnum
+from typing import TYPE_CHECKING
from zoneinfo import ZoneInfo
import pandas as pd
@@ -19,7 +20,9 @@ from pydantic.json_schema import SkipJsonSchema
from generalresearch.managers.leaderboard import country_timezone
from generalresearch.models import MAX_INT32
-from generalresearch.models.thl.locales import CountryISO
+
+if TYPE_CHECKING:
+ from generalresearch.models.thl.locales import CountryISO
class StreakPeriod(StrEnum):
diff --git a/generalresearch/models/thl/wallet/cashout_method.py b/generalresearch/models/thl/wallet/cashout_method.py
index 6158afd..1db85e8 100644
--- a/generalresearch/models/thl/wallet/cashout_method.py
+++ b/generalresearch/models/thl/wallet/cashout_method.py
@@ -4,7 +4,7 @@ import hashlib
import logging
from datetime import UTC, datetime
from enum import StrEnum
-from typing import Any, Literal, Self
+from typing import TYPE_CHECKING, Any, Literal, Self
from pydantic import (
BaseModel,
@@ -17,19 +17,22 @@ from pydantic import (
model_validator,
)
-from generalresearch.currency import USDCent
-from generalresearch.models.custom_types import (
- AwareDatetimeISO,
- HttpsUrlStr,
- UUIDStr,
-)
from generalresearch.models.legacy.api_status import StatusResponse
from generalresearch.models.thl.definitions import PayoutStatus
-from generalresearch.models.thl.locales import CountryISO
-from generalresearch.models.thl.user import BPUIDStr, User
-from generalresearch.models.thl.wallet import Currency, PayoutType
+from generalresearch.models.thl.wallet import PayoutType
from generalresearch.utils.enum import ReprEnumMeta
+if TYPE_CHECKING:
+ from generalresearch.currency import USDCent
+ from generalresearch.models.custom_types import (
+ AwareDatetimeISO,
+ HttpsUrlStr,
+ UUIDStr,
+ )
+ from generalresearch.models.thl.locales import CountryISO
+ from generalresearch.models.thl.user import BPUIDStr, User
+ from generalresearch.models.thl.wallet import Currency
+
logger = logging.getLogger()
example_cashout_method = {
diff --git a/generalresearch/models/thl/wallet/payout.py b/generalresearch/models/thl/wallet/payout.py
index d43807d..7301b31 100644
--- a/generalresearch/models/thl/wallet/payout.py
+++ b/generalresearch/models/thl/wallet/payout.py
@@ -3,7 +3,7 @@ from __future__ import annotations
import json
from collections.abc import Collection
from datetime import UTC, datetime
-from typing import Any
+from typing import TYPE_CHECKING, Any
from uuid import uuid4
from pydantic import (
@@ -15,12 +15,14 @@ from pydantic import (
)
from generalresearch.currency import USDCent
-from generalresearch.models.custom_types import AwareDatetimeISO, UUIDStr
from generalresearch.models.thl.definitions import PayoutStatus
from generalresearch.models.thl.wallet import PayoutType
-from generalresearch.models.thl.wallet.cashout_method import (
- CashMailOrderData,
-)
+
+if TYPE_CHECKING:
+ from generalresearch.models.custom_types import AwareDatetimeISO, UUIDStr
+ from generalresearch.models.thl.wallet.cashout_method import (
+ CashMailOrderData,
+ )
class PayoutEvent(BaseModel, validate_assignment=True):
diff --git a/generalresearch/models/thl/wallet/user_wallet.py b/generalresearch/models/thl/wallet/user_wallet.py
index dbe66fa..625fd52 100644
--- a/generalresearch/models/thl/wallet/user_wallet.py
+++ b/generalresearch/models/thl/wallet/user_wallet.py
@@ -1,15 +1,20 @@
from __future__ import annotations
import logging
+from typing import TYPE_CHECKING
from pydantic import BaseModel, ConfigDict, Field, NonNegativeInt
from generalresearch.models.legacy.api_status import StatusResponse
from generalresearch.models.thl.payout_format import (
PayoutFormatField,
- PayoutFormatType,
)
+if TYPE_CHECKING:
+ from generalresearch.models.thl.payout_format import (
+ PayoutFormatType,
+ )
+
logger = logging.getLogger()
example_wallet_balance = {