Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed types for 3.8 #7

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions redframes/types.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
from __future__ import annotations

import datetime
from typing import Any, Callable, Literal, Union
from typing import Any, Callable, Literal, Union, List

import numpy as np # pyright: ignore[reportMissingImports]
import pandas as pd # pyright: ignore[reportMissingImports]
import pandas.core.groupby.generic as pg # pyright: ignore[reportMissingImports]

Value = Any
Values = list[Value]
Values = List[Value]
OldValue = Value
NewValue = Value
Column = str
Columns = list[Column]
Columns = List[Column]
LazyColumns = Union[Column, Columns]
OldColumn = Column
NewColumn = Column
Expand Down
4 changes: 3 additions & 1 deletion redframes/verbs/rename.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
from typing import Dict

from ..checks import _check_type, _check_values
from ..types import NewColumn, OldColumn, PandasDataFrame


def rename(df: PandasDataFrame, columns: dict[OldColumn, NewColumn]) -> PandasDataFrame:
def rename(df: PandasDataFrame, columns: Dict[OldColumn, NewColumn]) -> PandasDataFrame:
_check_type(columns, dict)
cv = columns.values()
_check_values(cv, str)
Expand Down
4 changes: 3 additions & 1 deletion redframes/verbs/replace.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
from typing import Dict

from ..checks import _check_type
from ..types import Column, NewValue, OldValue, PandasDataFrame


def replace(
df: PandasDataFrame, over: dict[Column, dict[OldValue, NewValue]]
df: PandasDataFrame, over: Dict[Column, Dict[OldValue, NewValue]]
) -> PandasDataFrame:
_check_type(over, dict)
bad_columns = list(set(over.keys()) - set(df.columns))
Expand Down