Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re-enable isort and run on codebase #1295

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
1 change: 0 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ repos:
rev: v5.10.1
hooks:
- id: isort
args: ["--line-length=79", "--skip=docs/source/conf.py", "--diff"]

- repo: https://github.com/ikamensh/flynt
rev: "0.76"
Expand Down
11 changes: 4 additions & 7 deletions pandera/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,17 @@
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.hypotheses import Hypothesis
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.pandas.model_components import Field, check, dataframe_check
from pandera.decorators import check_input, check_io, check_output, check_types
Expand Down Expand Up @@ -57,15 +60,9 @@
UINT64,
pandas_version,
)

import pandera.backends.base.builtin_checks
import pandera.backends.base.builtin_hypotheses
import pandera.backends.pandas

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
4 changes: 2 additions & 2 deletions pandera/api/base/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
import inspect
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/pandas/array.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import copy
import warnings
from typing import Any, List, Optional, TypeVar, Union, cast

import pandas as pd

from pandera import errors
Expand All @@ -13,11 +14,11 @@
from pandera.api.pandas.types import CheckList, PandasDtypeInputTypes, is_field
from pandera.config import CONFIG
from pandera.dtypes import DataType, UniqueSettings
from pandera.engines import pandas_engine, PYDANTIC_V2
from pandera.engines import PYDANTIC_V2, pandas_engine

if PYDANTIC_V2:
from pydantic_core import core_schema
from pydantic import GetCoreSchemaHandler
from pydantic_core import core_schema


TArraySchemaBase = TypeVar("TArraySchemaBase", bound="ArraySchema")
Expand Down
6 changes: 3 additions & 3 deletions pandera/api/pandas/container.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import pandas as pd

from pandera import errors
from pandera.config import CONFIG
from pandera import strategies as st
from pandera.api.base.schema import BaseSchema, inferred_schema_guard
from pandera.api.checks import Check
Expand All @@ -21,12 +20,13 @@
PandasDtypeInputTypes,
StrictType,
)
from pandera.config import CONFIG
from pandera.dtypes import DataType, UniqueSettings
from pandera.engines import pandas_engine, PYDANTIC_V2
from pandera.engines import PYDANTIC_V2, pandas_engine

if PYDANTIC_V2:
from pydantic_core import core_schema
from pydantic import GetCoreSchemaHandler
from pydantic_core import core_schema

N_INDENT_SPACES = 4

Expand Down
2 changes: 1 addition & 1 deletion pandera/api/pandas/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@
from pandera.typing.common import DataFrameBase

if PYDANTIC_V2:
from pydantic import GetCoreSchemaHandler, GetJsonSchemaHandler
from pydantic_core import core_schema
from pydantic import GetJsonSchemaHandler, GetCoreSchemaHandler

try:
from typing_extensions import get_type_hints
Expand Down
2 changes: 1 addition & 1 deletion pandera/api/pyspark/container.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
from pyspark.sql import DataFrame

from pandera import errors
from pandera.config import CONFIG
from pandera.api.base.schema import BaseSchema
from pandera.api.checks import Check
from pandera.api.pyspark.error_handler import ErrorHandler
Expand All @@ -20,6 +19,7 @@
PySparkDtypeInputTypes,
StrictType,
)
from pandera.config import CONFIG

Check warning on line 22 in pandera/api/pyspark/container.py

View check run for this annotation

Codecov / codecov/patch

pandera/api/pyspark/container.py#L22

Added line #L22 was not covered by tests
from pandera.dtypes import DataType, UniqueSettings
from pandera.engines import pyspark_engine

Expand Down
10 changes: 4 additions & 6 deletions pandera/backends/pandas/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,18 @@
from pandera.api.checks import Check
from pandera.api.hypotheses import Hypothesis
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.backends.pandas import builtin_checks, builtin_hypotheses
from pandera.backends.pandas.checks import PandasCheckBackend
from pandera.backends.pandas.hypotheses import PandasHypothesisBackend
from pandera.backends.pandas.array import SeriesSchemaBackend
from pandera.backends.pandas.container import DataFrameSchemaBackend
from pandera.backends.pandas.checks import PandasCheckBackend
from pandera.backends.pandas.components import (
ColumnBackend,
IndexBackend,
MultiIndexBackend,
)

