Skip to content

Commit

Permalink
Create a common DataFrameSchema class, update mypy used in pre-commit (
Browse files Browse the repository at this point in the history
…#1609)

* define common dataframe api for DataFrameSchema

Signed-off-by: cosmicBboy <niels.bantilan@gmail.com>

* use mypy 1.10.0 for pre-commit

Signed-off-by: cosmicBboy <niels.bantilan@gmail.com>

* regenerate requirements files

Signed-off-by: cosmicBboy <niels.bantilan@gmail.com>

* fix lint

Signed-off-by: cosmicBboy <niels.bantilan@gmail.com>

* update pre-commit

Signed-off-by: cosmicBboy <niels.bantilan@gmail.com>

* run updated black, isort

Signed-off-by: cosmicBboy <niels.bantilan@gmail.com>

* update isort

Signed-off-by: cosmicBboy <niels.bantilan@gmail.com>

* add isort config to pyproject.toml

Signed-off-by: cosmicBboy <niels.bantilan@gmail.com>

* revert isort, black

Signed-off-by: cosmicBboy <niels.bantilan@gmail.com>

* revert black, isort

Signed-off-by: cosmicBboy <niels.bantilan@gmail.com>

---------

Signed-off-by: cosmicBboy <niels.bantilan@gmail.com>
  • Loading branch information
cosmicBboy committed May 1, 2024
1 parent 1305d93 commit d058f71
Show file tree
Hide file tree
Showing 144 changed files with 1,731 additions and 1,715 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Expand Up @@ -45,7 +45,7 @@ repos:
exclude: (^docs/|^scripts)

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.982
rev: v1.10.0
hooks:
- id: mypy
additional_dependencies:
Expand Down
3 changes: 2 additions & 1 deletion .pylintrc
Expand Up @@ -54,4 +54,5 @@ disable=
fixme,
too-many-locals,
redefined-outer-name,
logging-fstring-interpolation
logging-fstring-interpolation,
multiple-statements
2 changes: 1 addition & 1 deletion ci/requirements-py3.10-pandas1.5.3-pydantic1.10.11.txt
Expand Up @@ -287,7 +287,7 @@ msgpack==1.0.8
# distributed
# ray
multimethod==1.10
mypy==0.982
mypy==1.10.0
mypy-extensions==1.0.0
# via
# black
Expand Down
2 changes: 1 addition & 1 deletion ci/requirements-py3.10-pandas1.5.3-pydantic2.3.0.txt
Expand Up @@ -289,7 +289,7 @@ msgpack==1.0.8
# distributed
# ray
multimethod==1.10
mypy==0.982
mypy==1.10.0
mypy-extensions==1.0.0
# via
# black
Expand Down
2 changes: 1 addition & 1 deletion ci/requirements-py3.10-pandas2.0.3-pydantic1.10.11.txt
Expand Up @@ -291,7 +291,7 @@ msgpack==1.0.8
# distributed
# ray
multimethod==1.10
mypy==0.982
mypy==1.10.0
mypy-extensions==1.0.0
# via
# black
Expand Down
2 changes: 1 addition & 1 deletion ci/requirements-py3.10-pandas2.0.3-pydantic2.3.0.txt
Expand Up @@ -293,7 +293,7 @@ msgpack==1.0.8
# distributed
# ray
multimethod==1.10
mypy==0.982
mypy==1.10.0
mypy-extensions==1.0.0
# via
# black
Expand Down
2 changes: 1 addition & 1 deletion ci/requirements-py3.10-pandas2.2.0-pydantic1.10.11.txt
Expand Up @@ -291,7 +291,7 @@ msgpack==1.0.8
# distributed
# ray
multimethod==1.10
mypy==0.982
mypy==1.10.0
mypy-extensions==1.0.0
# via
# black
Expand Down
2 changes: 1 addition & 1 deletion ci/requirements-py3.10-pandas2.2.0-pydantic2.3.0.txt
Expand Up @@ -293,7 +293,7 @@ msgpack==1.0.8
# distributed
# ray
multimethod==1.10
mypy==0.982
mypy==1.10.0
mypy-extensions==1.0.0
# via
# black
Expand Down
2 changes: 1 addition & 1 deletion ci/requirements-py3.11-pandas1.5.3-pydantic1.10.11.txt
Expand Up @@ -281,7 +281,7 @@ msgpack==1.0.8
# distributed
# ray
multimethod==1.10
mypy==0.982
mypy==1.10.0
mypy-extensions==1.0.0
# via
# black
Expand Down
2 changes: 1 addition & 1 deletion ci/requirements-py3.11-pandas1.5.3-pydantic2.3.0.txt
Expand Up @@ -283,7 +283,7 @@ msgpack==1.0.8
# distributed
# ray
multimethod==1.10
mypy==0.982
mypy==1.10.0
mypy-extensions==1.0.0
# via
# black
Expand Down
2 changes: 1 addition & 1 deletion ci/requirements-py3.11-pandas2.0.3-pydantic1.10.11.txt
Expand Up @@ -285,7 +285,7 @@ msgpack==1.0.8
# distributed
# ray
multimethod==1.10
mypy==0.982
mypy==1.10.0
mypy-extensions==1.0.0
# via
# black
Expand Down
2 changes: 1 addition & 1 deletion ci/requirements-py3.11-pandas2.0.3-pydantic2.3.0.txt
Expand Up @@ -287,7 +287,7 @@ msgpack==1.0.8
# distributed
# ray
multimethod==1.10
mypy==0.982
mypy==1.10.0
mypy-extensions==1.0.0
# via
# black
Expand Down
2 changes: 1 addition & 1 deletion ci/requirements-py3.11-pandas2.2.0-pydantic1.10.11.txt
Expand Up @@ -285,7 +285,7 @@ msgpack==1.0.8
# distributed
# ray
multimethod==1.10
mypy==0.982
mypy==1.10.0
mypy-extensions==1.0.0
# via
# black
Expand Down
2 changes: 1 addition & 1 deletion ci/requirements-py3.11-pandas2.2.0-pydantic2.3.0.txt
Expand Up @@ -287,7 +287,7 @@ msgpack==1.0.8
# distributed
# ray
multimethod==1.10
mypy==0.982
mypy==1.10.0
mypy-extensions==1.0.0
# via
# black
Expand Down
2 changes: 1 addition & 1 deletion ci/requirements-py3.8-pandas1.5.3-pydantic1.10.11.txt
Expand Up @@ -303,7 +303,7 @@ msgpack==1.0.8
# distributed
# ray
multimethod==1.10
mypy==0.982
mypy==1.10.0
mypy-extensions==1.0.0
# via
# black
Expand Down
2 changes: 1 addition & 1 deletion ci/requirements-py3.8-pandas1.5.3-pydantic2.3.0.txt
Expand Up @@ -305,7 +305,7 @@ msgpack==1.0.8
# distributed
# ray
multimethod==1.10
mypy==0.982
mypy==1.10.0
mypy-extensions==1.0.0
# via
# black
Expand Down
2 changes: 1 addition & 1 deletion ci/requirements-py3.8-pandas2.0.3-pydantic1.10.11.txt
Expand Up @@ -303,7 +303,7 @@ msgpack==1.0.8
# distributed
# ray
multimethod==1.10
mypy==0.982
mypy==1.10.0
mypy-extensions==1.0.0
# via
# black
Expand Down
2 changes: 1 addition & 1 deletion ci/requirements-py3.8-pandas2.0.3-pydantic2.3.0.txt
Expand Up @@ -305,7 +305,7 @@ msgpack==1.0.8
# distributed
# ray
multimethod==1.10
mypy==0.982
mypy==1.10.0
mypy-extensions==1.0.0
# via
# black
Expand Down
2 changes: 1 addition & 1 deletion ci/requirements-py3.9-pandas1.5.3-pydantic1.10.11.txt
Expand Up @@ -295,7 +295,7 @@ msgpack==1.0.8
# distributed
# ray
multimethod==1.10
mypy==0.982
mypy==1.10.0
mypy-extensions==1.0.0
# via
# black
Expand Down
2 changes: 1 addition & 1 deletion ci/requirements-py3.9-pandas1.5.3-pydantic2.3.0.txt
Expand Up @@ -297,7 +297,7 @@ msgpack==1.0.8
# distributed
# ray
multimethod==1.10
mypy==0.982
mypy==1.10.0
mypy-extensions==1.0.0
# via
# black
Expand Down
2 changes: 1 addition & 1 deletion ci/requirements-py3.9-pandas2.0.3-pydantic1.10.11.txt
Expand Up @@ -299,7 +299,7 @@ msgpack==1.0.8
# distributed
# ray
multimethod==1.10
mypy==0.982
mypy==1.10.0
mypy-extensions==1.0.0
# via
# black
Expand Down
2 changes: 1 addition & 1 deletion ci/requirements-py3.9-pandas2.0.3-pydantic2.3.0.txt
Expand Up @@ -301,7 +301,7 @@ msgpack==1.0.8
# distributed
# ray
multimethod==1.10
mypy==0.982
mypy==1.10.0
mypy-extensions==1.0.0
# via
# black
Expand Down
2 changes: 1 addition & 1 deletion ci/requirements-py3.9-pandas2.2.0-pydantic1.10.11.txt
Expand Up @@ -299,7 +299,7 @@ msgpack==1.0.8
# distributed
# ray
multimethod==1.10
mypy==0.982
mypy==1.10.0
mypy-extensions==1.0.0
# via
# black
Expand Down
2 changes: 1 addition & 1 deletion ci/requirements-py3.9-pandas2.2.0-pydantic2.3.0.txt
Expand Up @@ -301,7 +301,7 @@ msgpack==1.0.8
# distributed
# ray
multimethod==1.10
mypy==0.982
mypy==1.10.0
mypy-extensions==1.0.0
# via
# black
Expand Down
2 changes: 1 addition & 1 deletion dev/requirements-3.10.txt
Expand Up @@ -293,7 +293,7 @@ msgpack==1.0.8
# distributed
# ray
multimethod==1.10
mypy==0.982
mypy==1.10.0
mypy-extensions==1.0.0
# via
# black
Expand Down
2 changes: 1 addition & 1 deletion dev/requirements-3.11.txt
Expand Up @@ -287,7 +287,7 @@ msgpack==1.0.8
# distributed
# ray
multimethod==1.10
mypy==0.982
mypy==1.10.0
mypy-extensions==1.0.0
# via
# black
Expand Down
2 changes: 1 addition & 1 deletion dev/requirements-3.8.txt
Expand Up @@ -305,7 +305,7 @@ msgpack==1.0.8
# distributed
# ray
multimethod==1.10
mypy==0.982
mypy==1.10.0
mypy-extensions==1.0.0
# via
# black
Expand Down
2 changes: 1 addition & 1 deletion dev/requirements-3.9.txt
Expand Up @@ -301,7 +301,7 @@ msgpack==1.0.8
# distributed
# ray
multimethod==1.10
mypy==0.982
mypy==1.10.0
mypy-extensions==1.0.0
# via
# black
Expand Down
2 changes: 1 addition & 1 deletion environment.yml
Expand Up @@ -47,7 +47,7 @@ dependencies:
# testing
- isort >= 5.7.0
- joblib
- mypy = 0.982
- mypy = 1.10.0
- pylint <= 2.17.3
- pytest
- pytest-cov
Expand Down
1 change: 1 addition & 0 deletions noxfile.py
@@ -1,4 +1,5 @@
"""Nox sessions."""

# isort: skip_file
import os
import re
Expand Down
19 changes: 8 additions & 11 deletions pandera/__init__.py
Expand Up @@ -3,23 +3,27 @@
import platform

import pandera.backends
import pandera.backends.base.builtin_checks
import pandera.backends.base.builtin_hypotheses
import pandera.backends.pandas
from pandera import errors, external_config, typing
from pandera.accessors import pandas_accessor
from pandera.api import extensions
from pandera.api.checks import Check
from pandera.api.parsers import Parser
from pandera.api.dataframe.model_components import (
Field,
check,
dataframe_check,
parser,
dataframe_parser,
parser,
)
from pandera.api.hypotheses import Hypothesis
from pandera.api.dataframe.model_components import Field
from pandera.api.pandas.array import SeriesSchema
from pandera.api.pandas.container import DataFrameSchema
from pandera.api.pandas.components import Column, Index, MultiIndex
from pandera.api.pandas.container import DataFrameSchema
from pandera.api.pandas.model import DataFrameModel, SchemaModel
from pandera.api.parsers import Parser
from pandera.backends.pandas.register import register_pandas_backends
from pandera.decorators import check_input, check_io, check_output, check_types
from pandera.dtypes import (
Bool,
Expand Down Expand Up @@ -65,16 +69,9 @@
UINT64,
pandas_version,
)

import pandera.backends.base.builtin_checks
import pandera.backends.base.builtin_hypotheses
import pandera.backends.pandas
from pandera.backends.pandas.register import register_pandas_backends

from pandera.schema_inference.pandas import infer_schema
from pandera.version import __version__


if platform.system() != "Windows":
# pylint: disable=ungrouped-imports
from pandera.dtypes import Complex256, Float128
Expand Down
2 changes: 1 addition & 1 deletion pandera/accessors/pyspark_sql_accessor.py
Expand Up @@ -4,8 +4,8 @@
import warnings
from typing import Optional

from pandera.api.pyspark.container import DataFrameSchema
from pandera.api.base.error_handler import ErrorHandler
from pandera.api.pyspark.container import DataFrameSchema

Schemas = DataFrameSchema # type: ignore
Errors = ErrorHandler # type: ignore
Expand Down
2 changes: 1 addition & 1 deletion pandera/api/base/checks.py
Expand Up @@ -162,7 +162,7 @@ def from_builtin_check_name(
name: str,
init_kwargs,
error: Union[str, Callable],
statistics: Dict[str, Any] = None,
statistics: Optional[Dict[str, Any]] = None,
**check_kwargs,
):
"""Create a Check object from a built-in check's name."""
Expand Down
4 changes: 2 additions & 2 deletions pandera/api/base/error_handler.py
Expand Up @@ -5,9 +5,9 @@
from typing import Any, Dict, List, Union

from pandera.api.checks import Check
from pandera.config import get_config_context, ValidationDepth
from pandera.validation_depth import ValidationScope, validation_type
from pandera.config import ValidationDepth, get_config_context
from pandera.errors import SchemaError, SchemaErrorReason
from pandera.validation_depth import ValidationScope, validation_type


class ErrorCategory(Enum):
Expand Down
9 changes: 1 addition & 8 deletions pandera/api/base/parsers.py
@@ -1,14 +1,7 @@
"""Data validation base parse."""

import inspect
from typing import (
Any,
Dict,
NamedTuple,
Optional,
Tuple,
Type,
)
from typing import Any, Dict, NamedTuple, Optional, Tuple, Type

from pandera.backends.base import BaseParserBackend

Expand Down
4 changes: 2 additions & 2 deletions pandera/api/base/schema.py
Expand Up @@ -9,11 +9,11 @@
import os
from abc import ABC
from functools import wraps
from typing import Any, Dict, Tuple, Type, Optional, Union
from typing import Any, Dict, Optional, Tuple, Type, Union

from pandera.backends.base import BaseSchemaBackend
from pandera.errors import BackendNotFoundError
from pandera.dtypes import DataType
from pandera.errors import BackendNotFoundError

DtypeInputTypes = Union[str, type, DataType, Type]

Expand Down
5 changes: 3 additions & 2 deletions pandera/api/base/types.py
@@ -1,15 +1,16 @@
"""Base type definitions for pandera."""

from typing import List, Union

from pandera.api.checks import Check
from pandera.api.parsers import Parser
from pandera.api.hypotheses import Hypothesis
from pandera.api.parsers import Parser

try:
# python 3.8+
from typing import Literal # type: ignore[attr-defined]
except ImportError: # pragma: no cover
from typing_extensions import Literal # type: ignore[misc]
from typing_extensions import Literal # type: ignore[assignment]


StrictType = Union[bool, Literal["filter"]]
Expand Down

0 comments on commit d058f71

Please sign in to comment.