Type hinting overhaul. by Kircheneer · Pull Request #219 · networktocode/diffsync · GitHub
Skip to content
Merged
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
189 changes: 98 additions & 91 deletions diffsync/__init__.py

Large diffs are not rendered by default.

83 changes: 42 additions & 41 deletions diffsync/diff.py
7 changes: 6 additions & 1 deletion diffsync/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@
See the License for the specific language governing permissions and
limitations under the License.
"""
from typing import TYPE_CHECKING, Union, Any

if TYPE_CHECKING:
from diffsync import DiffSyncModel
from diffsync.diff import DiffElement


class ObjectCrudException(Exception):
Expand All @@ -39,7 +44,7 @@ class ObjectStoreException(Exception):
class ObjectAlreadyExists(ObjectStoreException):
"""Exception raised when trying to store a DiffSyncModel or DiffElement that is already being stored."""

def __init__(self, message, existing_object, *args, **kwargs):
def __init__(self, message: str, existing_object: Union["DiffSyncModel", "DiffElement"], *args: Any, **kwargs: Any):

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Should existing_object just be an Any?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

What other than DiffSyncModel or DiffElement would we store in a store?

"""Add existing_object to the exception to provide user with existing object."""
self.existing_object = existing_object
super().__init__(message, existing_object, *args, **kwargs)
Expand Down
22 changes: 12 additions & 10 deletions diffsync/helpers.py
Loading