-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Description
Create a python environment with python 3.10 and install from pypi
- pandas
- pandas-stubs
- numpy
- jinja2
- xarray
- pytest
- pyarrow
- matplotlib
Download the source directory of pandas-stubs 2.0.1.230501 here: https://github.com/pandas-dev/pandas-stubs/releases/tag/v2.0.1.230501 in either ZIP or tar.gz format
Extract the tests folder. Then do pyright tests . Using pyright basic type checking, pyright 1.1.308 reports no errors.
pyright 1.1.310 reports
c:\Code\Misc\pstubtst\tests\test_frame.py
c:\Code\Misc\pstubtst\tests\test_frame.py:1449:32 - error: Operator "+" not supported for types "TimestampSeries" and "Timedelta" (reportGeneralTypeIssues)
c:\Code\Misc\pstubtst\tests\test_frame.py:2101:16 - error: Expression of type "DataFrame" cannot be assigned to return type "MyDataFrame[int]"
"DataFrame" is incompatible with "MyDataFrame[int]" (reportGeneralTypeIssues)
c:\Code\Misc\pstubtst\tests\test_indexes.py
c:\Code\Misc\pstubtst\tests\test_indexes.py:771:23 - error: "assert_type" mismatch: expected "DatetimeIndex" but received "Index" (reportGeneralTypeIssues)
c:\Code\Misc\pstubtst\tests\test_indexes.py:772:23 - error: "assert_type" mismatch: expected "Timestamp" but received "Scalar" (reportGeneralTypeIssues)
c:\Code\Misc\pstubtst\tests\test_indexes.py:773:23 - error: "assert_type" mismatch: expected "DatetimeIndex" but received "Index" (reportGeneralTypeIssues)
c:\Code\Misc\pstubtst\tests\test_io.py
c:\Code\Misc\pstubtst\tests\test_io.py:880:9 - warning: Expression value is unused (reportUnusedExpression)
c:\Code\Misc\pstubtst\tests\test_pandas.py
c:\Code\Misc\pstubtst\tests\test_pandas.py:1906:40 - error: Cannot access member "month" for type "Index"
Member "month" is unknown (reportGeneralTypeIssues)
c:\Code\Misc\pstubtst\tests\test_pandas.py:1915:40 - error: Cannot access member "month" for type "Index"
Member "month" is unknown (reportGeneralTypeIssues)
c:\Code\Misc\pstubtst\tests\test_pandas.py:1924:77 - error: Cannot access member "month" for type "Index"
Member "month" is unknown (reportGeneralTypeIssues)
c:\Code\Misc\pstubtst\tests\test_pandas.py:1933:77 - error: Cannot access member "month" for type "Index"
Member "month" is unknown (reportGeneralTypeIssues)
c:\Code\Misc\pstubtst\tests\test_scalars.py
c:\Code\Misc\pstubtst\tests\test_scalars.py:549:23 - error: "assert_type" mismatch: expected "TimedeltaIndex" but received "Index" (reportGeneralTypeIssues)
c:\Code\Misc\pstubtst\tests\test_scalars.py:551:21 - error: Operator "+" not supported for types "Timedelta" and "Series[Unknown]" (reportGeneralTypeIssues)
c:\Code\Misc\pstubtst\tests\test_scalars.py:551:21 - error: "assert_type" mismatch: expected "TimedeltaSeries" but received "Unknown" (reportGeneralTypeIssues)
c:\Code\Misc\pstubtst\tests\test_scalars.py:583:23 - error: "assert_type" mismatch: expected "TimedeltaIndex" but received "Index" (reportGeneralTypeIssues)
c:\Code\Misc\pstubtst\tests\test_scalars.py:585:21 - error: "assert_type" mismatch: expected "TimedeltaSeries" but received "Series[Unknown]" (reportGeneralTypeIssues)
c:\Code\Misc\pstubtst\tests\test_scalars.py:616:23 - error: "assert_type" mismatch: expected "TimedeltaIndex" but received "Index" (reportGeneralTypeIssues)
c:\Code\Misc\pstubtst\tests\test_scalars.py:642:23 - error: "assert_type" mismatch: expected "TimedeltaIndex" but received "Index" (reportGeneralTypeIssues)
c:\Code\Misc\pstubtst\tests\test_scalars.py:644:21 - error: Operator "-" not supported for types "Series[Unknown]" and "Timedelta" (reportGeneralTypeIssues)
c:\Code\Misc\pstubtst\tests\test_scalars.py:644:21 - error: "assert_type" mismatch: expected "TimedeltaSeries" but received "Unknown" (reportGeneralTypeIssues)
c:\Code\Misc\pstubtst\tests\test_scalars.py:1000:21 - error: "assert_type" mismatch: expected "np_ndarray_bool" but received "Literal[False]" (reportGeneralTypeIssues)
c:\Code\Misc\pstubtst\tests\test_scalars.py:1003:21 - error: "assert_type" mismatch: expected "np_ndarray_bool" but received "Literal[True]" (reportGeneralTypeIssues)
c:\Code\Misc\pstubtst\tests\test_scalars.py:1005:27 - error: Cannot access member "all" for type "bool"
Member "all" is unknown (reportGeneralTypeIssues)
c:\Code\Misc\pstubtst\tests\test_scalars.py:1181:23 - error: "assert_type" mismatch: expected "TimedeltaSeries" but received "Series[Unknown]" (reportGeneralTypeIssues)
c:\Code\Misc\pstubtst\tests\test_scalars.py:1193:23 - error: "assert_type" mismatch: expected "DatetimeIndex" but received "Index" (reportGeneralTypeIssues)
c:\Code\Misc\pstubtst\tests\test_scalars.py:1194:23 - error: "assert_type" mismatch: expected "DatetimeIndex" but received "Index" (reportGeneralTypeIssues)
c:\Code\Misc\pstubtst\tests\test_scalars.py:1197:21 - error: Operator "+" not supported for types "Timestamp" and "Series[Unknown]" (reportGeneralTypeIssues)
c:\Code\Misc\pstubtst\tests\test_scalars.py:1197:21 - error: "assert_type" mismatch: expected "TimestampSeries" but received "Unknown" (reportGeneralTypeIssues)
c:\Code\Misc\pstubtst\tests\test_scalars.py:1221:23 - error: "assert_type" mismatch: expected "DatetimeIndex" but received "Index" (reportGeneralTypeIssues)
c:\Code\Misc\pstubtst\tests\test_scalars.py:1223:21 - error: Operator "-" not supported for types "Timestamp" and "Series[Unknown]" (reportGeneralTypeIssues)
c:\Code\Misc\pstubtst\tests\test_scalars.py:1223:21 - error: "assert_type" mismatch: expected "TimestampSeries" but received "Unknown" (reportGeneralTypeIssues)
c:\Code\Misc\pstubtst\tests\test_scalars.py:1246:23 - error: "assert_type" mismatch: expected "TimestampSeries" but received "Series[Unknown]" (reportGeneralTypeIssues)
c:\Code\Misc\pstubtst\tests\test_scalars.py:1358:21 - error: "assert_type" mismatch: expected "Series[bool]" but received "Literal[False]" (reportGeneralTypeIssues)
c:\Code\Misc\pstubtst\tests\test_scalars.py:1361:21 - error: "assert_type" mismatch: expected "Series[bool]" but received "Literal[True]" (reportGeneralTypeIssues)
c:\Code\Misc\pstubtst\tests\test_scalars.py:1363:27 - error: Cannot access member "all" for type "bool"
Member "all" is unknown (reportGeneralTypeIssues)
c:\Code\Misc\pstubtst\tests\test_series.py
c:\Code\Misc\pstubtst\tests\test_series.py:1476:16 - error: Expression of type "Series[Unknown]" cannot be assigned to return type "MySeries[float]"
"Series[Unknown]" is incompatible with "MySeries[float]" (reportGeneralTypeIssues)
c:\Code\Misc\pstubtst\tests\test_timefuncs.py
c:\Code\Misc\pstubtst\tests\test_timefuncs.py:448:25 - error: Cannot access member "month" for type "Index"
Member "month" is unknown (reportGeneralTypeIssues)
c:\Code\Misc\pstubtst\tests\test_timefuncs.py:448:23 - error: "assert_type" mismatch: expected "_IntIndexType" but received "Unknown" (reportGeneralTypeIssues)
I don't understand why upgrading pyright picked up all these issues. Some may be correct, but others don't seem to me. I've only looked at a few of them. The following ones don't make sense:
c:\Code\Misc\pstubtst\tests\test_frame.py:2101:16 - error: Expression of type "DataFrame" cannot be assigned to return type "MyDataFrame[int]"
Corresponding code to the above:
T = TypeVar("T")
class MyDataFrame(pd.DataFrame, Generic[T]):
...
def func() -> MyDataFrame[int]:
return MyDataFrame[int]({"foo": [1, 2, 3]}) # pyright is reporting error hereAbove doesn't make sense because we are returning the MyDataFrame class, so why is pyright thinking that it is a DataFrame??
c:\Code\Misc\pstubtst\tests\test_indexes.py:771:23 - error: "assert_type" mismatch: expected "DatetimeIndex" but received "Index" (reportGeneralTypeIssues)
c:\Code\Misc\pstubtst\tests\test_indexes.py:772:23 - error: "assert_type" mismatch: expected "Timestamp" but received "Scalar" (reportGeneralTypeIssues)
c:\Code\Misc\pstubtst\tests\test_indexes.py:773:23 - error: "assert_type" mismatch: expected "DatetimeIndex" but received "Index" (reportGeneralTypeIssues)
idt = pd.DatetimeIndex(["2022-08-14", "2022-08-20", "2022-08-24"])
check(assert_type(idt, pd.DatetimeIndex), pd.DatetimeIndex, pd.Timestamp) # pyright reporting error here
check(assert_type(idt[0], pd.Timestamp), pd.Timestamp) # pyright reporting error here
check(assert_type(idt[[0, 2]], pd.DatetimeIndex), pd.DatetimeIndex, pd.Timestamp) # pyright reporting error hereFirst one doesn't make sense because we are returning a DatetimeIndex class, so why does pyright think it is Index.
Second one and third one happen because of the error on the first one.
Those are the ones I had the patience to analyze, but your help in indicating what has changed in pyright that has created these new errors would be appreciated.
One other note - there are more errors with 1.1.309 (171 of them) than with 1.1.310 (36 of them) so that leaves me to believe that a bug was introduced in pyright.