Skip to content
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

remove unused pkg and update deps #126

Merged
merged 6 commits into from
Oct 22, 2024
Merged

remove unused pkg and update deps #126

merged 6 commits into from
Oct 22, 2024

Conversation

mfshao
Copy link
Contributor

@mfshao mfshao commented Oct 16, 2024

Link to JIRA ticket if there is one: https://ctds-planx.atlassian.net/browse/HP-1589

Improvements

  • improved logic for generating name for array of enums field

Dependency updates

  • update python-json-logger to V2

@mfshao mfshao marked this pull request as ready for review October 17, 2024 15:30
@@ -275,7 +275,10 @@ def _array_type(property_type):
if "description" in property_type:
enum["name"] = property_type["description"]
else:
enum["name"] = property_type["termDef"][0]["term"]
enum["name"] = property_type["term"]["termDef"]["term"]
Copy link
Contributor

@AlbertSnows AlbertSnows Oct 22, 2024

Choose a reason for hiding this comment

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

suggestion: This block can be rewritten as

enum["name"] = (
    property_type.get("description") or 
    property_type["term"]["termDef"]["term"] or 
    property_type["termDef"][0]["term"])

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah I was suppose to write this using .get() somehow I just forgot 🤦

@@ -275,7 +275,10 @@ def _array_type(property_type):
if "description" in property_type:
enum["name"] = property_type["description"]
else:
enum["name"] = property_type["termDef"][0]["term"]
enum["name"] = property_type["term"]["termDef"]["term"]
Copy link
Member

Choose a reason for hiding this comment

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

This should exist but should we do something safer like property_type.get("term", None).get("termDef").get("term") so we know we get a None returned

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah I was suppose to write this using .get() somehow I just forgot 🤦

Copy link
Contributor

Choose a reason for hiding this comment

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

defaulting to None will still be unsafe. If you want to be safe I believe the format would be
result = property_type.get("term", {}).get("termDef", {}).get("term")

Copy link
Member

Choose a reason for hiding this comment

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

yeah this is the right way

AlbertSnows
AlbertSnows previously approved these changes Oct 22, 2024
Copy link
Contributor

@AlbertSnows AlbertSnows left a comment

Choose a reason for hiding this comment

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

Approved with one suggestion. The suggestion is not required to be implemented, but encouraged.

@mfshao mfshao merged commit e81db0b into master Oct 22, 2024
5 checks passed
@mfshao mfshao deleted the chore/relax-dep branch October 22, 2024 20:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants