diff options
| author | stuppie | 2026-09-06 18:41:23 -0600 |
|---|---|---|
| committer | stuppie | 2026-09-06 18:41:23 -0600 |
| commit | 5d20e51ba4149b9ba04f6a70de4f6c8ff0425fc3 (patch) | |
| tree | 665e392bfab32336509ecb9bd95dce42d7ebbead | |
| parent | 7690eb3cc1f575e6bc16e8f7022d613601ebb14d (diff) | |
| download | generalresearch-5d20e51ba4149b9ba04f6a70de4f6c8ff0425fc3.tar.gz generalresearch-5d20e51ba4149b9ba04f6a70de4f6c8ff0425fc3.zip | |
Fix 35 more model rebuild errors. I think that is all of them now
| -rw-r--r-- | generalresearch/models/thl/leaderboard.py | 13 | ||||
| -rw-r--r-- | generalresearch/models/thl/offerwall/base.py | 24 | ||||
| -rw-r--r-- | generalresearch/models/thl/offerwall/cache.py | 18 | ||||
| -rw-r--r-- | generalresearch/models/thl/profiling/marketplace.py | 10 | ||||
| -rw-r--r-- | generalresearch/models/thl/profiling/question.py | 6 | ||||
| -rw-r--r-- | generalresearch/models/thl/profiling/user_question_answer.py | 34 | ||||
| -rw-r--r-- | generalresearch/models/thl/report_task.py | 3 | ||||
| -rw-r--r-- | generalresearch/models/thl/survey/model.py | 24 | ||||
| -rw-r--r-- | generalresearch/models/thl/survey/penalty.py | 7 | ||||
| -rw-r--r-- | generalresearch/models/thl/survey/task_collection.py | 4 | ||||
| -rw-r--r-- | generalresearch/models/thl/task_adjustment.py | 6 | ||||
| -rw-r--r-- | generalresearch/models/thl/task_status.py | 14 | ||||
| -rw-r--r-- | generalresearch/models/thl/user_profile.py | 9 | ||||
| -rw-r--r-- | generalresearch/models/thl/user_quality_event.py | 8 |
14 files changed, 68 insertions, 112 deletions
diff --git a/generalresearch/models/thl/leaderboard.py b/generalresearch/models/thl/leaderboard.py index 3b33fe6..8c7f1bd 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 TYPE_CHECKING, Literal +from typing import Literal from uuid import UUID, uuid3 from zoneinfo import ZoneInfo @@ -21,12 +21,9 @@ 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() @@ -269,9 +266,9 @@ class Leaderboard(BaseModel): .to_pydatetime() .replace(tzinfo=self.timezone) ) - assert ( - period_start_local == self.period_start_local - ), f"invalid period_start_local {self.period_start_local}. The period starts at {period_start_local}" + assert period_start_local == self.period_start_local, ( + f"invalid period_start_local {self.period_start_local}. The period starts at {period_start_local}" + ) if self.period_end_local is not None: assert self.period_end_local == period_end_local, "invalid period" else: diff --git a/generalresearch/models/thl/offerwall/base.py b/generalresearch/models/thl/offerwall/base.py index c99df16..ead48c3 100644 --- a/generalresearch/models/thl/offerwall/base.py +++ b/generalresearch/models/thl/offerwall/base.py @@ -25,31 +25,27 @@ 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 if TYPE_CHECKING: - 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 @@ -277,9 +273,9 @@ class TaskResult(BaseModel): if fname ] ) - assert all( - x in {"domain", "mid"} for x in fmt_str - ), "unrecognized format variable" + assert all(x in {"domain", "mid"} for x in fmt_str), ( + "unrecognized format variable" + ) else: assert self.entry_link is None, f"entry link not allowed for {self.source}" return self diff --git a/generalresearch/models/thl/offerwall/cache.py b/generalresearch/models/thl/offerwall/cache.py index 9b2f462..abb213e 100644 --- a/generalresearch/models/thl/offerwall/cache.py +++ b/generalresearch/models/thl/offerwall/cache.py @@ -1,20 +1,18 @@ from __future__ import annotations from datetime import UTC, datetime -from typing import TYPE_CHECKING, Any +from typing import Any from pydantic import BaseModel, Field from generalresearch.models.custom_types import AwareDatetimeISO, UUIDStr - -if TYPE_CHECKING: - from generalresearch.models.definitions import Source - from generalresearch.models.thl.offerwall import OfferWallRequest - from generalresearch.models.thl.offerwall.base import ( - OfferwallBase, - ScoredTaskResult, - TaskResult, - ) +from generalresearch.models.definitions import Source +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/profiling/marketplace.py b/generalresearch/models/thl/profiling/marketplace.py index 19d45d6..38ce47e 100644 --- a/generalresearch/models/thl/profiling/marketplace.py +++ b/generalresearch/models/thl/profiling/marketplace.py @@ -3,7 +3,7 @@ from __future__ import annotations from abc import ABC, abstractmethod from datetime import UTC, datetime from functools import cached_property -from typing import TYPE_CHECKING, Any +from typing import Any from pydantic import BaseModel, ConfigDict, Field, PositiveInt, computed_field @@ -13,12 +13,8 @@ from generalresearch.models.custom_types import ( LanguageISOLike, UUIDStr, ) -from generalresearch.models.definitions import MAX_INT32 - -if TYPE_CHECKING: - - from generalresearch.models.definitions import Source - from generalresearch.models.thl.locales import CountryISO, LanguageISO +from generalresearch.models.definitions import MAX_INT32, Source +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 ea6a3c9..3e2984a 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 TYPE_CHECKING, Any +from typing import Any from pydantic import ( BaseModel, @@ -15,9 +15,7 @@ from generalresearch.models.custom_types import ( LanguageISOLike, UUIDStr, ) - -if TYPE_CHECKING: - from generalresearch.models.thl.profiling.upk_question import UpkQuestion +from generalresearch.models.thl.profiling.upk_question import UpkQuestion class Question(BaseModel): diff --git a/generalresearch/models/thl/profiling/user_question_answer.py b/generalresearch/models/thl/profiling/user_question_answer.py index a7c2194..342b65e 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 TYPE_CHECKING, Any, Literal +from typing import Any, Literal from pydantic import ( BaseModel, @@ -15,16 +15,12 @@ from pydantic import ( ) from generalresearch.models.custom_types import AwareDatetimeISO, UUIDStr -from generalresearch.models.definitions import MAX_INT32 +from generalresearch.models.definitions import MAX_INT32, Source from generalresearch.models.thl.locales import CountryISO, LanguageISO - -if TYPE_CHECKING: - from generalresearch.models.definitions import Source - from generalresearch.models.thl.profiling.upk_question import UpkQuestion +from generalresearch.models.thl.profiling.upk_question import UpkQuestion class UserQuestionAnswer(BaseModel): - model_config = ConfigDict(validate_assignment=True) user_id: PositiveInt | None = Field(lt=MAX_INT32, default=None) @@ -56,9 +52,9 @@ class UserQuestionAnswer(BaseModel): if calc_answers is None: return None - assert all( - ":" in k for k in calc_answers - ), "calc_answers expects the keys to be in format source:question_code" + assert all(":" in k for k in calc_answers), ( + "calc_answers expects the keys to be in format source:question_code" + ) return calc_answers def model_dump_mysql(self, session_id: str | None = None) -> dict[str, Any]: @@ -97,12 +93,12 @@ class UserQuestionAnswer(BaseModel): """ try: assert question.id == self.question_id, "mismatched question id" - assert ( - question.country_iso == self.country_iso - ), "country_iso doesn't match question's country" - assert ( - question.language_iso == self.language_iso - ), "language_iso doesn't match question's language" + assert question.country_iso == self.country_iso, ( + "country_iso doesn't match question's country" + ) + assert question.language_iso == self.language_iso, ( + "language_iso doesn't match question's language" + ) question._validate_question_answer(self.answer) except AssertionError as e: return False, str(e) @@ -142,9 +138,9 @@ class MarketplaceResearchProfileQuestion(BaseModel): @model_validator(mode="after") def validate_keys(self): - assert ( - ":" not in self.question_code - ), "question_code expected to not be in curie format" + assert ":" not in self.question_code, ( + "question_code expected to not be in curie format" + ) return self @property diff --git a/generalresearch/models/thl/report_task.py b/generalresearch/models/thl/report_task.py index e4a8f48..d816420 100644 --- a/generalresearch/models/thl/report_task.py +++ b/generalresearch/models/thl/report_task.py @@ -8,9 +8,8 @@ from typing import TYPE_CHECKING from pydantic import BaseModel, ConfigDict, Field from generalresearch.models.thl.definitions import ReportValue +from generalresearch.models.thl.user_identifiers 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/survey/model.py b/generalresearch/models/thl/survey/model.py index f8e5083..9e3c03d 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 TYPE_CHECKING, Annotated, Any +from typing import Annotated, Any from pydantic import ( BaseModel, @@ -24,15 +24,11 @@ from generalresearch.models.custom_types import ( PropertyCode, SurveyKey, ) -from generalresearch.models.thl.definitions import StatusCode1 +from generalresearch.models.definitions import Source +from generalresearch.models.thl.category import Category +from generalresearch.models.thl.definitions import Status, StatusCode1 from generalresearch.models.thl.pagination import Page -if TYPE_CHECKING: - - from generalresearch.models.definitions import Source - from generalresearch.models.thl.category import Category - from generalresearch.models.thl.definitions import Status - class SurveyCategoryModel(BaseModel): model_config = ConfigDict(from_attributes=True) @@ -100,12 +96,12 @@ class Survey(BaseModel): @model_validator(mode="after") def category_strengths(self): if any(s.strength is not None for s in self.categories): - assert all( - s.strength is not None for s in self.categories - ), "If any category strength is not None, all should be set" - assert ( - abs(sum(s.strength for s in self.categories) - 1) <= 0.01 - ), "Strengths should some to 1" + assert all(s.strength is not None for s in self.categories), ( + "If any category strength is not None, all should be set" + ) + assert abs(sum(s.strength for s in self.categories) - 1) <= 0.01, ( + "Strengths should some to 1" + ) return self def model_dump_sql(self): diff --git a/generalresearch/models/thl/survey/penalty.py b/generalresearch/models/thl/survey/penalty.py index e989bff..b8ec697 100644 --- a/generalresearch/models/thl/survey/penalty.py +++ b/generalresearch/models/thl/survey/penalty.py @@ -2,7 +2,7 @@ from __future__ import annotations import abc from datetime import UTC, datetime -from typing import TYPE_CHECKING, Annotated, Literal +from typing import Annotated, Literal from pydantic import BaseModel, ConfigDict, Field, TypeAdapter @@ -10,10 +10,7 @@ from generalresearch.models.custom_types import ( AwareDatetimeISO, UUIDStr, ) - -if TYPE_CHECKING: - - from generalresearch.models.definitions import Source +from generalresearch.models.definitions import Source class SurveyPenalty(BaseModel, abc.ABC): diff --git a/generalresearch/models/thl/survey/task_collection.py b/generalresearch/models/thl/survey/task_collection.py index c9614d5..d8db0d1 100644 --- a/generalresearch/models/thl/survey/task_collection.py +++ b/generalresearch/models/thl/survey/task_collection.py @@ -3,14 +3,12 @@ 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 -if TYPE_CHECKING: - from generalresearch.models.thl.survey import MarketplaceTask +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 6e5a935..404f6ea 100644 --- a/generalresearch/models/thl/task_adjustment.py +++ b/generalresearch/models/thl/task_adjustment.py @@ -2,20 +2,16 @@ 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.custom_types import AwareDatetimeISO, UUIDStr -from generalresearch.models.definitions import MAX_INT32 +from generalresearch.models.definitions import MAX_INT32, Source from generalresearch.models.thl.definitions import ( WallAdjustedStatus, ) -if TYPE_CHECKING: - from generalresearch.models.definitions import Source - class TaskAdjustmentEvent(BaseModel): """ diff --git a/generalresearch/models/thl/task_status.py b/generalresearch/models/thl/task_status.py index 16ad66f..8fbb76d 100644 --- a/generalresearch/models/thl/task_status.py +++ b/generalresearch/models/thl/task_status.py @@ -27,19 +27,14 @@ 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 from generalresearch.models.thl.session import WallOut from generalresearch.models.thl.utils import decimal_to_int_cents if TYPE_CHECKING: - - from generalresearch.models.thl.payout_format import ( - PayoutFormatType, - ) - from generalresearch.models.thl.product import ( - PayoutTransformation, - Product, - ) + from generalresearch.models.thl.product import Product from generalresearch.models.thl.session import Session # API uses the ints, b/c this is what the grpc returned originally ... @@ -69,8 +64,7 @@ class TaskStatusResponse(BaseModel): product_user_id: str = Field( min_length=3, max_length=128, - description="A unique identifier for each user, which is set by the " - "Supplier", + description="A unique identifier for each user, which is set by the Supplier", examples=["app-user-9329ebd"], ) diff --git a/generalresearch/models/thl/user_profile.py b/generalresearch/models/thl/user_profile.py index 11dfca1..45dcb40 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 TYPE_CHECKING, Annotated, Any, Self +from typing import Annotated, Any, Self from pydantic import ( BaseModel, @@ -15,11 +15,8 @@ from pydantic.json_schema import SkipJsonSchema from generalresearch.models.custom_types import UUIDStr from generalresearch.models.definitions import MAX_INT32, Source - -if TYPE_CHECKING: - - from generalresearch.models.thl.user import User - from generalresearch.models.thl.user_streak import UserStreak +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 4d5db9d..ab82999 100644 --- a/generalresearch/models/thl/user_quality_event.py +++ b/generalresearch/models/thl/user_quality_event.py @@ -3,18 +3,16 @@ from __future__ import annotations from datetime import UTC, datetime from decimal import Decimal from enum import StrEnum -from typing import TYPE_CHECKING, Literal +from typing import Literal from pydantic import BaseModel, Field, PositiveInt from generalresearch.models.custom_types import AwareDatetimeISO, UUIDStr from generalresearch.models.definitions import MAX_INT32, Source +from generalresearch.models.thl.definitions import WallAdjustedStatus +from generalresearch.models.thl.user_identifiers import BPUIDStr from generalresearch.utils.enum import ReprEnumMeta -if TYPE_CHECKING: - from generalresearch.models.thl.definitions import WallAdjustedStatus - from generalresearch.models.thl.user import BPUIDStr - """ Typically used internally. These affect a user's quality standing. """ |
