Skip to content

Commit

Permalink
fix: converter not returning singleton, move __init__ to __new__ method
Browse files Browse the repository at this point in the history
  • Loading branch information
ketozhang committed Nov 17, 2024
1 parent 28a01b5 commit 4579181
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions asdf_pydantic/converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ class AsdfPydanticConverter(Converter):

_tag_to_class: dict[str, Type[AsdfPydanticModel]] = {}

def __init__(self) -> None:
global _ASDF_PYDANTIC_SINGLETON_CONVERTER

def __new__(cls, *args, **kwargs):
global _ASDF_PYDANTIC_SINGLETON_CONVERTER
if _ASDF_PYDANTIC_SINGLETON_CONVERTER is None:
_ASDF_PYDANTIC_SINGLETON_CONVERTER = self
_ASDF_PYDANTIC_SINGLETON_CONVERTER = super().__new__(cls)

self = _ASDF_PYDANTIC_SINGLETON_CONVERTER
return _ASDF_PYDANTIC_SINGLETON_CONVERTER

@classmethod
def add_models(
Expand Down

0 comments on commit 4579181

Please sign in to comment.