-
Notifications
You must be signed in to change notification settings - Fork 1
Added a fallback case for pointers without ["uuid"] #20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -39,7 +39,16 @@ def _get_item_info(item: Any) -> list[str]: | |||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| def _get_pointer(element: Any) -> str: | ||||||||||||||||||||||||||||||||||||||||
| return element["uuid"] if element else None | ||||||||||||||||||||||||||||||||||||||||
| if not element: | ||||||||||||||||||||||||||||||||||||||||
| return None | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| try: | ||||||||||||||||||||||||||||||||||||||||
| return element.get("uuid") | ||||||||||||||||||||||||||||||||||||||||
| except AttributeError: | ||||||||||||||||||||||||||||||||||||||||
| try: | ||||||||||||||||||||||||||||||||||||||||
| return element["uuid"] | ||||||||||||||||||||||||||||||||||||||||
| except (KeyError, TypeError): | ||||||||||||||||||||||||||||||||||||||||
| return None | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+44
to
53
|
||||||||||||||||||||||||||||||||||||||||
| try: | |
| return element.get("uuid") | |
| except AttributeError: | |
| try: | |
| return element["uuid"] | |
| except (KeyError, TypeError): | |
| return None | |
| if hasattr(element, "get"): | |
| return element.get("uuid", None) | |
| elif isinstance(element, dict) and "uuid" in element: | |
| return element["uuid"] | |
| elif hasattr(element, "__getitem__") and "uuid" in element: | |
| try: | |
| return element["uuid"] | |
| except Exception: | |
| return None | |
| return None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using
element.get("uuid")without a default value returnsNonewhen the key doesn't exist, but this could mask the case where the uuid value itself is intentionallyNone. Consider usingelement.get("uuid", None)explicitly or handle the distinction between missing keys andNonevalues.