-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
CLN: Fixing mypy errors in pandas/conftest.py #29046
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
Changes from 7 commits
bfc175e
6408388
f4afbb2
ce2d9b7
96a09ec
f07b7a0
77543f2
50dadb2
5bce559
1856a58
4be05dc
3fbf980
05bb32b
4b8b565
a920f28
dd279e9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -1,5 +1,5 @@ | ||||||
from pathlib import Path | ||||||
from typing import IO, TYPE_CHECKING, AnyStr, Iterable, Optional, TypeVar, Union | ||||||
from typing import IO, TYPE_CHECKING, AnyStr, Iterable, Optional, TypeVar, Union, Type | ||||||
|
||||||
import numpy as np | ||||||
|
||||||
|
@@ -18,7 +18,7 @@ | |||||
AnyArrayLike = TypeVar("AnyArrayLike", "ExtensionArray", "Index", "Series", np.ndarray) | ||||||
ArrayLike = TypeVar("ArrayLike", "ExtensionArray", np.ndarray) | ||||||
DatetimeLikeScalar = TypeVar("DatetimeLikeScalar", "Period", "Timestamp", "Timedelta") | ||||||
Dtype = Union[str, np.dtype, "ExtensionDtype"] | ||||||
Dtype = Type[Union[str, float, bool, np.dtype, "ExtensionDtype"]] | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Somewhat more complicated but the To illustrate: >>> pd.Series(range(1), dtype=pd.Int64Dtype) # Not what you would expect
0 0
dtype: object
>>> pd.Series(range(1), dtype=pd.Int64Dtype()) # This instance works though
0 0
dtype: object
>>> pd.Series(range(1), dtype=int) # contrast to the builtin, which uses Type[int]
0 0
dtype: int64 cc @TomAugspurger in case there's something I'm missing with the ExtensionDtype Also @simonjayhawkins do you mind if we include There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
should probably raise. I don't think we can automatically make that work since we have parametrized dtypes. Not sure what that does to the type hint. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
no problem. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👋 Sorry for the silence on my end. I'm picking this up again now. I didn't follow your comment, @WillAyd (though I committed your suggestion - hence the |
||||||
FilePathOrBuffer = Union[str, Path, IO[AnyStr]] | ||||||
|
||||||
FrameOrSeries = TypeVar("FrameOrSeries", bound="NDFrame") | ||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
from decimal import Decimal | ||
import operator | ||
import os | ||
from typing import List | ||
|
||
from dateutil.tz import tzlocal, tzutc | ||
import hypothesis | ||
|
@@ -11,6 +12,7 @@ | |
from pytz import FixedOffset, utc | ||
|
||
import pandas.util._test_decorators as td | ||
from pandas._typing import Dtype | ||
|
||
import pandas as pd | ||
from pandas import DataFrame | ||
|
@@ -481,14 +483,14 @@ def tz_aware_fixture(request): | |
|
||
UNSIGNED_INT_DTYPES = ["uint8", "uint16", "uint32", "uint64"] | ||
UNSIGNED_EA_INT_DTYPES = ["UInt8", "UInt16", "UInt32", "UInt64"] | ||
SIGNED_INT_DTYPES = [int, "int8", "int16", "int32", "int64"] | ||
SIGNED_INT_DTYPES = [int, "int8", "int16", "int32", "int64"] # type: List[Dtype] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. will need to change to py3.6 syntax. |
||
SIGNED_EA_INT_DTYPES = ["Int8", "Int16", "Int32", "Int64"] | ||
ALL_INT_DTYPES = UNSIGNED_INT_DTYPES + SIGNED_INT_DTYPES | ||
ALL_EA_INT_DTYPES = UNSIGNED_EA_INT_DTYPES + SIGNED_EA_INT_DTYPES | ||
|
||
FLOAT_DTYPES = [float, "float32", "float64"] | ||
COMPLEX_DTYPES = [complex, "complex64", "complex128"] | ||
STRING_DTYPES = [str, "str", "U"] | ||
FLOAT_DTYPES = [float, "float32", "float64"] # type: List[Dtype] | ||
COMPLEX_DTYPES = [complex, "complex64", "complex128"] # type: List[Dtype] | ||
STRING_DTYPES = [str, "str", "U"] # type: List[Dtype] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same |
||
|
||
DATETIME64_DTYPES = ["datetime64[ns]", "M8[ns]"] | ||
TIMEDELTA64_DTYPES = ["timedelta64[ns]", "m8[ns]"] | ||
|
Uh oh!
There was an error while loading. Please reload this page.