Skip to content

Commit

Permalink
make GenericDtype TypeVar bound union of supported types (#960)
Browse files Browse the repository at this point in the history
Signed-off-by: Niels Bantilan <niels.bantilan@gmail.com>

Signed-off-by: Niels Bantilan <niels.bantilan@gmail.com>
  • Loading branch information
cosmicBboy committed Oct 10, 2022
1 parent 1cc4f86 commit 5fd3e55
Showing 1 changed file with 76 additions and 74 deletions.
150 changes: 76 additions & 74 deletions pandera/typing/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# pylint:disable=abstract-method,disable=too-many-ancestors

import inspect
from typing import TYPE_CHECKING, Any, Generic, Optional, Type, TypeVar
from typing import TYPE_CHECKING, Any, Generic, Optional, Type, TypeVar, Union

import pandas as pd
import typing_inspect
Expand Down Expand Up @@ -53,83 +53,85 @@
if GEOPANDAS_INSTALLED:
GenericDtype = TypeVar( # type: ignore
"GenericDtype",
bool,
int,
str,
float,
pd.core.dtypes.base.ExtensionDtype,
Bool,
Date,
DateTime,
Decimal,
Timedelta,
Category,
Float,
Float16,
Float32,
Float64,
Int,
Int8,
Int16,
Int32,
Int64,
UInt8,
UInt16,
UInt32,
UInt64,
INT8,
INT16,
INT32,
INT64,
UINT8,
UINT16,
UINT32,
UINT64,
Object,
String,
STRING,
Geometry,
covariant=True,
bound=Union[
bool,
int,
str,
float,
pd.core.dtypes.base.ExtensionDtype,
Bool,
Date,
DateTime,
Decimal,
Timedelta,
Category,
Float,
Float16,
Float32,
Float64,
Int,
Int8,
Int16,
Int32,
Int64,
UInt8,
UInt16,
UInt32,
UInt64,
INT8,
INT16,
INT32,
INT64,
UINT8,
UINT16,
UINT32,
UINT64,
Object,
String,
STRING,
Geometry,
],
)
else:
GenericDtype = TypeVar( # type: ignore
"GenericDtype",
bool,
int,
str,
float,
pd.core.dtypes.base.ExtensionDtype,
Bool,
Date,
DateTime,
Decimal,
Timedelta,
Category,
Float,
Float16,
Float32,
Float64,
Int,
Int8,
Int16,
Int32,
Int64,
UInt8,
UInt16,
UInt32,
UInt64,
INT8,
INT16,
INT32,
INT64,
UINT8,
UINT16,
UINT32,
UINT64,
Object,
String,
STRING,
covariant=True,
bound=Union[
bool,
int,
str,
float,
pd.core.dtypes.base.ExtensionDtype,
Bool,
Date,
DateTime,
Decimal,
Timedelta,
Category,
Float,
Float16,
Float32,
Float64,
Int,
Int8,
Int16,
Int32,
Int64,
UInt8,
UInt16,
UInt32,
UInt64,
INT8,
INT16,
INT32,
INT64,
UINT8,
UINT16,
UINT32,
UINT64,
Object,
String,
STRING,
],
)

Schema = TypeVar("Schema", bound="SchemaModel") # type: ignore
Expand Down

0 comments on commit 5fd3e55

Please sign in to comment.