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

Added docstring and type annotations to family(), removed parameter endpoint #87

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

Conversation

mattkeanny
Copy link
Contributor

Starting with type annotations.
Acc. to ops specs, endpoint is not used in family service. Not used in tests either. Options: either document it in docstring or remove it. Went for second option.
The type annotations are acc. to python 3.6 (although commit comment says py3.8).

Copy link

codecov bot commented Jan 28, 2024

Codecov Report

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

Comparison is base (6bda2ad) 99.76% compared to head (67ff393) 77.54%.

Files Patch % Lines
epo_ops/api.py 80.00% 2 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##             main      #87       +/-   ##
===========================================
- Coverage   99.76%   77.54%   -22.23%     
===========================================
  Files          18       18               
  Lines         428      432        +4     
===========================================
- Hits          427      335       -92     
- Misses          1       97       +96     
Flag Coverage Δ
unittests 77.54% <80.00%> (-22.23%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

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

Copy link
Member

@amotl amotl left a comment

Choose a reason for hiding this comment

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

Hi Matt. Thanks for the contribution. I've added a remark about removing function arguments, maybe you could consider it? Thanks!

epo_ops/api.py Outdated
Comment on lines 38 to 44
def family(self, reference_type, input, endpoint=None, constituents=None):
def family(
self,
reference_type: str,
input: Union[Docdb, Epodoc],
constituents: Optional[List[str]] = None,
):
Copy link
Member

Choose a reason for hiding this comment

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

Acc. to ops specs, endpoint is not used in family service. Not used in tests either. Options: either document it in docstring or remove it. Went for second option.

Removing parameters means a breaking change, so we would need to target this for a 5.x release. Is it possible to move on with type hinting without doing that, and saving it for a subsequent iteration?

Copy link
Member

Choose a reason for hiding this comment

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

In order to prepare the removal, we can issue a deprecation warning when it is used, like:

if endpoint is not None:
    warnings.warn("The `endpoint` argument is not used in this context and will be removed.", DeprecationWarning)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You are quite right, I was a bit too fast on this one. Thanks.

Comment on lines -44 to +85
endpoint=endpoint,
endpoint=None,
Copy link
Member

@amotl amotl Jan 29, 2024

Choose a reason for hiding this comment

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

If we are 100% sure on this, let's do it. Otherwise, it would also be a breaking change, if, by chance, the parameter would still be used/needed in some cases.

Copy link
Contributor Author

@mattkeanny mattkeanny Jan 30, 2024

Choose a reason for hiding this comment

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

I tested the family() method, and the implementation allows endpoint to be assigned one of the allowed values for the parameter constituents and still work as if constituents was assigned the value. Although not according to ops specs, the resulting url when using e.g. endpoint="biblio" is the same as if constituents=["biblio"] was used.
So removing it may indeed break code out there. I'd leave that for a major version upgrade. Fine with the deprecation warning.

Copy link
Member

Choose a reason for hiding this comment

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

Hi Matt. Apologies for the delay.

So removing it may indeed break code out there. I'd leave that for a major version upgrade. Fine with the deprecation warning.

I am currently not totally sure, it has been a while... Do you agree that we want to keep endpoint=endpoint? It looks like the patch hasn't changed yet.

On the other hand, I don't want to be too pedantic about it if you think it will be good to go.

@mattkeanny mattkeanny requested a review from amotl February 9, 2024 19:23
Copy link
Member

@amotl amotl left a comment

Choose a reason for hiding this comment

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

Hi Matt. I agree with your changes, thank you very much for the excellent patch. Let @gsong have a final voice about it if he wants to. Maybe he can spot any flaw I am not able to detect.

Comment on lines -44 to +85
endpoint=endpoint,
endpoint=None,
Copy link
Member

Choose a reason for hiding this comment

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

Hi Matt. Apologies for the delay.

So removing it may indeed break code out there. I'd leave that for a major version upgrade. Fine with the deprecation warning.

I am currently not totally sure, it has been a while... Do you agree that we want to keep endpoint=endpoint? It looks like the patch hasn't changed yet.

On the other hand, I don't want to be too pedantic about it if you think it will be good to go.

@CholoTook
Copy link

Would it help if I check out this branch and use it in my tests?

@mattkeanny
Copy link
Contributor Author

Would it help if I check out this branch and use it in my tests?

@CholoTook would be great, yes.

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.

None yet

3 participants