Skip to content

Commit 8333a14

Browse files
authored
CI: mypy 0.990 (#419)
* CI: mypy 0.990 * added comments for the new ignores
1 parent 90c1b61 commit 8333a14

14 files changed

+27
-10
lines changed

.pre-commit-config.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ repos:
1111
hooks:
1212
- id: isort
1313
- repo: https://github.com/asottile/pyupgrade
14-
rev: v2.37.3
14+
rev: v3.2.0
1515
hooks:
1616
- id: pyupgrade
1717
types_or: [python, pyi]
@@ -27,7 +27,7 @@ repos:
2727
- id: flake8
2828
name: flake8 (pyi)
2929
additional_dependencies:
30-
- flake8-pyi==22.8.2
30+
- flake8-pyi==22.10.0
3131
types: [pyi]
3232
args: [
3333
--ignore=E301 E302 E305 E402 E501 E701 E704 F401 F811 W503 Y019 Y027 Y034 Y037 Y041 Y042,

pandas-stubs/core/base.pyi

+1
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ class IndexOpsMixin:
6363
def tolist(self) -> list: ...
6464
def to_list(self) -> list: ...
6565
def __iter__(self): ...
66+
@property
6667
def hasnans(self) -> bool: ...
6768
def value_counts(
6869
self,

pandas-stubs/core/frame.pyi

-2
Original file line numberDiff line numberDiff line change
@@ -1276,8 +1276,6 @@ class DataFrame(NDFrame, OpsMixin):
12761276
@property
12771277
def at(self): ... # Not sure what to do with this yet; look at source
12781278
@property
1279-
def bool(self) -> _bool: ...
1280-
@property
12811279
def columns(self) -> Index: ...
12821280
@columns.setter # setter needs to be right next to getter; otherwise mypy complains
12831281
def columns(

pandas-stubs/core/generic.pyi

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ from typing import (
88
Literal,
99
Mapping,
1010
Sequence,
11+
final,
1112
overload,
1213
)
1314

@@ -83,6 +84,7 @@ class NDFrame(PandasObject, indexing.IndexingMixin):
8384
def __neg__(self: NDFrameT) -> NDFrameT: ...
8485
def __pos__(self: NDFrameT) -> NDFrameT: ...
8586
def __nonzero__(self) -> None: ...
87+
@final
8688
def bool(self) -> _bool: ...
8789
def __abs__(self) -> NDFrame: ...
8890
def __round__(self, decimals: int = ...) -> NDFrame: ...

pandas-stubs/core/groupby/ops.pyi

+1
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ class BinGrouper(BaseGrouper):
7070
def get_iterator(self, data: DataFrame | Series, axis: int = ...): ...
7171
def indices(self): ...
7272
def group_info(self): ...
73+
@property
7374
def reconstructed_codes(self) -> list[np.ndarray]: ...
7475
def result_index(self): ...
7576
@property

pandas-stubs/core/indexes/base.pyi

+4-1
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ class Index(IndexOpsMixin, PandasObject):
112112
def is_monotonic_increasing(self) -> bool: ...
113113
@property
114114
def is_monotonic_decreasing(self) -> bool: ...
115+
@property
115116
def is_unique(self) -> bool: ...
116117
@property
117118
def has_duplicates(self) -> bool: ...
@@ -124,9 +125,10 @@ class Index(IndexOpsMixin, PandasObject):
124125
def is_interval(self) -> bool: ...
125126
def is_mixed(self) -> bool: ...
126127
def holds_integer(self): ...
128+
@property
127129
def inferred_type(self): ...
128-
def is_all_dates(self) -> bool: ...
129130
def __reduce__(self): ...
131+
@property
130132
def hasnans(self) -> bool: ...
131133
def isna(self): ...
132134
isnull = ...
@@ -177,6 +179,7 @@ class Index(IndexOpsMixin, PandasObject):
177179
): ...
178180
@property
179181
def values(self) -> np.ndarray: ...
182+
@property
180183
def array(self) -> ExtensionArray: ...
181184
def memory_usage(self, deep: bool = ...): ...
182185
def where(self, cond, other=...): ...

pandas-stubs/core/indexes/category.pyi

+1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ class CategoricalIndex(ExtensionIndex, accessor.PandasDelegate):
2828
def __array__(self, dtype=...) -> np.ndarray: ...
2929
def astype(self, dtype: DtypeArg, copy: bool = ...) -> Index: ...
3030
def fillna(self, value=..., downcast=...): ...
31+
@property
3132
def is_unique(self) -> bool: ...
3233
@property
3334
def is_monotonic_increasing(self) -> bool: ...

pandas-stubs/core/indexes/multi.pyi

+4
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,10 @@ class MultiIndex(Index):
6565
def __array__(self, dtype=...) -> np.ndarray: ...
6666
def view(self, cls=...): ...
6767
def __contains__(self, key) -> bool: ...
68+
@property
6869
def dtype(self) -> np.dtype: ...
6970
def memory_usage(self, deep: bool = ...) -> int: ...
71+
@property
7072
def nbytes(self) -> int: ...
7173
def format(
7274
self,
@@ -82,7 +84,9 @@ class MultiIndex(Index):
8284
def inferred_type(self) -> str: ...
8385
@property
8486
def values(self): ...
87+
@property
8588
def is_monotonic_increasing(self) -> bool: ...
89+
@property
8690
def is_monotonic_decreasing(self) -> bool: ...
8791
def duplicated(self, keep: Literal["first", "last", False] = ...): ...
8892
def fillna(self, value=..., downcast=...) -> None: ...

pandas-stubs/core/indexes/numeric.pyi

+1
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,6 @@ class Float64Index(NumericIndex):
3737
def equals(self, other) -> bool: ...
3838
def __contains__(self, other) -> bool: ...
3939
def get_loc(self, key, tolerance=...): ...
40+
@property
4041
def is_unique(self) -> bool: ...
4142
def isin(self, values, level=...): ...

pandas-stubs/core/indexes/range.pyi

+3
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,16 @@ class RangeIndex(Int64Index):
3232
def start(self): ...
3333
def stop(self): ...
3434
def step(self): ...
35+
@property
3536
def nbytes(self) -> int: ...
3637
def memory_usage(self, deep: bool = ...) -> int: ...
3738
@property
3839
def dtype(self) -> np.dtype: ...
3940
@property
4041
def is_unique(self) -> bool: ...
42+
@property
4143
def is_monotonic_increasing(self) -> bool: ...
44+
@property
4245
def is_monotonic_decreasing(self) -> bool: ...
4346
@property
4447
def has_duplicates(self) -> bool: ...

pandas-stubs/core/series.pyi

+2-1
Original file line numberDiff line numberDiff line change
@@ -455,8 +455,9 @@ class Series(IndexOpsMixin, NDFrame, Generic[S1]):
455455
observed: _bool = ...,
456456
dropna: _bool = ...,
457457
) -> _SeriesGroupByNonScalar[S1]: ...
458+
# need the ignore because None is Hashable
458459
@overload
459-
def count(self, level: None = ...) -> int: ...
460+
def count(self, level: None = ...) -> int: ... # type: ignore[misc]
460461
@overload
461462
def count(self, level: Hashable) -> Series[S1]: ...
462463
def mode(self, dropna=...) -> Series[S1]: ...

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ python = ">=3.8,<3.11"
3434
types-pytz = ">= 2022.1.1"
3535

3636
[tool.poetry.dev-dependencies]
37-
mypy = "==0.971"
37+
mypy = "==0.990"
3838
pyarrow = ">=9.0.0"
3939
pytest = ">=7.1.2"
4040
pyright = ">=1.1.278"

tests/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def check(actual: T, klass: type, dtype: type | None = None, attr: str = "left")
2929
return actual # type: ignore[return-value]
3030

3131
if hasattr(actual, "__iter__"):
32-
value = next(iter(actual)) # type: ignore[call-overload]
32+
value = next(iter(actual)) # pyright: ignore[reportGeneralTypeIssues]
3333
else:
3434
assert hasattr(actual, attr)
3535
value = getattr(actual, attr)

tests/test_io.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -695,7 +695,7 @@ def test_to_string():
695695
with ensure_clean() as path:
696696
check(assert_type(DF.to_string(path), None), type(None))
697697
check(assert_type(DF.to_string(pathlib.Path(path)), None), type(None))
698-
with open(path, "wt") as df_string:
698+
with open(path, "w") as df_string:
699699
check(assert_type(DF.to_string(df_string), None), type(None))
700700
sio = io.StringIO()
701701
check(assert_type(DF.to_string(sio), None), type(None))
@@ -822,7 +822,9 @@ def test_sqlalchemy_selectable() -> None:
822822
class Base(metaclass=sqlalchemy.orm.decl_api.DeclarativeMeta):
823823
__abstract__ = True
824824

825-
class Temp(Base):
825+
# error: Metaclass conflict: the metaclass of a derived class must be a
826+
# (non-strict) subclass of the metaclasses of all its bases
827+
class Temp(Base): # type: ignore[misc]
826828
__tablename__ = "part"
827829
quantity = sqlalchemy.Column(sqlalchemy.Integer)
828830

0 commit comments

Comments
 (0)