Skip to content

Commit

Permalink
CI: mypy 0.990 (#419)
Browse files Browse the repository at this point in the history
* CI: mypy 0.990

* added comments for the new ignores
  • Loading branch information
twoertwein committed Nov 8, 2022
1 parent 90c1b61 commit 8333a14
Show file tree
Hide file tree
Showing 14 changed files with 27 additions and 10 deletions.
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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,
Expand Down
1 change: 1 addition & 0 deletions pandas-stubs/core/base.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 0 additions & 2 deletions pandas-stubs/core/frame.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
2 changes: 2 additions & 0 deletions pandas-stubs/core/generic.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ from typing import (
Literal,
Mapping,
Sequence,
final,
overload,
)

Expand Down Expand Up @@ -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: ...
Expand Down
1 change: 1 addition & 0 deletions pandas-stubs/core/groupby/ops.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion pandas-stubs/core/indexes/base.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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: ...
Expand All @@ -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 = ...
Expand Down Expand Up @@ -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=...): ...
Expand Down
1 change: 1 addition & 0 deletions pandas-stubs/core/indexes/category.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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: ...
Expand Down
4 changes: 4 additions & 0 deletions pandas-stubs/core/indexes/multi.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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: ...
Expand Down
1 change: 1 addition & 0 deletions pandas-stubs/core/indexes/numeric.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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=...): ...
3 changes: 3 additions & 0 deletions pandas-stubs/core/indexes/range.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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: ...
Expand Down
3 changes: 2 additions & 1 deletion pandas-stubs/core/series.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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]: ...
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 4 additions & 2 deletions tests/test_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -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)

Expand Down

0 comments on commit 8333a14

Please sign in to comment.