Skip to content

Commit

Permalink
Update deprecated fields in pydantic models of Spanish Wiktionary
Browse files Browse the repository at this point in the history
This work is a contribution to the EWOK project, which receives funding from LABEX ASLAN (ANR–10–LABX–0081) at the Université de Lyon, as part of the "Investissements d'Avenir" program initiated and overseen by the Agence Nationale de la Recherche (ANR) in France.
  • Loading branch information
empiriker committed Nov 28, 2023
1 parent aed70aa commit b3dbc29
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions src/wiktextract/extractor/es/models.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
from typing import Optional
import json

import logging
from typing import Optional

from pydantic import BaseModel, Field, model_validator, ValidationError
from pydantic import (
BaseModel,
ConfigDict,
Field,
ValidationError,
model_validator,
)
from pydantic.json_schema import GenerateJsonSchema

from wiktextract.wxr_context import WiktextractContext
Expand All @@ -23,9 +28,7 @@ def debug(


class BaseModelWrap(BaseModel):
class Config:
extra = "ignore"
validate_assignment = True
model_config = ConfigDict(validate_assignment=True)

def update(self, data: dict):
for k, v in data.items():
Expand All @@ -48,7 +51,7 @@ def __setitem__(self, item, value):
class LoggingExtraFieldsModel(BaseModelWrap):
@model_validator(mode="before")
def log_extra_fields(cls, values):
all_allowed_field_names = {key for key in cls.__fields__.keys()}
all_allowed_field_names = cls.model_fields.keys()
extra_fields = {
name: str(value)
for name, value in values.items()
Expand Down

0 comments on commit b3dbc29

Please sign in to comment.