diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 144260552..b56771cf4 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -11,7 +11,7 @@ repos: hooks: - id: isort - repo: https://github.com/asottile/pyupgrade - rev: v2.37.3 + rev: v3.2.0 hooks: - id: pyupgrade types_or: [python, pyi] @@ -27,7 +27,7 @@ repos: - id: flake8 name: flake8 (pyi) additional_dependencies: - - flake8-pyi==22.8.2 + - flake8-pyi==22.10.0 types: [pyi] args: [ --ignore=E301 E302 E305 E402 E501 E701 E704 F401 F811 W503 Y019 Y027 Y034 Y037 Y041 Y042, diff --git a/pandas-stubs/core/base.pyi b/pandas-stubs/core/base.pyi index 81d019f19..b6fc6e165 100644 --- a/pandas-stubs/core/base.pyi +++ b/pandas-stubs/core/base.pyi @@ -63,6 +63,7 @@ class IndexOpsMixin: def tolist(self) -> list: ... def to_list(self) -> list: ... def __iter__(self): ... + @property def hasnans(self) -> bool: ... def value_counts( self, diff --git a/pandas-stubs/core/frame.pyi b/pandas-stubs/core/frame.pyi index 848f115f3..f693822db 100644 --- a/pandas-stubs/core/frame.pyi +++ b/pandas-stubs/core/frame.pyi @@ -1276,8 +1276,6 @@ class DataFrame(NDFrame, OpsMixin): @property def at(self): ... # Not sure what to do with this yet; look at source @property - def bool(self) -> _bool: ... - @property def columns(self) -> Index: ... @columns.setter # setter needs to be right next to getter; otherwise mypy complains def columns( diff --git a/pandas-stubs/core/generic.pyi b/pandas-stubs/core/generic.pyi index b26dbe4e7..0b1b89c17 100644 --- a/pandas-stubs/core/generic.pyi +++ b/pandas-stubs/core/generic.pyi @@ -8,6 +8,7 @@ from typing import ( Literal, Mapping, Sequence, + final, overload, ) @@ -83,6 +84,7 @@ class NDFrame(PandasObject, indexing.IndexingMixin): def __neg__(self: NDFrameT) -> NDFrameT: ... def __pos__(self: NDFrameT) -> NDFrameT: ... def __nonzero__(self) -> None: ... + @final def bool(self) -> _bool: ... def __abs__(self) -> NDFrame: ... def __round__(self, decimals: int = ...) -> NDFrame: ... diff --git a/pandas-stubs/core/groupby/ops.pyi b/pandas-stubs/core/groupby/ops.pyi index 281274e9c..1bc5b809c 100644 --- a/pandas-stubs/core/groupby/ops.pyi +++ b/pandas-stubs/core/groupby/ops.pyi @@ -70,6 +70,7 @@ class BinGrouper(BaseGrouper): def get_iterator(self, data: DataFrame | Series, axis: int = ...): ... def indices(self): ... def group_info(self): ... + @property def reconstructed_codes(self) -> list[np.ndarray]: ... def result_index(self): ... @property diff --git a/pandas-stubs/core/indexes/base.pyi b/pandas-stubs/core/indexes/base.pyi index c11e57903..0e0989e69 100644 --- a/pandas-stubs/core/indexes/base.pyi +++ b/pandas-stubs/core/indexes/base.pyi @@ -112,6 +112,7 @@ class Index(IndexOpsMixin, PandasObject): def is_monotonic_increasing(self) -> bool: ... @property def is_monotonic_decreasing(self) -> bool: ... + @property def is_unique(self) -> bool: ... @property def has_duplicates(self) -> bool: ... @@ -124,9 +125,10 @@ class Index(IndexOpsMixin, PandasObject): def is_interval(self) -> bool: ... def is_mixed(self) -> bool: ... def holds_integer(self): ... + @property def inferred_type(self): ... - def is_all_dates(self) -> bool: ... def __reduce__(self): ... + @property def hasnans(self) -> bool: ... def isna(self): ... isnull = ... @@ -177,6 +179,7 @@ class Index(IndexOpsMixin, PandasObject): ): ... @property def values(self) -> np.ndarray: ... + @property def array(self) -> ExtensionArray: ... def memory_usage(self, deep: bool = ...): ... def where(self, cond, other=...): ... diff --git a/pandas-stubs/core/indexes/category.pyi b/pandas-stubs/core/indexes/category.pyi index c02bb1c97..9abdf7dce 100644 --- a/pandas-stubs/core/indexes/category.pyi +++ b/pandas-stubs/core/indexes/category.pyi @@ -28,6 +28,7 @@ class CategoricalIndex(ExtensionIndex, accessor.PandasDelegate): def __array__(self, dtype=...) -> np.ndarray: ... def astype(self, dtype: DtypeArg, copy: bool = ...) -> Index: ... def fillna(self, value=..., downcast=...): ... + @property def is_unique(self) -> bool: ... @property def is_monotonic_increasing(self) -> bool: ... diff --git a/pandas-stubs/core/indexes/multi.pyi b/pandas-stubs/core/indexes/multi.pyi index 29e4acddf..c296a4a7a 100644 --- a/pandas-stubs/core/indexes/multi.pyi +++ b/pandas-stubs/core/indexes/multi.pyi @@ -65,8 +65,10 @@ class MultiIndex(Index): def __array__(self, dtype=...) -> np.ndarray: ... def view(self, cls=...): ... def __contains__(self, key) -> bool: ... + @property def dtype(self) -> np.dtype: ... def memory_usage(self, deep: bool = ...) -> int: ... + @property def nbytes(self) -> int: ... def format( self, @@ -82,7 +84,9 @@ class MultiIndex(Index): def inferred_type(self) -> str: ... @property def values(self): ... + @property def is_monotonic_increasing(self) -> bool: ... + @property def is_monotonic_decreasing(self) -> bool: ... def duplicated(self, keep: Literal["first", "last", False] = ...): ... def fillna(self, value=..., downcast=...) -> None: ... diff --git a/pandas-stubs/core/indexes/numeric.pyi b/pandas-stubs/core/indexes/numeric.pyi index 95715a83a..5ebead59a 100644 --- a/pandas-stubs/core/indexes/numeric.pyi +++ b/pandas-stubs/core/indexes/numeric.pyi @@ -37,5 +37,6 @@ class Float64Index(NumericIndex): def equals(self, other) -> bool: ... def __contains__(self, other) -> bool: ... def get_loc(self, key, tolerance=...): ... + @property def is_unique(self) -> bool: ... def isin(self, values, level=...): ... diff --git a/pandas-stubs/core/indexes/range.pyi b/pandas-stubs/core/indexes/range.pyi index 0ecc922bd..86c12bc90 100644 --- a/pandas-stubs/core/indexes/range.pyi +++ b/pandas-stubs/core/indexes/range.pyi @@ -32,13 +32,16 @@ class RangeIndex(Int64Index): def start(self): ... def stop(self): ... def step(self): ... + @property def nbytes(self) -> int: ... def memory_usage(self, deep: bool = ...) -> int: ... @property def dtype(self) -> np.dtype: ... @property def is_unique(self) -> bool: ... + @property def is_monotonic_increasing(self) -> bool: ... + @property def is_monotonic_decreasing(self) -> bool: ... @property def has_duplicates(self) -> bool: ... diff --git a/pandas-stubs/core/series.pyi b/pandas-stubs/core/series.pyi index e368c8786..b017b6840 100644 --- a/pandas-stubs/core/series.pyi +++ b/pandas-stubs/core/series.pyi @@ -455,8 +455,9 @@ class Series(IndexOpsMixin, NDFrame, Generic[S1]): observed: _bool = ..., dropna: _bool = ..., ) -> _SeriesGroupByNonScalar[S1]: ... + # need the ignore because None is Hashable @overload - def count(self, level: None = ...) -> int: ... + def count(self, level: None = ...) -> int: ... # type: ignore[misc] @overload def count(self, level: Hashable) -> Series[S1]: ... def mode(self, dropna=...) -> Series[S1]: ... diff --git a/pyproject.toml b/pyproject.toml index db5eb825d..a7aaf932a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -34,7 +34,7 @@ python = ">=3.8,<3.11" types-pytz = ">= 2022.1.1" [tool.poetry.dev-dependencies] -mypy = "==0.971" +mypy = "==0.990" pyarrow = ">=9.0.0" pytest = ">=7.1.2" pyright = ">=1.1.278" diff --git a/tests/__init__.py b/tests/__init__.py index acedd97ea..43008807a 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -29,7 +29,7 @@ def check(actual: T, klass: type, dtype: type | None = None, attr: str = "left") return actual # type: ignore[return-value] if hasattr(actual, "__iter__"): - value = next(iter(actual)) # type: ignore[call-overload] + value = next(iter(actual)) # pyright: ignore[reportGeneralTypeIssues] else: assert hasattr(actual, attr) value = getattr(actual, attr) diff --git a/tests/test_io.py b/tests/test_io.py index 5239bd6a8..3a8bee13d 100644 --- a/tests/test_io.py +++ b/tests/test_io.py @@ -695,7 +695,7 @@ def test_to_string(): with ensure_clean() as path: check(assert_type(DF.to_string(path), None), type(None)) check(assert_type(DF.to_string(pathlib.Path(path)), None), type(None)) - with open(path, "wt") as df_string: + with open(path, "w") as df_string: check(assert_type(DF.to_string(df_string), None), type(None)) sio = io.StringIO() check(assert_type(DF.to_string(sio), None), type(None)) @@ -822,7 +822,9 @@ def test_sqlalchemy_selectable() -> None: class Base(metaclass=sqlalchemy.orm.decl_api.DeclarativeMeta): __abstract__ = True - class Temp(Base): + # error: Metaclass conflict: the metaclass of a derived class must be a + # (non-strict) subclass of the metaclasses of all its bases + class Temp(Base): # type: ignore[misc] __tablename__ = "part" quantity = sqlalchemy.Column(sqlalchemy.Integer)