Skip to content

Commit 47dc596

Browse files
committed
fix: ignore deprecation warnings from pydantic in code gen
see datamodel-code-generator/datamodel-code-generator#2213
1 parent eae9143 commit 47dc596

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

‎src/osw/core.py‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import platform
88
import re
99
import sys
10+
import warnings
1011
from copy import deepcopy
1112
from enum import Enum
1213
from typing import Any, Dict, List, Optional, Type, Union, overload
@@ -17,6 +18,7 @@
1718
import rdflib
1819
from jsonpath_ng.ext import parse
1920
from mwclient.client import Site
21+
from pydantic import PydanticDeprecatedSince20
2022
from pydantic.v1 import BaseModel, Field, PrivateAttr, create_model, validator
2123
from pyld import jsonld
2224

@@ -513,6 +515,9 @@ def _fetch_schema(self, fetchSchemaParam: _FetchSchemaParam = None) -> None:
513515
"
514516
)
515517
else:
518+
# suppress deprecation warnings from pydantic
519+
# see https://github.com/koxudaxi/datamodel-code-generator/issues/2213
520+
warnings.filterwarnings("ignore", category=PydanticDeprecatedSince20)
516521
datamodel_code_generator.generate(
517522
input_=pathlib.Path(schema_path),
518523
input_file_type="jsonschema",
@@ -530,6 +535,7 @@ def _fetch_schema(self, fetchSchemaParam: _FetchSchemaParam = None) -> None:
530535
collapse_root_models=True,
531536
reuse_model=True,
532537
)
538+
warnings.filterwarnings("default", category=PydanticDeprecatedSince20)
533539

534540
# see https://koxudaxi.github.io/datamodel-code-generator/
535541
# --base-class OswBaseModel: use a custom base class

0 commit comments

Comments
 (0)