diff --git a/.github/workflows/code-checks.yml b/.github/workflows/code-checks.yml index 96088547634c5..e8f54b33a92c0 100644 --- a/.github/workflows/code-checks.yml +++ b/.github/workflows/code-checks.yml @@ -157,3 +157,32 @@ jobs: - name: Build image run: docker build --pull --no-cache --tag pandas-dev-env . + + requirements-dev-text-installable: + name: Test install requirements-dev.txt + runs-on: ubuntu-latest + + concurrency: + # https://github.community/t/concurrecy-not-work-for-push/183068/7 + group: ${{ github.event_name == 'push' && github.run_number || github.ref }}-requirements-dev-text-installable + cancel-in-progress: true + + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Setup Python + id: setup_python + uses: actions/setup-python@v3 + with: + python-version: '3.8' + cache: 'pip' + cache-dependency-path: 'requirements-dev.txt' + + - name: Install requirements-dev.txt + run: pip install -r requirements-dev.txt + + - name: Check Pip Cache Hit + run: echo ${{ steps.setup_python.outputs.cache-hit }} diff --git a/.github/workflows/posix.yml b/.github/workflows/ubuntu.yml similarity index 97% rename from .github/workflows/posix.yml rename to .github/workflows/ubuntu.yml index 831bbd8bb3233..961ba57d36b94 100644 --- a/.github/workflows/posix.yml +++ b/.github/workflows/ubuntu.yml @@ -1,4 +1,4 @@ -name: Posix +name: Ubuntu on: push: @@ -145,7 +145,7 @@ jobs: - name: Extra installs # xsel for clipboard tests - run: sudo apt-get update && sudo apt-get install -y libc6-dev-i386 xsel ${{ env.EXTRA_APT }} + run: sudo apt-get update && sudo apt-get install -y xsel ${{ env.EXTRA_APT }} - name: Set up Conda uses: ./.github/actions/setup-conda diff --git a/ci/deps/actions-310.yaml b/ci/deps/actions-310.yaml index d17d29ef38e7f..73700c0da0d47 100644 --- a/ci/deps/actions-310.yaml +++ b/ci/deps/actions-310.yaml @@ -31,8 +31,7 @@ dependencies: - jinja2 - lxml - matplotlib - # TODO: uncomment after numba supports py310 - #- numba + - numba - numexpr - openpyxl - odfpy diff --git a/environment.yml b/environment.yml index 1f1583354339c..98631d8485736 100644 --- a/environment.yml +++ b/environment.yml @@ -1,21 +1,85 @@ +# Local development dependencies including docs building, website upload, ASV benchmark name: pandas-dev channels: - conda-forge dependencies: - # required - - numpy>=1.19.5 - python=3.8 - - python-dateutil>=2.8.1 + + # test dependencies + - cython=0.29.30 + - pytest>=6.0 + - pytest-cov + - pytest-xdist>=1.31 + - psutil + - pytest-asyncio>=0.17 + - boto3 + + # required dependencies + - python-dateutil + - numpy - pytz + # optional dependencies + - beautifulsoup4 + - blosc + - brotlipy + - bottleneck + - fastparquet + - fsspec + - html5lib + - hypothesis + - gcsfs + - jinja2 + - lxml + - matplotlib + - numba>=0.53.1 + - numexpr>=2.8.0 # pin for "Run checks on imported code" job + - openpyxl + - odfpy + - pandas-gbq + - psycopg2 + - pyarrow + - pymysql + - pyreadstat + - pytables + - python-snappy + - pyxlsb + - s3fs + - scipy + - sqlalchemy + - tabulate + - xarray + - xlrd + - xlsxwriter + - xlwt + - zstandard + + # downstream packages + - aiobotocore<2.0.0 # GH#44311 pinned to fix docbuild + - botocore + - cftime + - dask + - ipython + - geopandas-base + - seaborn + - scikit-learn + - statsmodels + - coverage + - pandas-datareader + - pyyaml + - py + - pytorch + + # local testing dependencies + - moto + - flask + # benchmarks - asv - # building # The compiler packages are meta-packages and install the correct compiler (activation) packages on the respective platforms. - c-compiler - cxx-compiler - - cython>=0.29.30 # code checks - black=22.3.0 @@ -32,10 +96,11 @@ dependencies: # documentation - gitpython # obtain contributors from git for whatsnew - gitdb + - natsort # DataFrame.sort_values doctest - numpydoc - pandas-dev-flaker=0.5.0 - pydata-sphinx-theme=0.8.0 - - pytest-cython + - pytest-cython # doctest - sphinx - sphinx-panels - types-python-dateutil @@ -47,77 +112,14 @@ dependencies: - nbconvert>=6.4.5 - nbsphinx - pandoc - - # Dask and its dependencies (that dont install with dask) - - dask-core - - toolz>=0.7.3 - - partd>=0.3.10 - - cloudpickle>=0.2.1 - - # web (jinja2 is also needed, but it's also an optional pandas dependency) - - markdown - - feedparser - - pyyaml - - requests - - # testing - - boto3 - - botocore>=1.11 - - hypothesis>=5.5.3 - - moto # mock S3 - - flask - - pytest>=6.0 - - pytest-cov - - pytest-xdist>=1.31 - - pytest-asyncio>=0.17 - - pytest-instafail - - # downstream tests - - seaborn - - statsmodels - - # unused (required indirectly may be?) - ipywidgets - nbformat - notebook>=6.0.3 - - # optional - - blosc - - bottleneck>=1.3.1 - ipykernel - - ipython>=7.11.1 - - jinja2 # pandas.Styler - - matplotlib>=3.3.2 # pandas.plotting, Series.plot, DataFrame.plot - - numexpr>=2.7.1 - - scipy>=1.4.1 - - numba>=0.50.1 - - # optional for io - # --------------- - # pd.read_html - - beautifulsoup4>=4.8.2 - - html5lib - - lxml - - # pd.read_excel, DataFrame.to_excel, pd.ExcelWriter, pd.ExcelFile - - openpyxl - - xlrd - - xlsxwriter - - xlwt - - odfpy - - - fastparquet>=0.4.0 # pandas.read_parquet, DataFrame.to_parquet - - pyarrow>2.0.1 # pandas.read_parquet, DataFrame.to_parquet, pandas.read_feather, DataFrame.to_feather - - python-snappy # required by pyarrow - - pytables>=3.6.1 # pandas.read_hdf, DataFrame.to_hdf - - s3fs>=0.4.0 # file IO when using 's3://...' path - - aiobotocore<2.0.0 # GH#44311 pinned to fix docbuild - - fsspec>=0.7.4 # for generic remote file operations - - gcsfs>=0.6.0 # file IO when using 'gcs://...' path - - sqlalchemy # pandas.read_sql, DataFrame.to_sql - - xarray # DataFrame.to_xarray - - cftime # Needed for downstream xarray.CFTimeIndex test - - pyreadstat # pandas.read_spss - - tabulate>=0.8.3 # DataFrame.to_markdown - - natsort # DataFrame.sort_values + # web + - jinja2 # in optional dependencies, but documented here as needed + - markdown + - feedparser + - pyyaml + - requests diff --git a/pandas/core/algorithms.py b/pandas/core/algorithms.py index f1fbdafa04288..72f6a7bce4d0e 100644 --- a/pandas/core/algorithms.py +++ b/pandas/core/algorithms.py @@ -1064,12 +1064,7 @@ def checked_add_with_arr( elif arr_mask is not None: not_nan = np.logical_not(arr_mask) elif b_mask is not None: - # Argument 1 to "__call__" of "_UFunc_Nin1_Nout1" has incompatible type - # "Optional[ndarray[Any, dtype[bool_]]]"; expected - # "Union[_SupportsArray[dtype[Any]], _NestedSequence[_SupportsArray[dtype[An - # y]]], bool, int, float, complex, str, bytes, _NestedSequence[Union[bool, - # int, float, complex, str, bytes]]]" [arg-type] - not_nan = np.logical_not(b2_mask) # type: ignore[arg-type] + not_nan = np.logical_not(b2_mask) else: not_nan = np.empty(arr.shape, dtype=bool) not_nan.fill(True) diff --git a/pandas/core/array_algos/quantile.py b/pandas/core/array_algos/quantile.py index 78e12fb3995fd..de7945a96c69e 100644 --- a/pandas/core/array_algos/quantile.py +++ b/pandas/core/array_algos/quantile.py @@ -143,10 +143,7 @@ def _nanpercentile_1d( return np.percentile( values, qs, - # error: No overload variant of "percentile" matches argument types - # "ndarray[Any, Any]", "ndarray[Any, dtype[floating[_64Bit]]]", - # "int", "Dict[str, str]" - **{np_percentile_argname: interpolation}, # type: ignore[call-overload] + **{np_percentile_argname: interpolation}, ) @@ -215,8 +212,5 @@ def _nanpercentile( values, qs, axis=1, - # error: No overload variant of "percentile" matches argument types - # "ndarray[Any, Any]", "ndarray[Any, dtype[floating[_64Bit]]]", - # "int", "Dict[str, str]" - **{np_percentile_argname: interpolation}, # type: ignore[call-overload] + **{np_percentile_argname: interpolation}, ) diff --git a/pandas/core/arraylike.py b/pandas/core/arraylike.py index b6e9bf1420b21..e241fc119ae02 100644 --- a/pandas/core/arraylike.py +++ b/pandas/core/arraylike.py @@ -265,7 +265,11 @@ def array_ufunc(self, ufunc: np.ufunc, method: str, *inputs: Any, **kwargs: Any) return result # Determine if we should defer. - no_defer = (np.ndarray.__array_ufunc__, cls.__array_ufunc__) + # error: "Type[ndarray[Any, Any]]" has no attribute "__array_ufunc__" + no_defer = ( + np.ndarray.__array_ufunc__, # type: ignore[attr-defined] + cls.__array_ufunc__, + ) for item in inputs: higher_priority = ( diff --git a/pandas/core/arrays/arrow/array.py b/pandas/core/arrays/arrow/array.py index 1f35013075751..c1380fcdbba06 100644 --- a/pandas/core/arrays/arrow/array.py +++ b/pandas/core/arrays/arrow/array.py @@ -496,7 +496,7 @@ def _indexing_key_to_indices( if isinstance(key, slice): indices = np.arange(n)[key] elif is_integer(key): - indices = np.arange(n)[[key]] # type: ignore[index] + indices = np.arange(n)[[key]] elif is_bool_dtype(key): key = np.asarray(key) if len(key) != n: diff --git a/pandas/core/arrays/datetimes.py b/pandas/core/arrays/datetimes.py index 5f060542526d3..97dae33bc0311 100644 --- a/pandas/core/arrays/datetimes.py +++ b/pandas/core/arrays/datetimes.py @@ -487,7 +487,10 @@ def _generate_range( np.linspace(0, end.value - start.value, periods, dtype="int64") + start.value ) - if i8values.dtype != "i8": + # error: Non-overlapping equality check + # (left operand type: "dtype[signedinteger[Any]]", + # right operand type: "Literal['i8']") + if i8values.dtype != "i8": # type: ignore[comparison-overlap] # 2022-01-09 I (brock) am not sure if it is possible for this # to overflow and cast to e.g. f8, but if it does we need to cast i8values = i8values.astype("i8") diff --git a/pandas/core/arrays/interval.py b/pandas/core/arrays/interval.py index eecf1dff4dd48..69814863afefc 100644 --- a/pandas/core/arrays/interval.py +++ b/pandas/core/arrays/interval.py @@ -687,7 +687,21 @@ def __getitem__( if is_scalar(left) and isna(left): return self._fill_value return Interval(left, right, inclusive=self.inclusive) - if np.ndim(left) > 1: + # error: Argument 1 to "ndim" has incompatible type + # "Union[ndarray[Any, Any], ExtensionArray]"; expected + # "Union[Sequence[Sequence[Sequence[Sequence[Sequence[Any]]]]], + # Union[Union[_SupportsArray[dtype[Any]], + # Sequence[_SupportsArray[dtype[Any]]], + # Sequence[Sequence[_SupportsArray[dtype[Any]]]], + # Sequence[Sequence[Sequence[_SupportsArray[dtype[Any]]]]], + # Sequence[Sequence[Sequence[Sequence[_SupportsArray[dtype[Any]]]]]]], + # Union[bool, int, float, complex, str, bytes, + # Sequence[Union[bool, int, float, complex, str, bytes]], + # Sequence[Sequence[Union[bool, int, float, complex, str, bytes]]], + # Sequence[Sequence[Sequence[Union[bool, int, float, complex, str, bytes]]]], + # Sequence[Sequence[Sequence[Sequence[Union[bool, int, float, + # complex, str, bytes]]]]]]]]" + if np.ndim(left) > 1: # type: ignore[arg-type] # GH#30588 multi-dimensional indexer disallowed raise ValueError("multi-dimensional indexing not allowed") return self._shallow_copy(left, right) @@ -1665,13 +1679,7 @@ def isin(self, values) -> np.ndarray: # complex128 ndarray is much more performant. left = self._combined.view("complex128") right = values._combined.view("complex128") - # Argument 1 to "in1d" has incompatible type "Union[ExtensionArray, - # ndarray[Any, Any], ndarray[Any, dtype[Any]]]"; expected - # "Union[_SupportsArray[dtype[Any]], _NestedSequence[_SupportsArray[ - # dtype[Any]]], bool, int, float, complex, str, bytes, - # _NestedSequence[Union[bool, int, float, complex, str, bytes]]]" - # [arg-type] - return np.in1d(left, right) # type: ignore[arg-type] + return np.in1d(left, right) elif needs_i8_conversion(self.left.dtype) ^ needs_i8_conversion( values.left.dtype diff --git a/pandas/core/arrays/masked.py b/pandas/core/arrays/masked.py index 3616e3512c6fe..d2c082c472e5e 100644 --- a/pandas/core/arrays/masked.py +++ b/pandas/core/arrays/masked.py @@ -110,7 +110,13 @@ def __init__( self, values: np.ndarray, mask: npt.NDArray[np.bool_], copy: bool = False ) -> None: # values is supposed to already be validated in the subclass - if not (isinstance(mask, np.ndarray) and mask.dtype == np.bool_): + if not ( + isinstance(mask, np.ndarray) + and + # error: Non-overlapping equality check + # (left operand type: "dtype[bool_]", right operand type: "Type[bool_]") + mask.dtype == np.bool_ # type: ignore[comparison-overlap] + ): raise TypeError( "mask should be boolean numpy array. Use " "the 'pd.array' function instead" @@ -1151,11 +1157,7 @@ def any(self, *, skipna: bool = True, **kwargs): nv.validate_any((), kwargs) values = self._data.copy() - # Argument 3 to "putmask" has incompatible type "object"; expected - # "Union[_SupportsArray[dtype[Any]], _NestedSequence[ - # _SupportsArray[dtype[Any]]], bool, int, float, complex, str, bytes, _Nested - # Sequence[Union[bool, int, float, complex, str, bytes]]]" [arg-type] - np.putmask(values, self._mask, self._falsey_value) # type: ignore[arg-type] + np.putmask(values, self._mask, self._falsey_value) result = values.any() if skipna: return result @@ -1231,11 +1233,7 @@ def all(self, *, skipna: bool = True, **kwargs): nv.validate_all((), kwargs) values = self._data.copy() - # Argument 3 to "putmask" has incompatible type "object"; expected - # "Union[_SupportsArray[dtype[Any]], _NestedSequence[ - # _SupportsArray[dtype[Any]]], bool, int, float, complex, str, bytes, _Neste - # dSequence[Union[bool, int, float, complex, str, bytes]]]" [arg-type] - np.putmask(values, self._mask, self._truthy_value) # type: ignore[arg-type] + np.putmask(values, self._mask, self._truthy_value) result = values.all() if skipna: diff --git a/pandas/core/arrays/sparse/array.py b/pandas/core/arrays/sparse/array.py index 427bf50ca7424..8215abf294221 100644 --- a/pandas/core/arrays/sparse/array.py +++ b/pandas/core/arrays/sparse/array.py @@ -944,15 +944,7 @@ def __getitem__( if is_integer(key): return self._get_val_at(key) elif isinstance(key, tuple): - # Invalid index type "Tuple[Union[int, ellipsis], ...]" for - # "ndarray[Any, Any]"; expected type "Union[SupportsIndex, - # _SupportsArray[dtype[Union[bool_, integer[Any]]]], _NestedSequence[_Su - # pportsArray[dtype[Union[bool_, integer[Any]]]]], - # _NestedSequence[Union[bool, int]], Tuple[Union[SupportsIndex, - # _SupportsArray[dtype[Union[bool_, integer[Any]]]], - # _NestedSequence[_SupportsArray[dtype[Union[bool_, integer[Any]]]]], _N - # estedSequence[Union[bool, int]]], ...]]" [index] - data_slice = self.to_dense()[key] # type: ignore[index] + data_slice = self.to_dense()[key] elif isinstance(key, slice): # Avoid densifying when handling contiguous slices @@ -1192,9 +1184,7 @@ def _concat_same_type( data = np.concatenate(values) indices_arr = np.concatenate(indices) - # Argument 2 to "IntIndex" has incompatible type "ndarray[Any, - # dtype[signedinteger[_32Bit]]]"; expected "Sequence[int]" - sp_index = IntIndex(length, indices_arr) # type: ignore[arg-type] + sp_index = IntIndex(length, indices_arr) else: # when concatenating block indices, we don't claim that you'll @@ -1384,8 +1374,7 @@ def __setstate__(self, state): if isinstance(state, tuple): # Compat for pandas < 0.24.0 nd_state, (fill_value, sp_index) = state - # Need type annotation for "sparse_values" [var-annotated] - sparse_values = np.array([]) # type: ignore[var-annotated] + sparse_values = np.array([]) sparse_values.__setstate__(nd_state) self._sparse_values = sparse_values diff --git a/pandas/core/dtypes/astype.py b/pandas/core/dtypes/astype.py index 8d1427976276c..7dc2c81746454 100644 --- a/pandas/core/dtypes/astype.py +++ b/pandas/core/dtypes/astype.py @@ -113,7 +113,9 @@ def astype_nansafe( ).reshape(shape) elif is_datetime64_dtype(arr.dtype): - if dtype == np.int64: + # error: Non-overlapping equality check (left + # operand type: "dtype[Any]", right operand type: "Type[signedinteger[Any]]") + if dtype == np.int64: # type: ignore[comparison-overlap] if isna(arr).any(): raise ValueError("Cannot convert NaT values to integer") return arr.view(dtype) @@ -125,7 +127,9 @@ def astype_nansafe( raise TypeError(f"cannot astype a datetimelike from [{arr.dtype}] to [{dtype}]") elif is_timedelta64_dtype(arr.dtype): - if dtype == np.int64: + # error: Non-overlapping equality check (left + # operand type: "dtype[Any]", right operand type: "Type[signedinteger[Any]]") + if dtype == np.int64: # type: ignore[comparison-overlap] if isna(arr).any(): raise ValueError("Cannot convert NaT values to integer") return arr.view(dtype) diff --git a/pandas/core/dtypes/cast.py b/pandas/core/dtypes/cast.py index ed3f9ee525c9e..27cf2e5e7ea58 100644 --- a/pandas/core/dtypes/cast.py +++ b/pandas/core/dtypes/cast.py @@ -305,7 +305,7 @@ def maybe_downcast_to_dtype(result: ArrayLike, dtype: str | np.dtype) -> ArrayLi result = cast(np.ndarray, result) result = array_to_timedelta64(result) - elif dtype == "M8[ns]" and result.dtype == _dtype_obj: + elif dtype == np.dtype("M8[ns]") and result.dtype == _dtype_obj: return np.asarray(maybe_cast_to_datetime(result, dtype=dtype)) return result diff --git a/pandas/core/dtypes/common.py b/pandas/core/dtypes/common.py index a192337daf59b..bdbad2560b2d7 100644 --- a/pandas/core/dtypes/common.py +++ b/pandas/core/dtypes/common.py @@ -534,7 +534,9 @@ def is_string_or_object_np_dtype(dtype: np.dtype) -> bool: """ Faster alternative to is_string_dtype, assumes we have a np.dtype object. """ - return dtype == object or dtype.kind in "SU" + # error: Non-overlapping equality check (left operand type: + # "dtype[Any]", right operand type: "Type[object]") + return dtype == object or dtype.kind in "SU" # type: ignore[comparison-overlap] def is_string_dtype(arr_or_dtype) -> bool: diff --git a/pandas/core/exchange/buffer.py b/pandas/core/exchange/buffer.py index 098c596bff4cd..65f2ac6dabef5 100644 --- a/pandas/core/exchange/buffer.py +++ b/pandas/core/exchange/buffer.py @@ -57,7 +57,8 @@ def __dlpack__(self): Represent this structure as DLPack interface. """ if _NUMPY_HAS_DLPACK: - return self._x.__dlpack__() + # error: "ndarray[Any, Any]" has no attribute "__dlpack__" + return self._x.__dlpack__() # type: ignore[attr-defined] raise NotImplementedError("__dlpack__") def __dlpack_device__(self) -> Tuple[DlpackDeviceType, Optional[int]]: diff --git a/pandas/core/frame.py b/pandas/core/frame.py index 8711d53353185..2006aba85cb24 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -2481,9 +2481,7 @@ def to_records( if dtype_mapping is None: formats.append(v.dtype) elif isinstance(dtype_mapping, (type, np.dtype, str)): - # Argument 1 to "append" of "list" has incompatible type - # "Union[type, dtype[Any], str]"; expected "dtype[_SCT]" [arg-type] - formats.append(dtype_mapping) # type: ignore[arg-type] + formats.append(dtype_mapping) else: element = "row" if i < index_len else "column" msg = f"Invalid dtype {dtype_mapping} specified for {element} {name}" diff --git a/pandas/core/groupby/ops.py b/pandas/core/groupby/ops.py index 7f74c60c8e534..d056b4b03d904 100644 --- a/pandas/core/groupby/ops.py +++ b/pandas/core/groupby/ops.py @@ -171,7 +171,7 @@ def _get_cython_function( f = getattr(libgroupby, ftype) if is_numeric: return f - elif dtype == object: + elif dtype == np.dtype(object): if how in ["median", "cumprod"]: # no fused types -> no __signatures__ raise NotImplementedError( diff --git a/pandas/core/indexes/base.py b/pandas/core/indexes/base.py index 01bbc424c3764..7e6233d247251 100644 --- a/pandas/core/indexes/base.py +++ b/pandas/core/indexes/base.py @@ -4834,12 +4834,7 @@ def _join_non_unique( right = other._values.take(right_idx) if isinstance(join_array, np.ndarray): - # Argument 3 to "putmask" has incompatible type "Union[ExtensionArray, - # ndarray[Any, Any]]"; expected "Union[_SupportsArray[dtype[Any]], - # _NestedSequence[_SupportsArray[dtype[Any]]], bool, int, f - # loat, complex, str, bytes, _NestedSequence[Union[bool, int, float, - # complex, str, bytes]]]" [arg-type] - np.putmask(join_array, mask, right) # type: ignore[arg-type] + np.putmask(join_array, mask, right) else: join_array._putmask(mask, right) @@ -5351,11 +5346,9 @@ def __getitem__(self, key): if result.ndim > 1: deprecate_ndim_indexing(result) if hasattr(result, "_ndarray"): - # error: Item "ndarray[Any, Any]" of "Union[ExtensionArray, - # ndarray[Any, Any]]" has no attribute "_ndarray" [union-attr] # i.e. NDArrayBackedExtensionArray # Unpack to ndarray for MPL compat - return result._ndarray # type: ignore[union-attr] + return result._ndarray return result # NB: Using _constructor._simple_new would break if MultiIndex @@ -6893,9 +6886,7 @@ def insert(self, loc: int, item) -> Index: new_values = np.insert(arr, loc, casted) else: - # No overload variant of "insert" matches argument types - # "ndarray[Any, Any]", "int", "None" [call-overload] - new_values = np.insert(arr, loc, None) # type: ignore[call-overload] + new_values = np.insert(arr, loc, None) loc = loc if loc >= 0 else loc - 1 new_values[loc] = item diff --git a/pandas/core/indexes/multi.py b/pandas/core/indexes/multi.py index ef0a2d5bf1b0f..101eac992e95d 100644 --- a/pandas/core/indexes/multi.py +++ b/pandas/core/indexes/multi.py @@ -363,9 +363,7 @@ def _validate_codes(self, level: list, code: list): """ null_mask = isna(level) if np.any(null_mask): - # Incompatible types in assignment (expression has type - # "ndarray[Any, dtype[Any]]", variable has type "List[Any]") - code = np.where(null_mask[code], -1, code) # type: ignore[assignment] + code = np.where(null_mask[code], -1, code) return code def _verify_integrity(self, codes: list | None = None, levels: list | None = None): @@ -1579,12 +1577,7 @@ def is_monotonic_increasing(self) -> bool: self._get_level_values(i)._values for i in reversed(range(len(self.levels))) ] try: - # Argument 1 to "lexsort" has incompatible type "List[Union[ExtensionArray, - # ndarray[Any, Any]]]"; expected "Union[_SupportsArray[dtype[Any]], - # _NestedSequence[_SupportsArray[dtype[Any]]], bool, - # int, float, complex, str, bytes, _NestedSequence[Union[bool, int, float, - # complex, str, bytes]]]" [arg-type] - sort_order = np.lexsort(values) # type: ignore[arg-type] + sort_order = np.lexsort(values) return Index(sort_order).is_monotonic_increasing except TypeError: diff --git a/pandas/core/internals/ops.py b/pandas/core/internals/ops.py index 1160d3b2a8e3a..c938a018574f9 100644 --- a/pandas/core/internals/ops.py +++ b/pandas/core/internals/ops.py @@ -125,7 +125,9 @@ def _get_same_shape_values( # argument type "Tuple[Union[ndarray, slice], slice]" lvals = lvals[rblk.mgr_locs.indexer, :] # type: ignore[call-overload] assert lvals.shape[0] == 1, lvals.shape - lvals = lvals[0, :] + # error: No overload variant of "__getitem__" of "ExtensionArray" matches + # argument type "Tuple[int, slice]" + lvals = lvals[0, :] # type: ignore[call-overload] else: # lvals are 1D, rvals are 2D assert rvals.shape[0] == 1, rvals.shape diff --git a/pandas/core/missing.py b/pandas/core/missing.py index b0bfbf13fbb2c..6224b35f7e680 100644 --- a/pandas/core/missing.py +++ b/pandas/core/missing.py @@ -333,15 +333,7 @@ def func(yvalues: np.ndarray) -> None: **kwargs, ) - # Argument 1 to "apply_along_axis" has incompatible type - # "Callable[[ndarray[Any, Any]], None]"; expected - # "Callable[..., Union[_SupportsArray[dtype[]], - # Sequence[_SupportsArray[dtype[ - # ]]], Sequence[Sequence[_SupportsArray[dtype[]]]], - # Sequence[Sequence[Sequence[_SupportsArray[dtype[]]]]], - # Sequence[Sequence[Sequence[Sequence[_SupportsArray[dtype[]]]]]]]]" - # interp each column independently - np.apply_along_axis(func, axis, data) # type: ignore[arg-type] + np.apply_along_axis(func, axis, data) return @@ -779,23 +771,14 @@ def interpolate_2d( Modifies values in-place. """ if limit_area is not None: - # Argument 1 to "apply_along_axis" has incompatible type "partial[None]"; - # expected "Callable[..., Union[_SupportsArray[dtype[]], - # Sequence[_SupportsArray[dtype[]]], Sequence[Sequence - # [_SupportsArray[dtype[]]]], - # Sequence[Sequence[Sequence[_SupportsArray[dtype[]]]]], - # Sequence[Sequence[Sequence[Sequence[_SupportsArray[dtype[]]]]]]]]" - - # Argument 2 to "apply_along_axis" has incompatible type "Union[str, int]"; - # expected "SupportsIndex" [arg-type] np.apply_along_axis( partial( _interpolate_with_limit_area, method=method, limit=limit, limit_area=limit_area, - ), # type: ignore[arg-type] - axis, # type: ignore[arg-type] + ), + axis, values, ) return diff --git a/pandas/core/reshape/melt.py b/pandas/core/reshape/melt.py index 262cd9774f694..aa426d24db75d 100644 --- a/pandas/core/reshape/melt.py +++ b/pandas/core/reshape/melt.py @@ -133,9 +133,7 @@ def melt( if is_extension_array_dtype(id_data): id_data = concat([id_data] * K, ignore_index=True) else: - # Incompatible types in assignment (expression has type - # "ndarray[Any, dtype[Any]]", variable has type "Series") [assignment] - id_data = np.tile(id_data._values, K) # type: ignore[assignment] + id_data = np.tile(id_data._values, K) mdata[col] = id_data mcolumns = id_vars + var_name + [value_name] diff --git a/pandas/core/series.py b/pandas/core/series.py index 6b1b9dc6c88ac..cf602115f683f 100644 --- a/pandas/core/series.py +++ b/pandas/core/series.py @@ -2024,9 +2024,7 @@ def count(self, level=None): lev = lev.insert(cnt, lev._na_value) obs = level_codes[notna(self._values)] - # Argument "minlength" to "bincount" has incompatible type "Optional[int]"; - # expected "SupportsIndex" [arg-type] - out = np.bincount(obs, minlength=len(lev) or None) # type: ignore[arg-type] + out = np.bincount(obs, minlength=len(lev) or None) return self._constructor(out, index=lev, dtype="int64").__finalize__( self, method="count" ) diff --git a/pandas/core/window/rolling.py b/pandas/core/window/rolling.py index b45f43adbe952..886d81af8ba6b 100644 --- a/pandas/core/window/rolling.py +++ b/pandas/core/window/rolling.py @@ -409,7 +409,10 @@ def _prep_values(self, values: ArrayLike) -> np.ndarray: if inf.any(): values = np.where(inf, np.nan, values) - return values + # error: Incompatible return value type + # (got "Union[ExtensionArray, ndarray[Any, Any], + # ndarray[Any, dtype[floating[_64Bit]]]]", expected "ndarray[Any, Any]") + return values # type: ignore[return-value] def _insert_on_column(self, result: DataFrame, obj: DataFrame) -> None: # if we have an 'on' column we want to put it back into diff --git a/pandas/io/formats/style.py b/pandas/io/formats/style.py index 24669e84443a6..1f42329389a18 100644 --- a/pandas/io/formats/style.py +++ b/pandas/io/formats/style.py @@ -3860,10 +3860,24 @@ def _highlight_between( Return an array of css props based on condition of data values within given range. """ if np.iterable(left) and not isinstance(left, str): - left = _validate_apply_axis_arg(left, "left", None, data) + # error: Argument 1 to "_validate_apply_axis_arg" + # has incompatible type "Union[str, float, Period, + # Timedelta, Interval[Any], datetime64, timedelta64, + # datetime, Sequence[Any], ndarray[Any, Any], NDFrame, None]"; + # expected "Union[NDFrame, Sequence[Any], ndarray[Any, Any]]" + left = _validate_apply_axis_arg( + left, "left", None, data # type: ignore[arg-type] + ) if np.iterable(right) and not isinstance(right, str): - right = _validate_apply_axis_arg(right, "right", None, data) + # error: Argument 1 to "_validate_apply_axis_arg" + # has incompatible type "Union[str, float, Period, + # Timedelta, Interval[Any], datetime64, timedelta64, + # datetime, Sequence[Any], ndarray[Any, Any], NDFrame, None]"; + # expected "Union[NDFrame, Sequence[Any], ndarray[Any, Any]]" + right = _validate_apply_axis_arg( + right, "right", None, data # type: ignore[arg-type] + ) # get ops with correct boundary attribution if inclusive == "both": diff --git a/pandas/io/parsers/c_parser_wrapper.py b/pandas/io/parsers/c_parser_wrapper.py index 91c37a0e43505..7781860f0d61e 100644 --- a/pandas/io/parsers/c_parser_wrapper.py +++ b/pandas/io/parsers/c_parser_wrapper.py @@ -383,7 +383,7 @@ def _concatenate_chunks(chunks: list[dict[int, ArrayLike]]) -> dict: numpy_dtypes, # type: ignore[arg-type] [], ) - if common_type == object: + if common_type == np.dtype(object): warning_columns.append(str(name)) dtype = dtypes.pop() @@ -400,14 +400,7 @@ def _concatenate_chunks(chunks: list[dict[int, ArrayLike]]) -> dict: arrs # type: ignore[arg-type] ) else: - # Argument 1 to "concatenate" has incompatible type - # "List[Union[ExtensionArray, ndarray[Any, Any]]]"; expected - # "Union[_SupportsArray[dtype[Any]], - # Sequence[_SupportsArray[dtype[Any]]], - # Sequence[Sequence[_SupportsArray[dtype[Any]]]], - # Sequence[Sequence[Sequence[_SupportsArray[dtype[Any]]]]], - # Sequence[Sequence[Sequence[Sequence[_SupportsArray[dtype[Any]]]]]]]" - result[name] = np.concatenate(arrs) # type: ignore[arg-type] + result[name] = np.concatenate(arrs) if warning_columns: warning_names = ",".join(warning_columns) diff --git a/pandas/tests/extension/date/array.py b/pandas/tests/extension/date/array.py index b14b9921be3d3..d29ed293e71ed 100644 --- a/pandas/tests/extension/date/array.py +++ b/pandas/tests/extension/date/array.py @@ -109,10 +109,7 @@ def __init__( self._month = np.zeros(ldates, dtype=np.uint8) # 255 (1, 31) self._day = np.zeros(ldates, dtype=np.uint8) # 255 (1, 12) - # "object_" object is not iterable [misc] - for (i,), (y, m, d) in np.ndenumerate( # type: ignore[misc] - np.char.split(dates, sep="-") - ): + for (i,), (y, m, d) in np.ndenumerate(np.char.split(dates, sep="-")): self._year[i] = int(y) self._month[i] = int(m) self._day[i] = int(d) diff --git a/requirements-dev.txt b/requirements-dev.txt index 7640587b85a1c..2b8aee80882a5 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -1,11 +1,66 @@ # This file is auto-generated from environment.yml, do not modify. # See that file for comments about the need/usage of each dependency. -numpy>=1.19.5 -python-dateutil>=2.8.1 +cython==0.29.30 +pytest>=6.0 +pytest-cov +pytest-xdist>=1.31 +psutil +pytest-asyncio>=0.17 +boto3 +python-dateutil +numpy pytz +beautifulsoup4 +blosc +brotlipy +bottleneck +fastparquet +fsspec +html5lib +hypothesis +gcsfs +jinja2 +lxml +matplotlib +numba>=0.53.1 +numexpr>=2.8.0 +openpyxl +odfpy +pandas-gbq +psycopg2 +pyarrow +pymysql +pyreadstat +tables +python-snappy +pyxlsb +s3fs +scipy +sqlalchemy +tabulate +xarray +xlrd +xlsxwriter +xlwt +zstandard +aiobotocore<2.0.0 +botocore +cftime +dask +ipython +geopandas +seaborn +scikit-learn +statsmodels +coverage +pandas-datareader +pyyaml +py +torch +moto +flask asv -cython>=0.29.30 black==22.3.0 cpplint flake8==4.0.1 @@ -18,6 +73,7 @@ pycodestyle pyupgrade gitpython gitdb +natsort numpydoc pandas-dev-flaker==0.5.0 pydata-sphinx-theme==0.8.0 @@ -31,58 +87,13 @@ types-setuptools nbconvert>=6.4.5 nbsphinx pandoc -dask -toolz>=0.7.3 -partd>=0.3.10 -cloudpickle>=0.2.1 -markdown -feedparser -pyyaml -requests -boto3 -botocore>=1.11 -hypothesis>=5.5.3 -moto -flask -pytest>=6.0 -pytest-cov -pytest-xdist>=1.31 -pytest-asyncio>=0.17 -pytest-instafail -seaborn -statsmodels ipywidgets nbformat notebook>=6.0.3 -blosc -bottleneck>=1.3.1 ipykernel -ipython>=7.11.1 jinja2 -matplotlib>=3.3.2 -numexpr>=2.7.1 -scipy>=1.4.1 -numba>=0.50.1 -beautifulsoup4>=4.8.2 -html5lib -lxml -openpyxl -xlrd -xlsxwriter -xlwt -odfpy -fastparquet>=0.4.0 -pyarrow>2.0.1 -python-snappy -tables>=3.6.1 -s3fs>=0.4.0 -aiobotocore<2.0.0 -fsspec>=0.7.4 -gcsfs>=0.6.0 -sqlalchemy -xarray -cftime -pyreadstat -tabulate>=0.8.3 -natsort +markdown +feedparser +pyyaml +requests setuptools>=51.0.0 diff --git a/scripts/generate_pip_deps_from_conda.py b/scripts/generate_pip_deps_from_conda.py index 2ea50fa3ac8d4..8cb539d3b02c8 100755 --- a/scripts/generate_pip_deps_from_conda.py +++ b/scripts/generate_pip_deps_from_conda.py @@ -21,7 +21,7 @@ import yaml EXCLUDE = {"python", "c-compiler", "cxx-compiler"} -RENAME = {"pytables": "tables", "dask-core": "dask"} +RENAME = {"pytables": "tables", "geopandas-base": "geopandas", "pytorch": "torch"} def conda_package_to_pip(package: str):