diff --git a/ixmp4/data/abstract/docs.py b/ixmp4/data/abstract/docs.py index 4d9f8e43..2fc01a29 100644 --- a/ixmp4/data/abstract/docs.py +++ b/ixmp4/data/abstract/docs.py @@ -23,12 +23,7 @@ class Docs(base.BaseModel, Protocol): # ) -class DocsRepository( - base.Retriever, - base.Deleter, - base.Enumerator, - Protocol, -): +class DocsRepository(base.Retriever, base.Deleter, base.Enumerator, Protocol): def get(self, dimension_id: int) -> Docs: """Retrieve the documentation of an object of any dimension. @@ -84,11 +79,7 @@ def delete(self, dimension_id: int) -> None: """ ... - def list( - self, - *, - dimension_id: int | None = None, - ) -> list[Docs]: + def list(self, *, dimension_id: int | None = None) -> list[Docs]: """Lists documentations. Parameters diff --git a/ixmp4/data/abstract/iamc/measurand.py b/ixmp4/data/abstract/iamc/measurand.py index e94a334d..8528df1f 100644 --- a/ixmp4/data/abstract/iamc/measurand.py +++ b/ixmp4/data/abstract/iamc/measurand.py @@ -43,10 +43,6 @@ def get_or_create(self, variable_name: str, unit__id: int) -> Measurand: except Measurand.NotFound: return self.create(variable_name, unit__id) - def list( - self, - ) -> list[Measurand]: ... + def list(self) -> list[Measurand]: ... - def tabulate( - self, - ) -> pd.DataFrame: ... + def tabulate(self) -> pd.DataFrame: ... diff --git a/ixmp4/data/abstract/meta.py b/ixmp4/data/abstract/meta.py index a974d2fa..7cb2a702 100644 --- a/ixmp4/data/abstract/meta.py +++ b/ixmp4/data/abstract/meta.py @@ -96,12 +96,7 @@ class RunMetaEntryRepository( base.BulkDeleter, Protocol, ): - def create( - self, - run__id: int, - key: str, - value: MetaValue, - ) -> RunMetaEntry: + def create(self, run__id: int, key: str, value: MetaValue) -> RunMetaEntry: """Creates a meta indicator entry for a run. Parameters @@ -165,9 +160,7 @@ def delete(self, id: int) -> None: ... def list( - self, - join_run_index: bool = False, - **kwargs: Unpack[EnumerateKwargs], + self, join_run_index: bool = False, **kwargs: Unpack[EnumerateKwargs] ) -> list[RunMetaEntry]: r"""Lists run's meta indicator entries by specified criteria. @@ -187,9 +180,7 @@ def list( ... def tabulate( - self, - join_run_index: bool = False, - **kwargs: Unpack[EnumerateKwargs], + self, join_run_index: bool = False, **kwargs: Unpack[EnumerateKwargs] ) -> pd.DataFrame: r"""Tabulates run's meta indicator entries by specified criteria. diff --git a/ixmp4/data/abstract/region.py b/ixmp4/data/abstract/region.py index c6615a10..d474ca47 100644 --- a/ixmp4/data/abstract/region.py +++ b/ixmp4/data/abstract/region.py @@ -107,11 +107,7 @@ def get(self, name: str) -> Region: """ ... - def get_or_create( - self, - name: str, - hierarchy: str | None = None, - ) -> Region: + def get_or_create(self, name: str, hierarchy: str | None = None) -> Region: try: region = self.get(name) except Region.NotFound: @@ -127,10 +123,7 @@ def get_or_create( else: return region - def list( - self, - **kwargs: Unpack[EnumerateKwargs], - ) -> list[Region]: + def list(self, **kwargs: Unpack[EnumerateKwargs]) -> list[Region]: r"""Lists regions by specified criteria. Parameters @@ -146,10 +139,7 @@ def list( """ ... - def tabulate( - self, - **kwargs: Unpack[EnumerateKwargs], - ) -> pd.DataFrame: + def tabulate(self, **kwargs: Unpack[EnumerateKwargs]) -> pd.DataFrame: r"""Tabulate regions by specified criteria. Parameters diff --git a/ixmp4/data/abstract/run.py b/ixmp4/data/abstract/run.py index 2433b7f7..e528f5a5 100644 --- a/ixmp4/data/abstract/run.py +++ b/ixmp4/data/abstract/run.py @@ -51,11 +51,7 @@ class RunRepository( base.Enumerator, Protocol, ): - def create( - self, - model_name: str, - scenario_name: str, - ) -> Run: + def create(self, model_name: str, scenario_name: str) -> Run: """Creates a run with an incremented version number or version=1 if no versions exist. Will automatically create the models and scenarios if they don't exist yet. @@ -74,12 +70,7 @@ def create( """ ... - def get( - self, - model_name: str, - scenario_name: str, - version: int, - ) -> Run: + def get(self, model_name: str, scenario_name: str, version: int) -> Run: """Retrieves a run. Parameters @@ -103,11 +94,7 @@ def get( """ ... - def get_or_create( - self, - model_name: str, - scenario_name: str, - ) -> Run: + def get_or_create(self, model_name: str, scenario_name: str) -> Run: """Tries to retrieve a run's default version and creates it if it was not found. @@ -128,11 +115,7 @@ def get_or_create( except Run.NoDefaultVersion: return self.create(model_name, scenario_name) - def get_default_version( - self, - model_name: str, - scenario_name: str, - ) -> Run: + def get_default_version(self, model_name: str, scenario_name: str) -> Run: """Retrieves a run's default version. Parameters @@ -154,10 +137,7 @@ def get_default_version( """ ... - def list( - self, - **kwargs: Unpack[EnumerateKwargs], - ) -> list[Run]: + def list(self, **kwargs: Unpack[EnumerateKwargs]) -> list[Run]: r"""Lists runs by specified criteria. Parameters @@ -173,10 +153,7 @@ def list( """ ... - def tabulate( - self, - **kwargs: Unpack[EnumerateKwargs], - ) -> pd.DataFrame: + def tabulate(self, **kwargs: Unpack[EnumerateKwargs]) -> pd.DataFrame: r"""Tabulate runs by specified criteria. Parameters diff --git a/ixmp4/data/abstract/unit.py b/ixmp4/data/abstract/unit.py index 6bebc354..27e2e561 100644 --- a/ixmp4/data/abstract/unit.py +++ b/ixmp4/data/abstract/unit.py @@ -122,10 +122,7 @@ def delete(self, id: int) -> None: """ ... - def list( - self, - **kwargs: Unpack[EnumerateKwargs], - ) -> list[Unit]: + def list(self, **kwargs: Unpack[EnumerateKwargs]) -> list[Unit]: r"""Lists units by specified criteria. Parameters @@ -141,10 +138,7 @@ def list( """ ... - def tabulate( - self, - **kwargs: Unpack[EnumerateKwargs], - ) -> pd.DataFrame: + def tabulate(self, **kwargs: Unpack[EnumerateKwargs]) -> pd.DataFrame: r"""Tabulate units by specified criteria. Parameters diff --git a/ixmp4/data/api/base.py b/ixmp4/data/api/base.py index 16ddb826..5978fc2f 100644 --- a/ixmp4/data/api/base.py +++ b/ixmp4/data/api/base.py @@ -72,8 +72,9 @@ class DataFrameDict(TypedDict): abstract.annotations.PrimitiveTypes | datetime | dict[str, Any] - # TODO should be able to remove this once PR#122 is merged - | list[float | int | str] + | list[float] + | list[int] + | list[str] | None ] ] @@ -110,8 +111,9 @@ class DataFrame(PydanticBaseModel): | float | str | dict[str, Any] - # TODO should be able to remove this once PR#122 is merged - | list[float | int | str] + | list[float] + | list[int] + | list[str] | None ] ] diff --git a/ixmp4/data/api/meta.py b/ixmp4/data/api/meta.py index 57e0b23b..eb5fb908 100644 --- a/ixmp4/data/api/meta.py +++ b/ixmp4/data/api/meta.py @@ -54,12 +54,7 @@ class RunMetaEntryRepository( model_class = RunMetaEntry prefix = "meta/" - def create( - self, - run__id: int, - key: str, - value: abstract.MetaValue, - ) -> RunMetaEntry: + def create(self, run__id: int, key: str, value: abstract.MetaValue) -> RunMetaEntry: return super().create(run__id=run__id, key=key, value=value) def get(self, run__id: int, key: str) -> RunMetaEntry: diff --git a/ixmp4/data/api/model.py b/ixmp4/data/api/model.py index 0d67588c..0dfd41d5 100644 --- a/ixmp4/data/api/model.py +++ b/ixmp4/data/api/model.py @@ -41,10 +41,7 @@ def __init__(self, *args: Unpack[tuple["RestBackend"]]) -> None: super().__init__(*args) self.docs = ModelDocsRepository(self.backend) - def create( - self, - name: str, - ) -> Model: + def create(self, name: str) -> Model: return super().create(name=name) def get(self, name: str) -> Model: diff --git a/ixmp4/data/api/optimization/equation.py b/ixmp4/data/api/optimization/equation.py index 44a7fd5b..8a45328e 100644 --- a/ixmp4/data/api/optimization/equation.py +++ b/ixmp4/data/api/optimization/equation.py @@ -85,15 +85,13 @@ def get_by_id(self, id: int) -> Equation: return Equation(**res) def list( - self, - **kwargs: Unpack[abstract.optimization.EnumerateKwargs], + self, **kwargs: Unpack[abstract.optimization.EnumerateKwargs] ) -> Iterable[Equation]: json = cast(abstract.annotations.OptimizationFilterAlias, kwargs) return super()._list(json=json) def tabulate( - self, - **kwargs: Unpack[abstract.optimization.EnumerateKwargs], + self, **kwargs: Unpack[abstract.optimization.EnumerateKwargs] ) -> pd.DataFrame: json = cast(abstract.annotations.OptimizationFilterAlias, kwargs) return super()._tabulate(json=json) diff --git a/ixmp4/data/api/optimization/indexset.py b/ixmp4/data/api/optimization/indexset.py index 422f69d4..7e3b4a8c 100644 --- a/ixmp4/data/api/optimization/indexset.py +++ b/ixmp4/data/api/optimization/indexset.py @@ -23,7 +23,7 @@ class IndexSet(base.BaseModel): id: int name: str - data: float | int | str | list[int | float | str] | None + data: float | int | str | list[int] | list[float] | list[str] | None run__id: int created_at: datetime | None @@ -48,11 +48,7 @@ def __init__(self, *args: Unpack[tuple["RestBackend"]]) -> None: super().__init__(*args) self.docs = IndexSetDocsRepository(self.backend) - def create( - self, - run_id: int, - name: str, - ) -> IndexSet: + def create(self, run_id: int, name: str) -> IndexSet: return super().create(run_id=run_id, name=name) def get(self, run_id: int, name: str) -> IndexSet: @@ -64,8 +60,7 @@ def enumerate( return super().enumerate(**kwargs) def list( - self, - **kwargs: Unpack[abstract.optimization.EnumerateKwargs], + self, **kwargs: Unpack[abstract.optimization.EnumerateKwargs] ) -> list[IndexSet]: json = cast(abstract.annotations.OptimizationFilterAlias, kwargs) return super()._list(json=json) diff --git a/ixmp4/data/api/optimization/parameter.py b/ixmp4/data/api/optimization/parameter.py index 815aaa81..eb3a94ae 100644 --- a/ixmp4/data/api/optimization/parameter.py +++ b/ixmp4/data/api/optimization/parameter.py @@ -82,15 +82,13 @@ def get_by_id(self, id: int) -> Parameter: return Parameter(**res) def list( - self, - **kwargs: Unpack[abstract.optimization.EnumerateKwargs], + self, **kwargs: Unpack[abstract.optimization.EnumerateKwargs] ) -> Iterable[Parameter]: json = cast(abstract.annotations.OptimizationFilterAlias, kwargs) return super()._list(json=json) def tabulate( - self, - **kwargs: Unpack[abstract.optimization.EnumerateKwargs], + self, **kwargs: Unpack[abstract.optimization.EnumerateKwargs] ) -> pd.DataFrame: json = cast(abstract.annotations.OptimizationFilterAlias, kwargs) return super()._tabulate(json=json) diff --git a/ixmp4/data/api/optimization/scalar.py b/ixmp4/data/api/optimization/scalar.py index c0736085..edae5b87 100644 --- a/ixmp4/data/api/optimization/scalar.py +++ b/ixmp4/data/api/optimization/scalar.py @@ -51,13 +51,7 @@ def __init__(self, *args: Unpack[tuple["RestBackend"]]) -> None: super().__init__(*args) self.docs = ScalarDocsRepository(self.backend) - def create( - self, - name: str, - value: float, - unit_name: str, - run_id: int, - ) -> Scalar: + def create(self, name: str, value: float, unit_name: str, run_id: int) -> Scalar: return super().create( name=name, value=value, unit_name=unit_name, run_id=run_id ) diff --git a/ixmp4/data/api/region.py b/ixmp4/data/api/region.py index 9fadb0c1..d9b38de3 100644 --- a/ixmp4/data/api/region.py +++ b/ixmp4/data/api/region.py @@ -54,11 +54,7 @@ def __init__(self, *args: Unpack[tuple["RestBackend"]]) -> None: super().__init__(*args) self.docs = RegionDocsRepository(self.backend) - def create( - self, - name: str, - hierarchy: str, - ) -> Region: + def create(self, name: str, hierarchy: str) -> Region: return super().create(name=name, hierarchy=hierarchy) def delete(self, id: int) -> None: @@ -72,16 +68,12 @@ def enumerate( ) -> list[Region] | pd.DataFrame: return super().enumerate(**kwargs) - def list( - self, - **kwargs: Unpack[abstract.region.EnumerateKwargs], - ) -> list[Region]: + def list(self, **kwargs: Unpack[abstract.region.EnumerateKwargs]) -> list[Region]: json = cast(abstract.annotations.IamcObjectFilterAlias, kwargs) return super()._list(json=json) def tabulate( - self, - **kwargs: Unpack[abstract.region.EnumerateKwargs], + self, **kwargs: Unpack[abstract.region.EnumerateKwargs] ) -> pd.DataFrame: json = cast(abstract.annotations.IamcObjectFilterAlias, kwargs) return super()._tabulate(json=json) diff --git a/ixmp4/data/api/run.py b/ixmp4/data/api/run.py index bbe213f4..374d0ebc 100644 --- a/ixmp4/data/api/run.py +++ b/ixmp4/data/api/run.py @@ -72,17 +72,11 @@ def enumerate( ) -> list[Run] | pd.DataFrame: return super().enumerate(**kwargs) - def list( - self, - **kwargs: Unpack[abstract.run.EnumerateKwargs], - ) -> list[Run]: + def list(self, **kwargs: Unpack[abstract.run.EnumerateKwargs]) -> list[Run]: json = cast(JsonType, kwargs) return super()._list(json=json) - def tabulate( - self, - **kwargs: Unpack[abstract.run.EnumerateKwargs], - ) -> pd.DataFrame: + def tabulate(self, **kwargs: Unpack[abstract.run.EnumerateKwargs]) -> pd.DataFrame: json = cast(JsonType, kwargs) return super()._tabulate(json=json) diff --git a/ixmp4/data/api/scenario.py b/ixmp4/data/api/scenario.py index b836906c..1521c076 100644 --- a/ixmp4/data/api/scenario.py +++ b/ixmp4/data/api/scenario.py @@ -45,10 +45,7 @@ def __init__(self, *args: Unpack[tuple["RestBackend"]]) -> None: super().__init__(*args) self.docs = ScenarioDocsRepository(self.backend) - def create( - self, - name: str, - ) -> Scenario: + def create(self, name: str) -> Scenario: return super().create(name=name) def get(self, name: str) -> Scenario: @@ -60,15 +57,13 @@ def enumerate( return super().enumerate(**kwargs) def list( - self, - **kwargs: Unpack[abstract.scenario.EnumerateKwargs], + self, **kwargs: Unpack[abstract.scenario.EnumerateKwargs] ) -> list[Scenario]: json = cast(abstract.annotations.IamcObjectFilterAlias, kwargs) return super()._list(json=json) def tabulate( - self, - **kwargs: Unpack[abstract.scenario.EnumerateKwargs], + self, **kwargs: Unpack[abstract.scenario.EnumerateKwargs] ) -> pd.DataFrame: json = cast(abstract.annotations.IamcObjectFilterAlias, kwargs) return super()._tabulate(json=json) diff --git a/ixmp4/data/api/unit.py b/ixmp4/data/api/unit.py index a8d64071..8024534c 100644 --- a/ixmp4/data/api/unit.py +++ b/ixmp4/data/api/unit.py @@ -46,10 +46,7 @@ def __init__(self, *args: Unpack[tuple["RestBackend"]]) -> None: super().__init__(*args) self.docs = UnitDocsRepository(self.backend) - def create( - self, - name: str, - ) -> Unit: + def create(self, name: str) -> Unit: return super().create(name=name) def delete(self, id: int) -> None: diff --git a/ixmp4/data/db/base.py b/ixmp4/data/db/base.py index 916c20c8..56b68f8c 100644 --- a/ixmp4/data/db/base.py +++ b/ixmp4/data/db/base.py @@ -199,11 +199,7 @@ def check_access( def join_auth(self, exc: SelectAuthType) -> SelectAuthType: return exc - def apply_auth( - self, - exc: SelectAuthType, - access_type: str, - ) -> SelectAuthType: + def apply_auth(self, exc: SelectAuthType, access_type: str) -> SelectAuthType: if self.backend.auth_context is not None: if not self.backend.auth_context.is_managed: exc = self.join_auth(exc) @@ -281,12 +277,7 @@ def list(self, *args: Any, **kwargs: Any) -> list[ModelType]: class Tabulator(Selecter[ModelType]): - def tabulate( - self, - *args: Any, - _raw: bool = False, - **kwargs: Any, - ) -> pd.DataFrame: + def tabulate(self, *args: Any, _raw: bool = False, **kwargs: Any) -> pd.DataFrame: _exc = self.select(*args, **kwargs) _exc = _exc.order_by(self.model_class.id.asc()) @@ -331,19 +322,13 @@ def enumerate( return self.tabulate(**kwargs) if table else self.list(**kwargs) def paginate( - self, - limit: int = 1000, - offset: int = 0, - **kwargs: Unpack[PaginateKwargs], + self, limit: int = 1000, offset: int = 0, **kwargs: Unpack[PaginateKwargs] ) -> list[ModelType] | pd.DataFrame: return self.enumerate( **kwargs, _post_filter=lambda e: e.offset(offset).limit(limit) ) - def count( - self, - **kwargs: Unpack[CountKwargs], - ) -> int: + def count(self, **kwargs: Unpack[CountKwargs]) -> int: _exc = self.select_for_count( _exc=db.select(db.func.count(self.model_class.id.distinct())), **kwargs, diff --git a/ixmp4/data/db/meta/repository.py b/ixmp4/data/db/meta/repository.py index d1c2928b..55fcbfb1 100644 --- a/ixmp4/data/db/meta/repository.py +++ b/ixmp4/data/db/meta/repository.py @@ -99,9 +99,7 @@ def check_df_access(self, df: pd.DataFrame) -> None: @guard("edit") def create( - self, - *args: abstract.annotations.PrimitiveTypes, - **kwargs: Unpack[CreateKwargs], + self, *args: abstract.annotations.PrimitiveTypes, **kwargs: Unpack[CreateKwargs] ) -> RunMetaEntry: return super().create(*args, **kwargs) diff --git a/ixmp4/data/db/model/repository.py b/ixmp4/data/db/model/repository.py index 8f7120bd..c143dd9e 100644 --- a/ixmp4/data/db/model/repository.py +++ b/ixmp4/data/db/model/repository.py @@ -19,7 +19,7 @@ from .model import Model -class EnumerateKwargs(abstract.HasNameFilter, total=False): +class EnumerateKwargs(abstract.annotations.HasNameFilter, total=False): _filter: BaseFilter diff --git a/ixmp4/data/db/optimization/parameter/repository.py b/ixmp4/data/db/optimization/parameter/repository.py index 37ed0f9d..82d50f88 100644 --- a/ixmp4/data/db/optimization/parameter/repository.py +++ b/ixmp4/data/db/optimization/parameter/repository.py @@ -80,11 +80,7 @@ def _add_column( # type: ignore[no-untyped-def] **kwargs, ) - def add( - self, - run_id: int, - name: str, - ) -> Parameter: + def add(self, run_id: int, name: str) -> Parameter: parameter = Parameter(name=name, run__id=run_id) parameter.set_creation_info(auth_context=self.backend.auth_context) self.session.add(parameter) diff --git a/ixmp4/data/db/optimization/table/repository.py b/ixmp4/data/db/optimization/table/repository.py index c95b7100..27dbef2c 100644 --- a/ixmp4/data/db/optimization/table/repository.py +++ b/ixmp4/data/db/optimization/table/repository.py @@ -78,11 +78,7 @@ def _add_column( # type: ignore[no-untyped-def] **kwargs, ) - def add( - self, - run_id: int, - name: str, - ) -> Table: + def add(self, run_id: int, name: str) -> Table: table = Table(name=name, run__id=run_id) self.session.add(table) diff --git a/ixmp4/data/db/region/repository.py b/ixmp4/data/db/region/repository.py index 61014a57..37302e8e 100644 --- a/ixmp4/data/db/region/repository.py +++ b/ixmp4/data/db/region/repository.py @@ -1,4 +1,3 @@ -from collections.abc import Iterable from typing import TYPE_CHECKING import pandas as pd @@ -19,13 +18,11 @@ from .model import Region -class EnumerateKwargs(abstract.HasNameFilter, total=False): - hierarchy: str - hierarchy__in: Iterable[str] - hierarchy__like: str - hierarchy__ilike: str - hierarchy__notlike: str - hierarchy__notilike: str +class EnumerateKwargs( + abstract.annotations.HasNameFilter, + abstract.annotations.HasHierarchyFilter, + total=False, +): _filter: BaseFilter diff --git a/ixmp4/data/db/run/repository.py b/ixmp4/data/db/run/repository.py index a5887a6e..81370410 100644 --- a/ixmp4/data/db/run/repository.py +++ b/ixmp4/data/db/run/repository.py @@ -93,12 +93,7 @@ def create( return super().create(model_name, *args, **kwargs) @guard("view") - def get( - self, - model_name: str, - scenario_name: str, - version: int, - ) -> Run: + def get(self, model_name: str, scenario_name: str, version: int) -> Run: exc = self.select( model={"name": model_name}, scenario={"name": scenario_name}, @@ -127,11 +122,7 @@ def get_by_id(self, id: int) -> Run: return obj @guard("view") - def get_default_version( - self, - model_name: str, - scenario_name: str, - ) -> Run: + def get_default_version(self, model_name: str, scenario_name: str) -> Run: exc = self.select( model={"name": model_name}, scenario={"name": scenario_name}, diff --git a/ixmp4/data/db/scenario/repository.py b/ixmp4/data/db/scenario/repository.py index 0b919cb3..e77858ce 100644 --- a/ixmp4/data/db/scenario/repository.py +++ b/ixmp4/data/db/scenario/repository.py @@ -19,7 +19,7 @@ from .model import Scenario -class EnumerateKwargs(abstract.HasNameFilter, total=False): +class EnumerateKwargs(abstract.annotations.HasNameFilter, total=False): _filter: BaseFilter diff --git a/ixmp4/data/db/timeseries.py b/ixmp4/data/db/timeseries.py index b497c4cb..7f62dfca 100644 --- a/ixmp4/data/db/timeseries.py +++ b/ixmp4/data/db/timeseries.py @@ -61,7 +61,7 @@ class SelectKwargs(TypedDict, total=False): run: dict[str, int] -class EnumerateKwargs(abstract.HasNameFilter, total=False): +class EnumerateKwargs(abstract.annotations.HasNameFilter, total=False): _filter: BaseFilter join_parameters: bool | None diff --git a/ixmp4/data/db/unit/repository.py b/ixmp4/data/db/unit/repository.py index a734c735..7f02c008 100644 --- a/ixmp4/data/db/unit/repository.py +++ b/ixmp4/data/db/unit/repository.py @@ -19,7 +19,7 @@ from .model import Unit -class EnumerateKwargs(abstract.HasNameFilter, total=False): +class EnumerateKwargs(abstract.annotations.HasNameFilter, total=False): _filter: BaseFilter diff --git a/ixmp4/data/types.py b/ixmp4/data/types.py index 55549c4d..449657f9 100644 --- a/ixmp4/data/types.py +++ b/ixmp4/data/types.py @@ -10,6 +10,7 @@ Float = Mapped[float] IndexSetId = Mapped[db.IndexSetIdType] Integer = Mapped[int] +# NOTE only one type will ever be in list, but not sure if we can map a union of lists OptimizationDataList = Mapped[list[float | int | str]] JsonDict = Mapped[dict[str, Any]] OptimizationDataType = Mapped[Literal["float", "int", "str"] | None] diff --git a/ixmp4/db/utils/__init__.py b/ixmp4/db/utils/__init__.py index e0fb4cba..3ef8a97d 100644 --- a/ixmp4/db/utils/__init__.py +++ b/ixmp4/db/utils/__init__.py @@ -11,7 +11,6 @@ if TYPE_CHECKING: from ixmp4.data.db.base import BaseModel -# TODO cannot use covariant typevar JoinType = TypeVar("JoinType", bound=sql.Select[tuple["BaseModel", ...]]) diff --git a/ixmp4/server/rest/__init__.py b/ixmp4/server/rest/__init__.py index 45275053..762ffc52 100644 --- a/ixmp4/server/rest/__init__.py +++ b/ixmp4/server/rest/__init__.py @@ -74,10 +74,7 @@ class APIInfo(BaseModel): @v1.get("/", response_model=APIInfo) -def root( - platform: str = Path(), - version: str = Depends(deps.get_version), -) -> APIInfo: +def root(platform: str = Path(), version: str = Depends(deps.get_version)) -> APIInfo: return APIInfo( name=platform, version=version, diff --git a/ixmp4/server/rest/docs.py b/ixmp4/server/rest/docs.py index db25e110..f8be7cc5 100644 --- a/ixmp4/server/rest/docs.py +++ b/ixmp4/server/rest/docs.py @@ -96,7 +96,6 @@ def set_scenarios( docs: DocsInput, backend: Backend = Depends(deps.get_backend), ) -> api.Docs: - # TODO is this faster or explicit casting (storing a variable)? return cast(api.Docs, backend.scenarios.docs.set(**docs.model_dump())) diff --git a/ixmp4/server/rest/optimization/equation.py b/ixmp4/server/rest/optimization/equation.py index 3ceafa03..d35d9e31 100644 --- a/ixmp4/server/rest/optimization/equation.py +++ b/ixmp4/server/rest/optimization/equation.py @@ -45,17 +45,6 @@ def query( pagination: Pagination = Depends(), backend: Backend = Depends(deps.get_backend), ) -> EnumerationOutput[Equation]: - print("before count") - total = backend.optimization.equations.count(_filter=filter) - print(total) - print("before paginate") - results = backend.optimization.equations.paginate( - _filter=filter, - limit=pagination.limit, - offset=pagination.offset, - table=bool(table), - ) - print(results) return EnumerationOutput( results=backend.optimization.equations.paginate( _filter=filter, diff --git a/pyproject.toml b/pyproject.toml index a363f9b7..957587e9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -111,7 +111,10 @@ no_implicit_optional = true warn_unreachable = true [[tool.mypy.overrides]] +# Removing this introduces several errors module = ["uvicorn.workers"] +# Without this, mypy is still fine, but pyproject.toml complains +ignore_missing_imports = true [tool.pydantic-mypy] init_forbid_extra = true diff --git a/tests/core/test_optimization_scalar.py b/tests/core/test_optimization_scalar.py index 2baf961b..0a04e51e 100644 --- a/tests/core/test_optimization_scalar.py +++ b/tests/core/test_optimization_scalar.py @@ -53,7 +53,8 @@ def test_create_scalar(self, platform: ixmp4.Platform) -> None: ) with pytest.raises(TypeError): - _ = run.optimization.scalars.create("Scalar 2") # type: ignore + # Testing a missing parameter on purpose + _ = run.optimization.scalars.create("Scalar 2") # type: ignore[call-arg] scalar_2 = run.optimization.scalars.create("Scalar 2", value=20, unit=unit) assert scalar_1.id != scalar_2.id diff --git a/tests/test_api.py b/tests/test_api.py index 81e6c0fe..e0e76087 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -55,7 +55,6 @@ def assert_paginated_res( filters: dict[str, dict[str, bool]] | None = None, no_of_rows: int | None = None, ) -> None: - # total, offset, limit = None, None, None total: int | None = None offset: int | None = None limit: int | None = None