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

fix(event structure): round values in settratr #6272

Merged
merged 4 commits into from
Dec 21, 2023
Merged

Conversation

unitrium
Copy link
Contributor

Issue

We currently don't have a consistent way of initializing attributes. They are rounded when using the add_value method and not rounded if using __setattr__ directly.

Description

Use the same proceding for both add_value and settatr so they are now consistent.

Double check

  • I have tested my parser changes locally with poetry run test_parser "zone_key"
  • I have run pnpx prettier --write . and poetry run format to format my changes.

@github-actions github-actions bot added the python Pull requests that update Python code label Dec 21, 2023
Copy link
Contributor

PR Analysis

  • 🎯 Main theme: This PR aims to ensure consistency in the initialization of attributes by rounding values in both the add_value method and __setattr__.
  • 📝 PR summary: The PR modifies the add_value and __setattr__ methods in the Mix class to ensure that values are rounded consistently. The __setattr__ method is overridden to round the value and the add_value method is updated to remove the rounding, as it will now be handled by __setattr__.
  • 📌 Type of PR: Bug fix
  • 🧪 Relevant tests added: No
  • ⏱️ Estimated effort to review [1-5]: 2, because the changes are straightforward and limited to a single class. However, the lack of tests increases the review effort slightly.
  • 🔒 Security concerns: No

PR Feedback

  • 💡 General suggestions: It's good that you have made the attribute initialization consistent across methods. However, it would be beneficial to add tests to verify the correct behavior of these changes. This will ensure that the rounding is working as expected and will prevent potential regressions in the future.

  • 🤖 Code feedback:
    relevant fileelectricitymap/contrib/lib/models/events.py
    suggestion      Consider adding a check to ensure that the value being set is indeed a float or None before rounding it. This will prevent potential errors if a non-float value is accidentally passed. [important]
    relevant linereturn super().__setattr__(name, _none_safe_round(value))

How to use

Instructions

To invoke the PR-Agent, add a comment using one of the following commands:
/review: Request a review of your Pull Request.
/describe: Update the PR title and description based on the contents of the PR.
/improve [--extended]: Suggest code improvements. Extended mode provides a higher quality feedback.
/ask <QUESTION>: Ask a question about the PR.
/update_changelog: Update the changelog based on the PR's contents.
/add_docs: Generate docstring for new components introduced in the PR.
/generate_labels: Generate labels for the PR based on the PR's contents.
see the tools guide for more details.

To edit any configuration parameter from the configuration.toml, add --config_path=new_value.
For example: /review --pr_reviewer.extra_instructions="focus on the file: ..."
To list the possible configuration parameters, add a /config comment.

unitrium and others added 2 commits December 21, 2023 13:09
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
@unitrium unitrium merged commit 98bc5c7 into master Dec 21, 2023
19 checks passed
@unitrium unitrium deleted the robin/round-set_attr branch December 21, 2023 13:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
python Pull requests that update Python code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants