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

chore: Update Disruption model fields to be optional #63

Merged
merged 2 commits into from
Jul 23, 2024

Conversation

mnbf9rca
Copy link
Owner

@mnbf9rca mnbf9rca commented Jul 23, 2024

Make the 'summary', 'additional_info', 'created', and 'last_update' fields in the Disruption model optional by setting their default value to None. This allows for more flexibility when creating instances of the Disruption class and handling data that may not always be available.

Summary by Sourcery

This pull request updates the 'Disruption' model to make several fields optional, enhancing flexibility when creating instances. Additionally, test configurations were updated to align with these changes.

  • Enhancements:
    • Updated the 'Disruption' model to make the 'summary', 'additional_info', 'created', and 'last_update' fields optional by setting their default value to None.
  • Tests:
    • Modified test configurations to reflect the change in the 'Disruption' model, replacing 'Line' with 'Disruption' in relevant test cases.

Make the 'summary', 'additional_info', 'created', and 'last_update' fields in the Disruption model optional by setting their default value to None. This allows for more flexibility when creating instances of the Disruption class and handling data that may not always be available.
Copy link

sourcery-ai bot commented Jul 23, 2024

Reviewer's Guide by Sourcery

This pull request updates the Disruption model to make the 'summary', 'additional_info', 'created', and 'last_update' fields optional by setting their default value to None. This change allows for more flexibility when creating instances of the Disruption class and handling data that may not always be available.

File-Level Changes

Files Changes
pydantic_tfl_api/models/disruption.py Made the 'summary', 'additional_info', 'created', and 'last_update' fields optional in the Disruption model.
tests/config_for_tests.py Updated test configurations to use the 'Disruption' model instead of the 'Line' model.

Tips
  • Trigger a new Sourcery review by commenting @sourcery-ai review on the pull request.
  • Continue your discussion with Sourcery by replying directly to review comments.
  • You can change your review settings at any time by accessing your dashboard:
    • Enable or disable the Sourcery-generated pull request summary or reviewer's guide;
    • Change the review language;
  • You can always contact us if you have any questions or feedback.

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @mnbf9rca - I've reviewed your changes and they look great!

Here's what I looked at during the review
  • 🟡 General issues: 1 issue found
  • 🟢 Security: all looks good
  • 🟡 Testing: 1 issue found
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment to tell me if it was helpful.

summary: Optional[str] = Field(None, alias='summary')
additional_info: Optional[str] = Field(None, alias='additionalInfo')
created: Optional[datetime] = Field(None, alias='created')
last_update: Optional[datetime] = Field(None, alias='lastUpdate')
Copy link

Choose a reason for hiding this comment

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

issue: Handling of last_update being optional.

The last_update field is crucial for tracking changes. Making it optional could lead to issues in tracking the state of disruptions. Ensure that the logic accounts for None values appropriately.

@@ -157,35 +157,35 @@
"endpoint": "lineDisruptionsByLineId",
"endpoint_args": ["victoria,northern"],
"endpoint_params": {},
"model": "Line",
"model": "Disruption",
Copy link

Choose a reason for hiding this comment

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

suggestion (testing): Update test cases to reflect optional fields

Since the 'summary', 'additional_info', 'created', and 'last_update' fields in the Disruption model are now optional, it would be beneficial to add test cases that create Disruption instances without these fields to ensure the model handles these scenarios correctly.

Suggested change
"model": "Disruption",
"model": "Disruption",
"summary": None,
"additional_info": None,
"created": None,
"last_update": None,

@mnbf9rca mnbf9rca merged commit add357e into main Jul 23, 2024
5 checks passed
@mnbf9rca mnbf9rca deleted the fix/incorrect-model-test-mappiong branch July 23, 2024 11:17
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.

1 participant