from pandera.backends.pandas.container import DataFrameSchemaBackend
from pandera.backends.pandas.hypotheses import PandasHypothesisBackend

dataframe_datatypes = [pd.DataFrame]
series_datatypes = [pd.Series]
Expand Down
6 changes: 3 additions & 3 deletions pandera/backends/pandas/array.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
"""Pandera array backends."""

from typing import cast, List, Optional
from typing import List, Optional, cast

import pandas as pd
from multimethod import DispatchError

from pandera.backends.base import CoreCheckResult
from pandera.api.pandas.types import is_field
from pandera.backends.base import CoreCheckResult
from pandera.backends.pandas.base import PandasSchemaBackend
from pandera.backends.pandas.error_formatters import (
reshape_failure_cases,
Expand All @@ -17,10 +17,10 @@
from pandera.error_handlers import SchemaErrorHandler
from pandera.errors import (
ParserError,
SchemaDefinitionError,
SchemaError,
SchemaErrorReason,
SchemaErrors,
SchemaDefinitionError,
)


Expand Down
10 changes: 5 additions & 5 deletions pandera/backends/pandas/components.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,22 @@
import numpy as np
import pandas as pd

from pandera.backends.base import CoreCheckResult
from pandera.backends.pandas.array import ArraySchemaBackend
from pandera.backends.pandas.container import DataFrameSchemaBackend
from pandera.api.pandas.types import (
is_field,
is_index,
is_multiindex,
is_table,
)
from pandera.backends.base import CoreCheckResult
from pandera.backends.pandas.array import ArraySchemaBackend
from pandera.backends.pandas.container import DataFrameSchemaBackend
from pandera.backends.pandas.error_formatters import scalar_failure_case
from pandera.error_handlers import SchemaErrorHandler
from pandera.errors import (
SchemaDefinitionError,
SchemaError,
SchemaErrors,
SchemaErrorReason,
SchemaDefinitionError,
SchemaErrors,
)


Expand Down
1 change: 0 additions & 1 deletion pandera/backends/pyspark/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
from pandera.backends.pyspark.components import ColumnBackend
from pandera.backends.pyspark.container import DataFrameSchemaBackend


for t in [pst.DataFrame]:
Check.register_backend(t, PySparkCheckBackend)
ColumnSchema.register_backend(t, ColumnSchemaBackend)
Expand Down
2 changes: 1 addition & 1 deletion pandera/backends/pyspark/column.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@

from pandera.api.pyspark.error_handler import ErrorCategory, ErrorHandler
from pandera.backends.pyspark.base import PysparkSchemaBackend
from pandera.backends.pyspark.decorators import validate_scope, ValidationScope
from pandera.backends.pyspark.decorators import ValidationScope, validate_scope
from pandera.backends.pyspark.error_formatters import scalar_failure_case

Check warning on line 13 in pandera/backends/pyspark/column.py

View check run for this annotation

Codecov / codecov/patch

pandera/backends/pyspark/column.py#L12-L13

Added lines #L12 - L13 were not covered by tests
from pandera.engines.pyspark_engine import Engine
from pandera.errors import ParserError, SchemaError, SchemaErrorReason

Expand Down
2 changes: 1 addition & 1 deletion pandera/backends/pyspark/components.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

from pandera.api.pyspark.error_handler import ErrorCategory, ErrorHandler
from pandera.backends.pyspark.column import ColumnSchemaBackend
from pandera.backends.pyspark.decorators import validate_scope, ValidationScope
from pandera.backends.pyspark.decorators import ValidationScope, validate_scope
from pandera.backends.pyspark.error_formatters import scalar_failure_case
from pandera.errors import SchemaError, SchemaErrorReason

Expand Down
2 changes: 1 addition & 1 deletion pandera/backends/pyspark/container.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
from pandera.backends.pyspark.base import ColumnInfo, PysparkSchemaBackend
from pandera.backends.pyspark.decorators import (
ValidationScope,
validate_scope,
cache_check_obj,
validate_scope,
)
from pandera.backends.pyspark.error_formatters import scalar_failure_case
from pandera.config import CONFIG
Expand Down
1 change: 1 addition & 0 deletions pandera/backends/pyspark/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from typing import List, Type

from pyspark.sql import DataFrame

from pandera.api.pyspark.types import PysparkDefaultTypes
from pandera.config import CONFIG, ValidationDepth
from pandera.errors import SchemaError
Expand Down
1 change: 0 additions & 1 deletion pandera/engines/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,4 @@

from pandera.engines.utils import pydantic_version


PYDANTIC_V2 = pydantic_version().release >= (2, 0, 0)
1 change: 0 additions & 1 deletion pandera/engines/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@

from pandera.dtypes import DataType


# register different TypedDict type depending on python version
if sys.version_info >= (3, 12):
from typing import TypedDict
Expand Down
7 changes: 3 additions & 4 deletions pandera/engines/pandas_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,13 @@

from pandera import dtypes, errors
from pandera.dtypes import immutable
from pandera.engines import engine, numpy_engine, utils
from pandera.engines import PYDANTIC_V2, engine, numpy_engine, utils
from pandera.engines.type_aliases import (
PandasDataType,
PandasExtensionType,
PandasObject,
)
from pandera.engines.utils import pandas_version
from pandera.engines import PYDANTIC_V2
from pandera.system import FLOAT_128_AVAILABLE

if PYDANTIC_V2:
Expand Down Expand Up @@ -1068,10 +1067,10 @@ def from_parametrized_dtype(cls, pd_dtype: pd.IntervalDtype):

if GEOPANDAS_INSTALLED:

from geopandas.array import GeometryArray, GeometryDtype, from_shapely
import pyproj
import shapely
import shapely.geometry
import pyproj
from geopandas.array import GeometryArray, GeometryDtype, from_shapely

GeoPandasObject = Union[
pd.Series, pd.DataFrame, gpd.GeoSeries, gpd.GeoDataFrame
Expand Down
6 changes: 3 additions & 3 deletions pandera/engines/pyspark_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
import dataclasses
import inspect
import re
import warnings
from typing import Any, Iterable, Union, Optional
import sys
from packaging import version
import warnings
from typing import Any, Iterable, Optional, Union

import pyspark
import pyspark.sql.types as pst
from packaging import version

from pandera import dtypes, errors
from pandera.dtypes import immutable
Expand Down
2 changes: 1 addition & 1 deletion pandera/error_handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from typing import List, Optional

from pandera.errors import SchemaError, SchemaErrors, SchemaErrorReason
from pandera.errors import SchemaError, SchemaErrorReason, SchemaErrors


class SchemaErrorHandler:
Expand Down
17 changes: 3 additions & 14 deletions pandera/pyspark.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,11 @@
"""A flexible and expressive pyspark validation library."""
# pylint: disable=unused-import
from pandera.accessors import pyspark_sql_accessor
import pandera.backends.pyspark

Check warning on line 3 in pandera/pyspark.py

View check run for this annotation

Codecov / codecov/patch

pandera/pyspark.py#L3

Added line #L3 was not covered by tests
from pandera.api.checks import Check
from pandera.api.pyspark import Column, DataFrameSchema
from pandera.api.pyspark.model import DataFrameModel, SchemaModel
from pandera.api.pyspark.model_components import (
Field,
check,
dataframe_check,
)
import pandera.backends.pyspark
from pandera.decorators import (
check_input,
check_io,
check_output,
check_types,
)
from pandera.api.pyspark.model_components import Field, check, dataframe_check
from pandera.decorators import check_input, check_io, check_output, check_types

Check warning on line 8 in pandera/pyspark.py

View check run for this annotation

Codecov / codecov/patch

pandera/pyspark.py#L7-L8

Added lines #L7 - L8 were not covered by tests
from pandera.dtypes import (
Bool,
Category,
Expand Down Expand Up @@ -51,7 +41,6 @@
from pandera.typing import pyspark_sql
from pandera.version import __version__


__all__ = [
# dtypes
"Bool",
Expand Down
1 change: 0 additions & 1 deletion pandera/typing/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@
)
from pandera.typing.pandas import DataFrame, Index, Series


DATAFRAME_TYPES: Set[Type] = {DataFrame}
SERIES_TYPES: Set[Type] = {Series}
INDEX_TYPES: Set[Type] = {Index}
Expand Down
2 changes: 1 addition & 1 deletion pandera/typing/fastapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@


if PYDANTIC_V2:
from pydantic_core import core_schema
from pydantic import GetCoreSchemaHandler
from pydantic_core import core_schema


if FASTAPI_INSTALLED:
Expand Down
Loading
Loading