[BUG](system) Model constraints from multiple constrained bases are dropped

Aperta
#806 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
48/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
json, python
Ambito
backend

Direzione di ricerca

Start by reading ModelConstraint.get_model_constraints and the forbid_if decorator, then trace how constrained base classes contribute validators and schema constraints during multiple inheritance. Check the related fixes in #784 and #785 for the single inheritance behavior. Done means constraints from both A and B appear in the model constraint list and are enforced when constructing C.

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

Descrizione

When a model inherits from two bases that both carry model constraints (class C(A, B)), the second base's constraints are lost:

  • The model's constraint list comes only from the first base, so JSON Schema and PySpark miss the second base's rules.
  • When both bases use the same constraint kind, Pydantic also enforces only one of them, because the validator names collide.
@forbid_if(["bar"], FieldEqCondition("foo", "a"))
class A(Base): ...

@forbid_if(["baz"], FieldEqCondition("foo", "b"))
class B(Base): ...

class C(A, B): ...

ModelConstraint.get_model_constraints(C)  # only A's constraint
C(foo="b", baz=1)                          # accepted

No schema model does this today.

Related: #784 / #785, which fix the single-inheritance case. And mentioned this potential issue.

Lingua principale
Python
Stelle
219
Fork
20
Merge medio
1g 21h
PR unite (30g)
37

Preparare l'ambiente

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 OvertureMaps/schema

Tutte le issue di OvertureMaps/schema

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.