Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Expression constructors are not mypy-compatible without the pydantic plugin

Aperta
#3,101 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
65/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Tranquilla
Stack tecnologico
python

Direzione di ricerca

Inizia in pyiceberg/expressions/init.py dai costruttori di UnboundPredicate, LiteralPredicate e UnaryPredicate e dalle dichiarazioni dei relativi campi term. Controlla il comportamento esistente del validator, quindi verifica che mypy senza il plugin Pydantic accetti i costruttori dei predicati elencati e che i termini stringa vengano ancora convertiti correttamente a runtime.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.

Example:

from pyiceberg import expressions as ice

expr = ice.EqualTo("my_column", 42)

mypy output (v1.19.1, pyiceberg 0.11.0, no pydantic mypy plugin):

error: Argument 1 to "EqualTo" has incompatible type "str"; expected "UnboundTerm"  [arg-type]

Root cause:

The base classes define explicit __init__ methods that accept str | UnboundTerm:

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.

Lingua principale
Python
Stelle
1.1k
Fork
589
Merge medio
2g 2h
PR unite (30g)
70

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di apache/iceberg-python

Tutte le issue di apache/iceberg-python

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.