Skip to content

Commit

Permalink
Resolve remaining type checking and linting issues
Browse files Browse the repository at this point in the history
Signed-off-by: Deepyaman Datta <deepyaman.datta@utexas.edu>
  • Loading branch information
deepyaman committed Jun 25, 2024
1 parent 5bf4279 commit 0dcf7dd
Show file tree
Hide file tree
Showing 11 changed files with 24 additions and 18 deletions.
4 changes: 2 additions & 2 deletions pandera/api/base/error_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from collections import defaultdict
from enum import Enum
from typing import Any, Dict, List, Union
from typing import Any, Dict, List, Optional, Union

from pandera.api.checks import Check
from pandera.config import ValidationDepth, get_config_context
Expand Down Expand Up @@ -40,7 +40,7 @@ def lazy(self) -> bool:
def collect_error(
self,
error_type: ErrorCategory,
reason_code: SchemaErrorReason,
reason_code: Optional[SchemaErrorReason],
schema_error: SchemaError,
original_exc: Union[BaseException, None] = None,
):
Expand Down
2 changes: 1 addition & 1 deletion pandera/api/dataframe/container.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ def __init__(
metadata=metadata,
)

self.columns: Dict[Any, Any] = ( # type: ignore [name-defined]
self.columns: Dict[Any, Any] = ( # type: ignore[name-defined]
{} if columns is None else columns
)

Expand Down
2 changes: 1 addition & 1 deletion pandera/api/ibis/container.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def validate(
inplace=inplace,
)

@_DataFrameSchema.dtype.setter
@_DataFrameSchema.dtype.setter # type: ignore[attr-defined]
def dtype(self, value) -> None:

Check warning on line 97 in pandera/api/ibis/container.py

View check run for this annotation

Codecov / codecov/patch

pandera/api/ibis/container.py#L96-L97

Added lines #L96 - L97 were not covered by tests
"""Set the dtype property."""
self._dtype = ibis_engine.Engine.dtype(value) if value else None

Check warning on line 99 in pandera/api/ibis/container.py

View check run for this annotation

Codecov / codecov/patch

pandera/api/ibis/container.py#L99

Added line #L99 was not covered by tests
5 changes: 4 additions & 1 deletion pandera/api/ibis/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

from pandera.api.checks import Check
from pandera.api.dataframe.model import DataFrameModel as _DataFrameModel
from pandera.api.dataframe.model import get_dtype_kwargs
from pandera.api.dataframe.model_components import FieldInfo
from pandera.api.ibis.components import Column
from pandera.api.ibis.container import DataFrameSchema
Expand Down Expand Up @@ -45,7 +46,9 @@ def _build_columns( # pylint:disable=too-many-locals
check_name = getattr(field, "check_name", None)

Check warning on line 46 in pandera/api/ibis/model.py

View check run for this annotation

Codecov / codecov/patch

pandera/api/ibis/model.py#L42-L46

Added lines #L42 - L46 were not covered by tests

try:
engine_dtype = ibis_engine.Engine.dtype(annotation.raw_annotation)
engine_dtype = ibis_engine.Engine.dtype(

Check warning on line 49 in pandera/api/ibis/model.py

View check run for this annotation

Codecov / codecov/patch

pandera/api/ibis/model.py#L48-L49

Added lines #L48 - L49 were not covered by tests
annotation.raw_annotation
)
if inspect.isclass(annotation.raw_annotation) and issubclass(

Check warning on line 52 in pandera/api/ibis/model.py

View check run for this annotation

Codecov / codecov/patch

pandera/api/ibis/model.py#L52

Added line #L52 was not covered by tests
annotation.raw_annotation, ibis_engine.DataType
):
Expand Down
2 changes: 1 addition & 1 deletion pandera/api/pandas/container.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def _register_default_backends(self):

register_pandas_backends()

@_DataFrameSchema.dtype.setter
@_DataFrameSchema.dtype.setter # type: ignore[attr-defined]
def dtype(self, value: PandasDtypeInputTypes) -> None:
"""Set the dtype property."""
self._dtype = pandas_engine.Engine.dtype(value) if value else None
Expand Down
2 changes: 1 addition & 1 deletion pandera/api/polars/container.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def validate(

return output

@_DataFrameSchema.dtype.setter
@_DataFrameSchema.dtype.setter # type: ignore[attr-defined]

Check warning on line 73 in pandera/api/polars/container.py

View check run for this annotation

Codecov / codecov/patch

pandera/api/polars/container.py#L73

Added line #L73 was not covered by tests
def dtype(self, value) -> None:
"""Set the dtype property."""
self._dtype = polars_engine.Engine.dtype(value) if value else None
Expand Down
2 changes: 1 addition & 1 deletion pandera/backends/ibis/components.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def validate(
if lazy and error_handler.collected_errors:
raise SchemaErrors(

Check warning on line 79 in pandera/backends/ibis/components.py

View check run for this annotation

Codecov / codecov/patch

pandera/backends/ibis/components.py#L78-L79

Added lines #L78 - L79 were not covered by tests
schema=schema,
schema_errors=error_handler.collected_errors,
schema_errors=error_handler.schema_errors,
data=check_obj,
)

Expand Down
6 changes: 3 additions & 3 deletions pandera/backends/ibis/container.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from __future__ import annotations

Check warning on line 3 in pandera/backends/ibis/container.py

View check run for this annotation

Codecov / codecov/patch

pandera/backends/ibis/container.py#L3

Added line #L3 was not covered by tests

from typing import TYPE_CHECKING, List, Optional
from typing import TYPE_CHECKING, Iterable, List, Optional

Check warning on line 5 in pandera/backends/ibis/container.py

View check run for this annotation

Codecov / codecov/patch

pandera/backends/ibis/container.py#L5

Added line #L5 was not covered by tests

import ibis.expr.types as ir

Check warning on line 7 in pandera/backends/ibis/container.py

View check run for this annotation

Codecov / codecov/patch

pandera/backends/ibis/container.py#L7

Added line #L7 was not covered by tests

Expand Down Expand Up @@ -85,7 +85,7 @@ def validate(
else:
raise SchemaErrors(

Check warning on line 86 in pandera/backends/ibis/container.py

View check run for this annotation

Codecov / codecov/patch

pandera/backends/ibis/container.py#L86

Added line #L86 was not covered by tests
schema=schema,
schema_errors=error_handler.collected_errors,
schema_errors=error_handler.schema_errors,
data=check_obj,
)

Expand All @@ -94,7 +94,7 @@ def validate(
def run_schema_component_checks(

Check warning on line 94 in pandera/backends/ibis/container.py

View check run for this annotation

Codecov / codecov/patch

pandera/backends/ibis/container.py#L94

Added line #L94 was not covered by tests
self,
check_obj: ir.Table,
schema_components: List,
schema_components: Iterable,
lazy: bool,
) -> List[CoreCheckResult]:
"""Run checks for all schema components."""
Expand Down
2 changes: 1 addition & 1 deletion pandera/backends/pandas/container.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ def run_checks_and_handle_errors(
(self.run_checks, (sample, schema)),
]
for check, args in core_checks:
results = check(*args) # type: ignore [operator]
results = check(*args)
if isinstance(results, CoreCheckResult):
results = [results]

Expand Down
5 changes: 3 additions & 2 deletions pandera/engines/ibis_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@ def dtype(cls, data_type: Any) -> dtypes.DataType:
try:
return engine.Engine.dtype(cls, data_type)
except TypeError:
np_dtype = data_type().to_numpy() # XXX(deepyaman): Make sure this is right???
np_dtype = (

Check warning on line 66 in pandera/engines/ibis_engine.py

View check run for this annotation

Codecov / codecov/patch

pandera/engines/ibis_engine.py#L63-L66

Added lines #L63 - L66 were not covered by tests
data_type().to_numpy() # XXX(deepyaman): Make sure this is right???
)

return engine.Engine.dtype(cls, np_dtype)

Check warning on line 70 in pandera/engines/ibis_engine.py

View check run for this annotation

Codecov / codecov/patch

pandera/engines/ibis_engine.py#L70

Added line #L70 was not covered by tests

Expand All @@ -81,7 +83,6 @@ class Int32(DataType, dtypes.Int32):
"""Semantic representation of a :class:`dt.Int32`."""



@Engine.register_dtype(

Check warning on line 86 in pandera/engines/ibis_engine.py

View check run for this annotation

Codecov / codecov/patch

pandera/engines/ibis_engine.py#L86

Added line #L86 was not covered by tests
equivalents=[np.int64, dtypes.Int64, dtypes.Int64(), dt.Int64, dt.int64]
)
Expand Down
10 changes: 6 additions & 4 deletions tests/ibis/test_ibis_container.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@
@pytest.fixture
def t_basic():
"""Basic Ibis table fixture."""
df = pd.DataFrame({
"string_col": ["0", "1", "2"],
"int_col": [0, 1, 2],
})
df = pd.DataFrame(
{
"string_col": ["0", "1", "2"],
"int_col": [0, 1, 2],
}
)
return ibis.memtable(df, name="t")


Expand Down

0 comments on commit 0dcf7dd

Please sign in to comment.