aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--generalresearch/incite/base.py5
-rw-r--r--generalresearch/models/cint/survey.py14
-rw-r--r--generalresearch/models/dynata/survey.py6
-rw-r--r--generalresearch/models/dynata/task_collection.py2
-rw-r--r--generalresearch/models/prodege/task_collection.py6
-rw-r--r--generalresearch/models/thl/contest/__init__.py7
-rw-r--r--generalresearch/models/thl/contest/contest_entry.py1
-rw-r--r--generalresearch/utils/copying_cache.py2
8 files changed, 21 insertions, 22 deletions
diff --git a/generalresearch/incite/base.py b/generalresearch/incite/base.py
index 795aad9..54d1565 100644
--- a/generalresearch/incite/base.py
+++ b/generalresearch/incite/base.py
@@ -7,7 +7,7 @@ import re
import shutil
import subprocess
import warnings
-from concurrent.futures import Future
+from collections.abc import Callable, Sequence
from datetime import datetime, timedelta, timezone
from os import R_OK, access, listdir
from os.path import isdir
@@ -17,12 +17,9 @@ from sys import platform
from typing import (
TYPE_CHECKING,
Any,
- Callable,
- Sequence,
)
from uuid import uuid4
-import dask
import dask.dataframe as dd
import pandas as pd
import pyarrow.parquet as pq
diff --git a/generalresearch/models/cint/survey.py b/generalresearch/models/cint/survey.py
index 56384e3..21bc21a 100644
--- a/generalresearch/models/cint/survey.py
+++ b/generalresearch/models/cint/survey.py
@@ -4,7 +4,7 @@ import json
import logging
from datetime import datetime, timezone
from decimal import Decimal
-from typing import Any, Literal, Type
+from typing import Annotated, Any, Literal
from more_itertools import flatten
from pydantic import (
@@ -15,7 +15,7 @@ from pydantic import (
computed_field,
model_validator,
)
-from typing_extensions import Annotated, Self
+from typing_extensions import Self
from generalresearch.locales import Localelator
from generalresearch.models import Source, TaskCalculationType
@@ -73,9 +73,9 @@ class CintQuota(BaseModel):
@model_validator(mode="after")
def validate_condition_len(self) -> Self:
if self.quota_type == "total":
- assert (
- self.condition_hashes is None
- ), "total quota should not have conditions"
+ assert self.condition_hashes is None, (
+ "total quota should not have conditions"
+ )
elif self.quota_type == "client":
assert len(self.condition_hashes) > 0, "quota must have conditions"
return self
@@ -291,7 +291,7 @@ class CintSurvey(MarketplaceTask):
return data
@property
- def condition_model(self) -> Type[MarketplaceCondition]:
+ def condition_model(self) -> type[MarketplaceCondition]:
return CintCondition
@property
@@ -417,7 +417,7 @@ class CintSurvey(MarketplaceTask):
return d
@classmethod
- def from_mysql(cls, d: Dict[str, Any]) -> Self:
+ def from_mysql(cls, d: dict[str, Any]) -> Self:
d["created_at"] = d["created_at"].replace(tzinfo=timezone.utc)
d["last_updated"] = d["last_updated"].replace(tzinfo=timezone.utc)
d["qualifications"] = json.loads(d["qualifications"])
diff --git a/generalresearch/models/dynata/survey.py b/generalresearch/models/dynata/survey.py
index 0e1b3e5..e88491d 100644
--- a/generalresearch/models/dynata/survey.py
+++ b/generalresearch/models/dynata/survey.py
@@ -5,7 +5,7 @@ import logging
from datetime import timezone
from decimal import Decimal
from functools import cached_property
-from typing import Any, Literal, Type
+from typing import Any, Literal
from more_itertools import flatten
from pydantic import (
@@ -500,7 +500,7 @@ class DynataSurvey(MarketplaceTask):
return res
@property
- def condition_model(self) -> Type[MarketplaceCondition]:
+ def condition_model(self) -> type[MarketplaceCondition]:
return DynataCondition
@property
@@ -551,7 +551,7 @@ class DynataSurvey(MarketplaceTask):
return d
@classmethod
- def from_db(cls, d: Dict[str, Any]) -> Self:
+ def from_db(cls, d: dict[str, Any]) -> Self:
d["created"] = d["created"].replace(tzinfo=timezone.utc)
d["last_updated"] = d["last_updated"].replace(tzinfo=timezone.utc)
d["filters"] = json.loads(d["filters"])
diff --git a/generalresearch/models/dynata/task_collection.py b/generalresearch/models/dynata/task_collection.py
index 71cf3db..2b82bfd 100644
--- a/generalresearch/models/dynata/task_collection.py
+++ b/generalresearch/models/dynata/task_collection.py
@@ -54,7 +54,7 @@ DynataTaskCollectionSchema = DataFrameSchema(
class DynataTaskCollection(TaskCollection):
- items: List[DynataSurvey]
+ items: list[DynataSurvey]
_schema = DynataTaskCollectionSchema
def to_row(self, s: DynataSurvey) -> dict[str, Any]:
diff --git a/generalresearch/models/prodege/task_collection.py b/generalresearch/models/prodege/task_collection.py
index 19e594f..4544050 100644
--- a/generalresearch/models/prodege/task_collection.py
+++ b/generalresearch/models/prodege/task_collection.py
@@ -1,4 +1,4 @@
-from typing import Any, Dict, List
+from typing import Any
import pandas as pd
from pandera.pandas import Check, Column, DataFrameSchema, Index
@@ -30,8 +30,8 @@ ProdegeTaskCollectionSchema = DataFrameSchema(
"conversion_rate": Column(float, Check.between(0, 1), nullable=True),
"created": Column(dtype=pd.DatetimeTZDtype(tz="UTC")),
"updated": Column(dtype=pd.DatetimeTZDtype(tz="UTC")),
- "used_question_ids": Column(List[str]),
- "all_hashes": Column(List[str]), # set >> list for column support
+ "used_question_ids": Column(list[str]),
+ "all_hashes": Column(list[str]), # set >> list for column support
"is_recontact": Column(bool),
# Not including here: entrance_url, max_clicks_settings, past_participation, include_psids, exclude_psids,
# quotas, source, conditions
diff --git a/generalresearch/models/thl/contest/__init__.py b/generalresearch/models/thl/contest/__init__.py
index 363c8c0..c02acbe 100644
--- a/generalresearch/models/thl/contest/__init__.py
+++ b/generalresearch/models/thl/contest/__init__.py
@@ -1,6 +1,7 @@
from __future__ import annotations
from datetime import datetime, timezone
+from typing import Any
from uuid import uuid4
from pydantic import (
@@ -86,9 +87,9 @@ class ContestPrize(BaseModel):
@model_validator(mode="after")
def validate_cash_value(self) -> Self:
if self.kind == ContestPrizeKind.CASH:
- assert (
- self.estimated_cash_value == self.cash_amount
- ), "if kind is CASH, cash_amount must equal estimated_cash_value"
+ assert self.estimated_cash_value == self.cash_amount, (
+ "if kind is CASH, cash_amount must equal estimated_cash_value"
+ )
return self
diff --git a/generalresearch/models/thl/contest/contest_entry.py b/generalresearch/models/thl/contest/contest_entry.py
index cddae14..2a9ecde 100644
--- a/generalresearch/models/thl/contest/contest_entry.py
+++ b/generalresearch/models/thl/contest/contest_entry.py
@@ -1,6 +1,7 @@
from __future__ import annotations
from datetime import datetime, timezone
+from typing import Any
from uuid import uuid4
from pydantic import (
diff --git a/generalresearch/utils/copying_cache.py b/generalresearch/utils/copying_cache.py
index ea13f69..a1cb37c 100644
--- a/generalresearch/utils/copying_cache.py
+++ b/generalresearch/utils/copying_cache.py
@@ -1,6 +1,6 @@
+from collections.abc import Callable
from copy import deepcopy
from functools import wraps
-from typing import Callable
def deepcopy_return(fn: Callable) -> Callable: