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 inherited readonly props #560

Conversation

ehennestad
Copy link
Collaborator

@ehennestad ehennestad commented Feb 5, 2024

Motivation

Some schema attributes are redefined to be readonly for inherited classes. In MATLAB a property attribute can not be redefined for subclasses, so it was possible to set readonly properties.

How to test the behavior?

es = types.core.ElectricalSeries()
es.data_unit = 'volt' % works
es.data_unit = 'millivolts' % should not work

Checklist

  • Have you ensured the PR description clearly describes the problem and solutions?
  • Have you checked to ensure that there aren't other open or previously closed Pull Requests for the same change?
  • If this PR fixes an issue, is the first line of the PR description fix #XX where XX is the issue number?

Some readonly props are inherited from superclasses where the same prop is settable. This will override the validator method for such a property to throw an error if someone tries to set a readonly property
@lawrence-mbf lawrence-mbf self-requested a review February 6, 2024 14:27
@lawrence-mbf
Copy link
Collaborator

@ehennestad This is not kosher but could you apply the fix mentioned in here: #262 (comment) as most of the errors in these tests come from there.

@ehennestad
Copy link
Collaborator Author

ehennestad commented Feb 6, 2024

The failed test is actually a good sign!

Error using types.core/ElectricalSeries/validate_data_unit
Unable to set the 'data_unit' property of class '<a href="matlab:doc
types.core.ElectricalSeries">ElectricalSeries</a>' because it is read-only.

Fix test that broke because of current PR
lawrence-mbf
lawrence-mbf previously approved these changes Feb 6, 2024
Copy link
Collaborator

@lawrence-mbf lawrence-mbf left a comment

Choose a reason for hiding this comment

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

lgtm

Copy link

codecov bot commented Feb 6, 2024

Codecov Report

Attention: 1 lines in your changes are missing coverage. Please review.

Comparison is base (9d77234) 88.49% compared to head (d8d18f0) 88.52%.

Files Patch % Lines
+file/fillValidators.m 95.83% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #560      +/-   ##
==========================================
+ Coverage   88.49%   88.52%   +0.02%     
==========================================
  Files         104      104              
  Lines        4616     4636      +20     
==========================================
+ Hits         4085     4104      +19     
- Misses        531      532       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Only add validator for inherited readonly props
Also support boolean read only property values
@ehennestad ehennestad closed this Feb 8, 2024
@ehennestad ehennestad reopened this Feb 8, 2024
@lawrence-mbf lawrence-mbf merged commit 5396243 into NeurodataWithoutBorders:master Feb 8, 2024
4 of 5 checks passed
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.

2 participants