From 7e4a67853edf185f465e7301d6a9f252de5697d7 Mon Sep 17 00:00:00 2001 From: Marigold Date: Thu, 12 Dec 2024 09:42:08 +0100 Subject: [PATCH] wip --- lib/catalog/owid/catalog/tables.py | 63 ++++++++++-------------------- 1 file changed, 21 insertions(+), 42 deletions(-) diff --git a/lib/catalog/owid/catalog/tables.py b/lib/catalog/owid/catalog/tables.py index f8af74260d2d..6233dde87959 100644 --- a/lib/catalog/owid/catalog/tables.py +++ b/lib/catalog/owid/catalog/tables.py @@ -192,12 +192,10 @@ def read(cls, path: Union[str, Path], **kwargs) -> "Table": return table @overload - def to_csv(self, path: None = None, **kwargs: Any) -> str: - ... + def to_csv(self, path: None = None, **kwargs: Any) -> str: ... @overload - def to_csv(self, path: Any, **kwargs: Any) -> None: - ... + def to_csv(self, path: Any, **kwargs: Any) -> None: ... def to_csv(self, path: Optional[Any] = None, **kwargs: Any) -> Union[None, str]: """ @@ -451,16 +449,13 @@ def rename( *, inplace: Literal[True], **kwargs: Any, - ) -> None: - ... + ) -> None: ... @overload - def rename(self, mapper: Any = None, *, inplace: Literal[False], **kwargs: Any) -> "Table": - ... + def rename(self, mapper: Any = None, *, inplace: Literal[False], **kwargs: Any) -> "Table": ... @overload - def rename(self, *args: Any, **kwargs: Any) -> "Table": - ... + def rename(self, *args: Any, **kwargs: Any) -> "Table": ... def rename(self, *args: Any, **kwargs: Any) -> Optional["Table"]: """Rename columns while keeping their metadata.""" @@ -565,16 +560,13 @@ def set_index( *, inplace: Literal[True], **kwargs: Any, - ) -> None: - ... + ) -> None: ... @overload - def set_index(self, keys: Union[str, List[str]], *, inplace: Literal[False], **kwargs: Any) -> "Table": - ... + def set_index(self, keys: Union[str, List[str]], *, inplace: Literal[False], **kwargs: Any) -> "Table": ... @overload - def set_index(self, keys: Union[str, List[str]], **kwargs: Any) -> "Table": - ... + def set_index(self, keys: Union[str, List[str]], **kwargs: Any) -> "Table": ... def set_index( self, @@ -594,16 +586,13 @@ def set_index( return cast(Table, t) @overload - def reset_index(self, level=None, *, inplace: Literal[True], **kwargs) -> None: - ... + def reset_index(self, level=None, *, inplace: Literal[True], **kwargs) -> None: ... @overload - def reset_index(self, level=None, *, inplace: Literal[False], **kwargs) -> "Table": - ... + def reset_index(self, level=None, *, inplace: Literal[False], **kwargs) -> "Table": ... @overload - def reset_index(self, level=None, *, inplace: bool = False, **kwargs) -> "Table": - ... + def reset_index(self, level=None, *, inplace: bool = False, **kwargs) -> "Table": ... def reset_index(self, level=None, *, inplace: bool = False, **kwargs) -> Optional["Table"]: # type: ignore """Fix type signature of reset_index.""" @@ -623,16 +612,13 @@ def reindex(self, *args, **kwargs) -> "Table": return cast(Table, t) @overload - def drop_duplicates(self, *, inplace: Literal[True], **kwargs) -> None: - ... + def drop_duplicates(self, *, inplace: Literal[True], **kwargs) -> None: ... @overload - def drop_duplicates(self, *, inplace: Literal[False], **kwargs) -> "Table": - ... + def drop_duplicates(self, *, inplace: Literal[False], **kwargs) -> "Table": ... @overload - def drop_duplicates(self, **kwargs) -> "Table": - ... + def drop_duplicates(self, **kwargs) -> "Table": ... def drop_duplicates(self, *args, **kwargs) -> Optional["Table"]: return super().drop_duplicates(*args, **kwargs) @@ -823,16 +809,13 @@ def format( return t @overload - def dropna(self, *, inplace: Literal[True], **kwargs) -> None: - ... + def dropna(self, *, inplace: Literal[True], **kwargs) -> None: ... @overload - def dropna(self, *, inplace: Literal[False], **kwargs) -> "Table": - ... + def dropna(self, *, inplace: Literal[False], **kwargs) -> "Table": ... @overload - def dropna(self, **kwargs) -> "Table": - ... + def dropna(self, **kwargs) -> "Table": ... def dropna(self, *args, **kwargs) -> Optional["Table"]: tb = super().dropna(*args, **kwargs) @@ -1078,12 +1061,10 @@ def __init__(self, groupby: pd.core.groupby.DataFrameGroupBy, metadata: TableMet self._fields = fields @overload - def __getattr__(self, name: Literal["count", "size", "sum", "mean", "median"]) -> Callable[[], "Table"]: - ... + def __getattr__(self, name: Literal["count", "size", "sum", "mean", "median"]) -> Callable[[], "Table"]: ... @overload - def __getattr__(self, name: str) -> "VariableGroupBy": - ... + def __getattr__(self, name: str) -> "VariableGroupBy": ... def __getattr__(self, name: str) -> Union[Callable[..., "Table"], "VariableGroupBy"]: # Calling method on the groupby object @@ -1114,12 +1095,10 @@ def func(*args, **kwargs): return VariableGroupBy(getattr(self.groupby, name), name, self._fields[name], self.metadata) @overload - def __getitem__(self, key: str) -> "VariableGroupBy": - ... + def __getitem__(self, key: str) -> "VariableGroupBy": ... @overload - def __getitem__(self, key: list) -> "TableGroupBy": - ... + def __getitem__(self, key: list) -> "TableGroupBy": ... def __getitem__(self, key: Union[str, list]) -> Union["VariableGroupBy", "TableGroupBy"]: if isinstance(key, list):