Skip to content

Commit

Permalink
Ignore dynamically created imports in mypy.
Browse files Browse the repository at this point in the history
  • Loading branch information
evetion committed Sep 12, 2023
1 parent bcb893f commit 8ba0274
Show file tree
Hide file tree
Showing 13 changed files with 34 additions and 28 deletions.
2 changes: 1 addition & 1 deletion python/ribasim/ribasim/node_types/basin.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from pandera.typing import DataFrame

from ribasim.input_base import TableModel
from ribasim.schemas import (
from ribasim.schemas import ( # type: ignore
BasinForcingSchema,
BasinProfileSchema,
BasinStateSchema,
Expand Down
5 changes: 4 additions & 1 deletion python/ribasim/ribasim/node_types/discrete_control.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
from pandera.typing import DataFrame

from ribasim.input_base import TableModel
from ribasim.schemas import DiscreteControlConditionSchema, DiscreteControlLogicSchema
from ribasim.schemas import ( # type: ignore
DiscreteControlConditionSchema,
DiscreteControlLogicSchema,
)

__all__ = ("DiscreteControl",)

Expand Down
5 changes: 4 additions & 1 deletion python/ribasim/ribasim/node_types/flow_boundary.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
from pandera.typing import DataFrame

from ribasim.input_base import TableModel
from ribasim.schemas import FlowBoundaryStaticSchema, FlowBoundaryTimeSchema
from ribasim.schemas import ( # type: ignore
FlowBoundaryStaticSchema,
FlowBoundaryTimeSchema,
)

__all__ = ("FlowBoundary",)

Expand Down
2 changes: 1 addition & 1 deletion python/ribasim/ribasim/node_types/fractional_flow.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from pandera.typing import DataFrame

from ribasim.input_base import TableModel
from ribasim.schemas import FractionalFlowStaticSchema
from ribasim.schemas import FractionalFlowStaticSchema # type: ignore

__all__ = ("FractionalFlow",)

Expand Down
5 changes: 4 additions & 1 deletion python/ribasim/ribasim/node_types/level_boundary.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
from pandera.typing import DataFrame

from ribasim.input_base import TableModel
from ribasim.schemas import LevelBoundaryStaticSchema, LevelBoundaryTimeSchema
from ribasim.schemas import ( # type: ignore
LevelBoundaryStaticSchema,
LevelBoundaryTimeSchema,
)

__all__ = ("LevelBoundary",)

Expand Down
2 changes: 1 addition & 1 deletion python/ribasim/ribasim/node_types/linear_resistance.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from pandera.typing import DataFrame

from ribasim.input_base import TableModel
from ribasim.schemas import LinearResistanceStaticSchema
from ribasim.schemas import LinearResistanceStaticSchema # type: ignore

__all__ = ("LinearResistance",)

Expand Down
2 changes: 1 addition & 1 deletion python/ribasim/ribasim/node_types/manning_resistance.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from pandera.typing import DataFrame

from ribasim.input_base import TableModel
from ribasim.schemas import ManningResistanceStaticSchema
from ribasim.schemas import ManningResistanceStaticSchema # type: ignore

__all__ = ("ManningResistance",)

Expand Down
2 changes: 1 addition & 1 deletion python/ribasim/ribasim/node_types/outlet.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from pandera.typing import DataFrame

from ribasim.input_base import TableModel
from ribasim.schemas import OutletStaticSchema
from ribasim.schemas import OutletStaticSchema # type: ignore

__all__ = ("Outlet",)

Expand Down
2 changes: 1 addition & 1 deletion python/ribasim/ribasim/node_types/pid_control.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from pandera.typing import DataFrame

from ribasim.input_base import TableModel
from ribasim.schemas import PidControlStaticSchema, PidControlTimeSchema
from ribasim.schemas import PidControlStaticSchema, PidControlTimeSchema # type: ignore

__all__ = ("PidControl",)

Expand Down
2 changes: 1 addition & 1 deletion python/ribasim/ribasim/node_types/pump.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from pandera.typing import DataFrame

from ribasim.input_base import TableModel
from ribasim.schemas import PumpStaticSchema
from ribasim.schemas import PumpStaticSchema # type: ignore

__all__ = ("Pump",)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from pandera.typing import DataFrame

from ribasim.input_base import TableModel
from ribasim.schemas import (
from ribasim.schemas import ( # type: ignore
TabulatedRatingCurveStaticSchema,
TabulatedRatingCurveTimeSchema,
)
Expand Down
2 changes: 1 addition & 1 deletion python/ribasim/ribasim/node_types/terminal.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from pandera.typing import DataFrame

from ribasim.input_base import TableModel
from ribasim.schemas import TerminalStaticSchema
from ribasim.schemas import TerminalStaticSchema # type: ignore

__all__ = ("Terminal",)

Expand Down
29 changes: 13 additions & 16 deletions python/ribasim/ribasim/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Generate Pandera Schemas from all autogenerated Pydantic Models
These classes have Schema as a postfix, so Ribasim.models.PumpStatic
becomes Ribasim.node_types.PumpStaticSchema.
becomes Ribasim.schemas.PumpStaticSchema.
"""
import inspect
import sys
Expand All @@ -14,22 +14,19 @@


def gen_schema(name, cls):
classname = f"{name}Schema"
setattr(
sys.modules[__name__],
classname,
type(
classname,
(pa.DataFrameModel,),
{
"Config": type(
f"{classname}.Config",
(),
{"dtype": PydanticModel(cls), "coerce": True},
)
},
),
cname = f"{name}Schema"
ctype = type(
cname,
(pa.DataFrameModel,),
{
"Config": type(
f"{cname}.Config",
(),
{"dtype": PydanticModel(cls), "coerce": True},
)
},
)
setattr(sys.modules[__name__], cname, ctype)


for name, cls in inspect.getmembers(models, inspect.isclass):
Expand Down

0 comments on commit 8ba0274

Please sign in to comment.