You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Expression constructors are not mypy-compatible without the pydantic plugin #3101
Constructing expression predicates like EqualTo("col", value) produces mypy errors because the Pydantic model field declarations use UnboundTerm as the type for term, and without the pydantic mypy plugin active, mypy generates __init__ signatures from the field types rather than from the explicit __init__ overrides.
But since these classes extend IcebergBaseModel (Pydantic BaseModel), mypy ignores the explicit __init__ and instead generates the constructor signature from the field declaration term: UnboundTerm, which does not include str.
This affects all predicate constructors: EqualTo, NotEqualTo, GreaterThan, GreaterThanOrEqual, LessThan, LessThanOrEqual, IsNull, NotNull, IsNaN, NotNaN, In, NotIn, StartsWith, NotStartsWith.
Workaround:
Downstream projects can either enable the pydantic mypy plugin or suppress type checking for the affected call sites.
Possible fix:
Widen the field type annotation on UnboundPredicate from term: UnboundTerm to term: str | UnboundTerm with a validator that coerces str to UnboundTerm. This way the type seen by mypy (from the field declaration) matches what the constructor actually accepts at runtime, regardless of whether the pydantic mypy plugin is enabled.
I've opened #3421 to address this by widening the term field type to Annotated[str | UnboundTerm, BeforeValidator(_to_unbound_term)]. This makes mypy accept str in the constructor without requiring the pydantic plugin.
Activity
[Feature][DataLoader] Add mypy static type checking
[Feature][DataLoader] Add mypy static type checking (#472)
aashish-g03 commentedon May 27, 2026
I've opened #3421 to address this by widening the
termfield type toAnnotated[str | UnboundTerm, BeforeValidator(_to_unbound_term)]. This makes mypy acceptstrin the constructor without requiring the pydantic plugin.