Skip to content

fix: add a check to ensure the MRO is correct #1352

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

Merged
merged 2 commits into from
Apr 27, 2021
Merged

fix: add a check to ensure the MRO is correct #1352

merged 2 commits into from
Apr 27, 2021

Conversation

JohnVillalovos
Copy link
Member

@JohnVillalovos JohnVillalovos commented Mar 1, 2021

This should be merged after:
#1344
DONE

Add a check to ensure the MRO (Method Resolution Order) is correct for classes in
gitlab.v4.objects.

An example of an incorrect definition:
    class ProjectPipeline(RESTObject, RefreshMixin, ObjectDeleteMixin):
                          ^^^^^^^^^^ This should be at the end.

Correct way would be:
    class ProjectPipeline(RefreshMixin, ObjectDeleteMixin, RESTObject):
                                      Correctly at the end ^^^^^^^^^^

Also fix classes which have the issue.

@max-wittig
Copy link
Member

Thanks for the MR. Could you elaborate why this matters? I know what you can override methods based on the order, but other than that, I'm unsure. Would be interesting to know @JohnVillalovos

@JohnVillalovos
Copy link
Member Author

Thanks for the MR. Could you elaborate why this matters? I know what you can override methods based on the order, but other than that, I'm unsure. Would be interesting to know @JohnVillalovos

Sure. Let me write up a better explanation and post it. It will have to be after my work-day is over here in Oregon.

@JohnVillalovos
Copy link
Member Author

Thanks for the MR. Could you elaborate why this matters? I know what you can override methods based on the order, but other than that, I'm unsure. Would be interesting to know @JohnVillalovos

Sure. Let me write up a better explanation and post it. It will have to be after my work-day is over here in Oregon.

I have put comments in the test file that explain it better.

This PR is assuming that #1344 will be merged. As that is what triggered this issue.

@codecov-io
Copy link

codecov-io commented Mar 3, 2021

Codecov Report

Merging #1352 (a7a0487) into master (96d2805) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #1352   +/-   ##
=======================================
  Coverage   80.21%   80.21%           
=======================================
  Files          73       73           
  Lines        3801     3801           
=======================================
  Hits         3049     3049           
  Misses        752      752           
Flag Coverage Δ
unit 80.21% <100.00%> (ø)

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

Impacted Files Coverage Δ
gitlab/v4/objects/commits.py 78.26% <100.00%> (ø)
gitlab/v4/objects/deployments.py 100.00% <100.00%> (ø)
gitlab/v4/objects/jobs.py 63.79% <100.00%> (ø)
gitlab/v4/objects/pipelines.py 88.00% <100.00%> (ø)
gitlab/v4/objects/releases.py 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 96d2805...a7a0487. Read the comment docs.

@JohnVillalovos
Copy link
Member Author

@max-wittig Hopefully I have answered your question.

@JohnVillalovos
Copy link
Member Author

Any more questions or comments about this?

Copy link
Member

@nejch nejch left a comment

Choose a reason for hiding this comment

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

Thanks @JohnVillalovos! Just a few quick comments.

@JohnVillalovos
Copy link
Member Author

@nejch Thanks for the feedback. I'll try to get some time to work on this in the next few days.

@JohnVillalovos
Copy link
Member Author

@nejch Updated. I removed the debug code and moved the comments into the docstring.

Add a check to ensure the MRO (Method Resolution Order) is correct for classes in
gitlab.v4.objects when doing type-checking.

An example of an incorrect definition:
    class ProjectPipeline(RESTObject, RefreshMixin, ObjectDeleteMixin):
                          ^^^^^^^^^^ This should be at the end.

Correct way would be:
    class ProjectPipeline(RefreshMixin, ObjectDeleteMixin, RESTObject):
                                      Correctly at the end ^^^^^^^^^^

Also fix classes which have the issue.
@nejch nejch enabled auto-merge April 27, 2021 05:11
@nejch nejch merged commit 909aa9a into python-gitlab:master Apr 27, 2021
@JohnVillalovos JohnVillalovos deleted the jlvillal/fix_mro branch April 27, 2021 16:03
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.

4 participants