Expression constructors are not mypy-compatible without the pydantic plugin
Les mainteneurs répondent en général sous 1 jour
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 3/5
- Temps estimé
- 1-2 jours
- Accessibilité débutants
- 65/100
- Type d'issue
- Bug
- Clarté
- Plutôt claire
- Activité
- Calme
- Stack technique
- python
- Domaine
- developer-experience
Piste de recherche
Commencez dans pyiceberg/expressions/init.py par les constructeurs de UnboundPredicate, LiteralPredicate et UnaryPredicate, ainsi que par les déclarations de leur champ term. Vérifiez le comportement actuel du validateur, puis vérifiez que mypy sans le plugin Pydantic accepte les constructeurs de prédicats indiqués et que les termes de type string sont toujours correctement convertis à l’exécution.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
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:
UnboundPredicate.__init__:def __init__(self, term: str | UnboundTerm, **kwargs: Any) -> NoneLiteralPredicate.__init__:def __init__(self, term: str | UnboundTerm, literal: Any | None = None, **kwargs: Any) -> NoneUnaryPredicate.__init__:def __init__(self, term: str | UnboundTerm, **_: Any) -> None
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.
- Langage dominant
- Python
- Étoiles
- 1.1k
- Forks
- 606
- Merge moyen
- 1 j 11 h
- PR mergées (30 j)
- 76
Préparer son environnement
- Aucun Dockerfile ni fichier Docker Compose
- Propose un modèle de pull request
- Aucun guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de apache/iceberg-python
-
View does not expose metadata_location: RestCatalog.load_view discards it from the server's responsePeut-être pris @Soumo-git-hub l’a pris il y a 1 jour. Ouvertekind:bug
Difficulté 2/5 1-3 heures Accessibilité débutants 84/100
apache/iceberg-python#4073 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 70/100
apache/iceberg-python#4010 · 3 commentaires · 1 réaction ·
Les mainteneurs répondent en général sous 1 jour
-
to_bytes silently rescales a Decimal with a negative scalePeut-être pris @Rodrigo-Palma l’a pris il y a 17 jours. Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
apache/iceberg-python#3996 ·
Les mainteneurs répondent en général sous 1 jour
-
Deletion vector bitmap count is read from the blob and used as a loop bound without validationPeut-être pris @ghoshp83 l’a pris il y a 17 jours. Ouvertebug
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
apache/iceberg-python#3979 ·
Les mainteneurs répondent en général sous 1 jour
-
FsspecFileIO: `_adls` mutates shared properties, so a second storage account gets the first account's filesystemPeut-être pris @krishnakaanchan-png l’a pris il y a 34 jours. Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
apache/iceberg-python#3885 ·
Les mainteneurs répondent en général sous 1 jour
Toutes les issues de apache/iceberg-python
Issues similaires
-
needs triage
Difficulté 2/5 1-3 heures Accessibilité débutants 76/100
Les mainteneurs répondent en général sous 1 jour
-
json_params_matcher fails on falsy top-level JSON primitives (0, False, "")Peut-être pris @mayureshsonawane17 l’a pris aujourd’hui. OuverteWaiting for: Product Owner
Difficulté 2/5 1-3 heures Accessibilité débutants 84/100
Les mainteneurs répondent en général sous 5 jours
-
Difficulté 2/5 1-3 heures Accessibilité débutants 75/100
Les mainteneurs répondent en général sous 1 jour
-
Add .devin pluginOuverte
Difficulté 1/5 Moins d'une heure Accessibilité débutants 88/100
ayghri/i-have-adhd#249 ·
Les mainteneurs répondent en général sous 2 jours
-
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
modelscope/FunASR#3762 ·
Les mainteneurs répondent en général sous 1 jour