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

Fail early when rounds' attributes are missing #2294

Merged
merged 5 commits into from
Jan 17, 2025

Conversation

Adamantios
Copy link
Collaborator

@Adamantios Adamantios commented Jan 17, 2025

Proposed changes

Some base rounds require a number of base attributes to be defined by the superclasses. For example, none_type on CollectSameUntilThresholdRound.

If the superclass fails to initialize these attributes, the business logic will proceed without a warning. However, if during the execution variable is required to launch an event, it will crash the application when accessing that attribute.

Fixes

Closes #2246.

Types of changes

What types of changes does your code introduce? (A breaking change is a fix or feature that would cause existing functionality and APIs to not work as expected.)
Put an x in the box that applies

  • Non-breaking fix (non-breaking change which fixes an issue)
  • Breaking fix (breaking change which fixes an issue)
  • Non-breaking feature (non-breaking change which adds functionality)
  • Breaking feature (breaking change which adds functionality)
  • Refactor (non-breaking change which changes implementation)
  • Messy (mixture of the above - requires explanation!)

Checklist

Put an x in the boxes that apply.

  • I have read the CONTRIBUTING doc
  • I am making a pull request against the main branch (left side). Also you should start your branch off our main.
  • Lint and unit tests pass locally with my changes
  • I have added tests that prove my fix is effective or that my feature works
  • I have locally run services that could be impacted and they do not present failures derived from my changes
  • Public-facing documentation has been updated with the changes affected by this PR. Even if the provided contents are not in their final form, all significant information must be included.
  • Any backwards-incompatible/breaking change has been clearly documented in the upgrading document.

Further comments

n/a

This commit improves the checks for the rounds' attributes by:
1. Failing early and not when the round is instantiated -> check moved from `AbstractRound` round's `__init__` to the `_MetaAbstractRound` metaclass.
2. Introduces the `extended_requirements` attribute to separate it from the `required_class_attributes` attribute which contains mandatory fields for any type of round.
@Adamantios Adamantios force-pushed the fix/required-attributes branch from c1eb718 to ef84fd2 Compare January 17, 2025 13:42
@Adamantios Adamantios merged commit 005353b into main Jan 17, 2025
23 checks passed
@Adamantios Adamantios deleted the fix/required-attributes branch January 17, 2025 16:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Enforce superclasses of base rounds to always define required attributes
3 participants