Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions diffsync/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"""

import sys
from copy import deepcopy
from inspect import isclass
from typing import (
Any,
Expand Down Expand Up @@ -480,6 +481,13 @@ def __init_subclass__(cls) -> None:
if not isclass(value) or not issubclass(value, DiffSyncModel):
raise AttributeError(f'top_level references attribute "{name}" but it is not a DiffSyncModel subclass!')

def __new__(cls, **kwargs): # type: ignore[no-untyped-def]
"""Document keyword arguments that were used to initialize Adapter."""
meta_kwargs = deepcopy(kwargs)
instance = super().__new__(cls)
instance._meta_kwargs = meta_kwargs
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Anything we can/should document about this enhancement?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, can't hurt to have it mentioned but I'm not sure where would be a good place.

return instance

def __str__(self) -> StrType:
"""String representation of an Adapter."""
if self.type != self.name:
Expand Down
4 changes: 2 additions & 2 deletions diffsync/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"""

from collections import OrderedDict
from typing import Iterator, List, Dict, Optional, TypeVar, Callable, Generic
from typing import Callable, Dict, Generic, Iterator, List, Optional, TypeVar

SPACE = " "
BRANCH = "│ "
Expand Down Expand Up @@ -44,7 +44,7 @@ def symmetric_difference(lst1: List[T], lst2: List[T]) -> List[T]:
class OrderedDefaultDict(OrderedDict, Generic[K, V]):
"""A combination of collections.OrderedDict and collections.DefaultDict behavior."""

def __init__(self, dict_type: Callable[[], V]) -> None:
def __init__(self, dict_type: Callable[[], V] = dict) -> None: # type: ignore[assignment]
"""Create a new OrderedDefaultDict."""
self.factory = dict_type
super().__init__(self)
Expand Down
Loading