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

Switch abstract interfaces to protocols #120

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

WilliamJamieson
Copy link
Collaborator

@WilliamJamieson WilliamJamieson commented Oct 23, 2023

This PR replaces the AbstractDataModel object with a python protocol as described in #118 (comment). This is a bit cleaner than the current implementation.

This PR also implements a ModelContainer protocol which provides the same functionality of #118.

Note that the only functional change is that issubclass will does not function quite correctly due to the missing __hash__ see python/mypy#3939 for a more detailed discussion of this. Since in general the idea of the AbstractDataModel was to provide a way to check if some non-inheriting object instance followed the structure it described, issubclass checks are unnecessary and likely only limited to stpipe itself, which itself makes no such checks.

@codecov
Copy link

codecov bot commented Oct 23, 2023

Codecov Report

Attention: Patch coverage is 88.29787% with 11 lines in your changes missing coverage. Please review.

Project coverage is 95.02%. Comparing base (45d4cde) to head (bea0b91).
Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
src/stpipe/protocols.py 72.22% 5 Missing ⚠️
tests/test_protocols.py 78.26% 5 Missing ⚠️
src/stpipe/config_parser.py 66.66% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##             main     #120       +/-   ##
===========================================
+ Coverage   80.80%   95.02%   +14.22%     
===========================================
  Files          37       39        +2     
  Lines        2849     3195      +346     
===========================================
+ Hits         2302     3036      +734     
+ Misses        547      159      -388     

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

@WilliamJamieson
Copy link
Collaborator Author

@WilliamJamieson WilliamJamieson marked this pull request as ready for review October 24, 2023 20:29
@WilliamJamieson WilliamJamieson requested a review from a team as a code owner October 24, 2023 20:29
@WilliamJamieson WilliamJamieson force-pushed the refactor/protocols branch 3 times, most recently from b4c6fcd to 93bd7eb Compare October 31, 2023 16:32
@WilliamJamieson WilliamJamieson force-pushed the refactor/protocols branch 2 times, most recently from 2c1b09e to b85a10e Compare November 7, 2023 17:46
Copy link
Collaborator

@perrygreenfield perrygreenfield left a comment

Choose a reason for hiding this comment

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

LGTM aside from one docstring that looks like it was mistakenly copied from elsewhere

tests/test_roman.py Outdated Show resolved Hide resolved
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