Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

feat: add support for mutually exclusive attributes, consolidate attribute validation, fix boards.py _create_attr#2037

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
nejch merged 1 commit intopython-gitlab:mainfromwalterrowe:main
May 31, 2022

Conversation

walterrowe
Copy link
Contributor

@walterrowewalterrowe commentedMay 30, 2022
edited
Loading

feat: add support for mutually exclusive attributes, consolidate attribute validation, fix boards.py _create_attr

  • add exclusive tuple to RequiredOptional data class to add support for mutually exclusive attributes
  • consolidate _check_missing_create_attrs and _check_missing_update_attrs from mixins.py into _validate_attrs in utils.py
  • change _create_attrs in board list manager classes from required=('label_ld',) to exclusive=('label_id','asignee_id','milestone_id')

closes#1897

Copy link
Member

@nejchnejch left a comment

Choose a reason for hiding this comment

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

Thanks for this PR@walterrowe! Just a few tiny suggestions to get CI passing.

@walterrowe
Copy link
ContributorAuthor

updates made ..

@walterrowe
Copy link
ContributorAuthor

updated utils.py _validate_attrs() .. it was unintentionally indented.

@walterrowe
Copy link
ContributorAuthor

walterrowe commentedMay 31, 2022
edited
Loading

looks like utils.py doesn't know type RequiredOptional used in _validate_attrs param types? does utils.py need "from gitlab import base"?

@walterrowe
Copy link
ContributorAuthor

added base to imports (from gitlab import types, base)

@walterrowewalterrowe requested a review fromnejchMay 31, 2022 12:05
@nejch
Copy link
Member

Thanks for your patience@walterrowe, getting closer now ;)

I suggest you always run a quicktox before pushing, this way the linters will already let you know if something's wrong or if the tests don't pass.

added base to imports (from gitlab import types, base)

Thanks for this. Our linters are quite strict so likely it'll need to be alphabetical, sorry 😁

looks like utils.py doesn't know type RequiredOptional used in _validate_attrs param types? does utils.py need "from gitlab import base"?

You're right, sorry I missed this when I looked at the PR. BecauseRequiredOptional is inbase.py, we also now get a circular import (we import base from utils and vice versa), so it would probably make sense to haveRequiredOptional defined inutils.py (but still import it in base e.g.from .utils import RequiredOptional otherwise you'll need to touch a bunch of files). I'll refactor that later if needed.

@walterrowe
Copy link
ContributorAuthor

looked at the error .. looking for suggestions on how to resolve

@walterrowe
Copy link
ContributorAuthor

walterrowe commentedMay 31, 2022
edited
Loading

I followed the contributors doc and set up all the pre-commit items. I have addressed them all except these two.

gitlab/utils.py:168: error: Name "RequiredOptional" is not definedgitlab/mixins.py:345: error: Item "None" of "Optional[Type[RESTObject]]" has no attribute "_id_attr"

utils.py where we declare attributes arg type

def _validate_attrs(    data: Dict[str, Any],    attributes: RequiredOptional,    excludes: Optional[list] = None,) -> None:

mixins.py where we set excludes

        excludes = [self._obj_cls._id_attr]        utils._validate_attrs(            data=new_data, attributes=self._update_attrs, excludes=excludes        )

@walterrowe
Copy link
ContributorAuthor

walterrowe commentedMay 31, 2022
edited
Loading

In utils.py ...

from gitlab.base import RequiredOptional

This resolves the RequiredOptional type error and the circular imports between base and utils.

I tried moving RequiredOptional from base to utils and two dozen other files then said they didn't know RequiredOptional so moving it is quite involved. Looking at the groups.py object file I see it tries to import RequiredOptional from base (from gitlab.base import RequiredOptional, RESTManager, RESTObject) so I took the same approach in utils.py.

@nejch - I still get pre-commit complaining about _id_attr in the update method of UpdateMixins in mixins.py:

gitlab/mixins.py:345: error: Item "None" of "Optional[Type[RESTObject]]" has no attribute "_id_attr"

It comes from this line:

        excludes = [self._obj_cls._id_attr]

I moved this ref from the old _check_missing_update_attrs() method.

        required = tuple(            [k for k in self._update_attrs.required if k != self._obj_cls._id_attr]        )

I need help with that one. Tracing backwards it appears _id_attr would be inherited from RESTObject, its optional, and defaults to "id". Perhaps in the update method of the UpdateMixin we don't need this, or need to first check if its not None?

@walterrowe
Copy link
ContributorAuthor

walterrowe commentedMay 31, 2022
edited
Loading

added check for self._obj_cls is not None .. pre-commit runs clean

nejch reacted with thumbs up emoji

@walterrowe
Copy link
ContributorAuthor

@nejch .. now I'm stuck .. any guidance would be helpful.

@JohnVillalovos
Copy link
Member

Just jumping in here without doing a full review. It might make sense to moveRequiredOptional togitlab/types.py.

Asgitlab/types.py has no dependencies on any othergitlab module. This should get rid of the circular dependency issue.

nejch reacted with thumbs up emoji

@nejch
Copy link
Member

Thanks@JohnVillalovos that makes sense.

@walterrowe you can move it totypes.py and re-import inbase.py (andutils.py) for now so that you don't need to touch all the other files.

@JohnVillalovos
Copy link
Member

Thanks@JohnVillalovos that makes sense.

@walterrowe you can move it totypes.py and re-import inbase.py (andutils.py) for now so that you don't need to touch all the other files.

I created a PR for moving theRequiredOptional as it was not so easy.

#2039

@nejch
Copy link
Member

@walterrowe the PR above was merged, so if you now rebase your PR on top of our main you should be able to do this pretty easily, just import it fromtypes.py. Thanks! :)

@JohnVillalovos
Copy link
Member

@walterrowe the PR above was merged, so if you now rebase your PR on top of our main you should be able to do this pretty easily, just import it fromtypes.py. Thanks! :)

If you need assistance rebasing please let us know. I may be busy today, but starting tomorrow I will have more free time.

@walterrowe
Copy link
ContributorAuthor

walterrowe commentedMay 31, 2022
edited
Loading

@walterrowe the PR above was merged, so if you now rebase your PR on top of our main you should be able to do this pretty easily, just import it fromtypes.py. Thanks! :)

If you need assistance rebasing please let us know. I may be busy today, but starting tomorrow I will have more free time.

Sure wish I had seen this before I pushed my commit to update almost all those same files with the same changes. I have the pre-commit setup so it warned me about all of them.

@JohnVillalovos - I might need some assistance at this point since I have pushed my commits to my fork associated with the PR.

@JohnVillalovos
Copy link
Member

@JohnVillalovos - I might need some assistance at this point since I have pushed my commits to my fork associated with the PR.

Give me a few minutes and I will attempt to rebase.

@JohnVillalovos
Copy link
Member

Give me a few minutes and I will attempt to rebase.

@walterrowe I rebased and squashed the PR. I have pushed it to your branch. You will need to re-clone it most likely.

Please let me know if you have questions.

Might be easiest to just do a new:
git clone git@github.com:walterrowe/python-gitlab.git

@walterrowe
Copy link
ContributorAuthor

who would have thought implementing mutually exclusive attributes would require this much effort! thanks for all the assistance and guidance through this. definitely learning a great deal about python and code review that I didn't know before.

Copy link
Member

@JohnVillalovosJohnVillalovos left a comment

Choose a reason for hiding this comment

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

Getting there. Need to figure out the unit test failures.

Thanks!

walterrowe reacted with laugh emoji
@walterrowe
Copy link
ContributorAuthor

fixed the test_mixins_methods refs to _check_missing_create_attrs and _check_missing_update_attrs

Copy link
Member

@JohnVillalovosJohnVillalovos left a comment

Choose a reason for hiding this comment

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

@walterrowe LGTM (Looks Good To Me) 👍

Thanks for all the work on this. I will let@nejch review it too.

And by the way. Nice photography 😊 I'm a complete amateur but enjoying playing with off-camera flash and other stuff on occasion.

walterrowe reacted with heart emoji
Copy link
Member

@JohnVillalovosJohnVillalovos left a comment

Choose a reason for hiding this comment

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

@walterrowe Oh I forgot one thing. Can you "squash" it down to one commit?

I can do it for you if you like.

Basic idea is:

git rebase --interactive HEAD~4

Change the last three lines frompick tosquash and edit the commit message.

@codecov-commenter
Copy link

Codecov Report

Merging#2037 (5bf017a) intomain (37eb8e0) willdecrease coverage by0.09%.
The diff coverage is75.86%.

@@            Coverage Diff             @@##             main    #2037      +/-   ##==========================================- Coverage   93.78%   93.68%   -0.10%==========================================  Files          78       78                Lines        4984     4985       +1     ==========================================- Hits         4674     4670       -4- Misses        310      315       +5
FlagCoverage Δ
cli_func_v481.80% <68.96%> (+<0.01%)⬆️
py_func_v480.68% <72.41%> (+<0.01%)⬆️
unit85.01% <68.96%> (-0.10%)⬇️

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

Impacted FilesCoverage Δ
gitlab/v4/objects/epics.py75.00% <50.00%> (ø)
gitlab/v4/objects/issues.py89.15% <50.00%> (ø)
gitlab/utils.py93.15% <66.66%> (-6.85%)⬇️
gitlab/mixins.py92.22% <100.00%> (-0.30%)⬇️
gitlab/types.py100.00% <100.00%> (ø)
gitlab/v4/objects/boards.py90.69% <100.00%> (ø)
gitlab/v4/objects/files.py100.00% <100.00%> (ø)

@walterrowe
Copy link
ContributorAuthor

@walterrowe Oh I forgot one thing. Can you "squash" it down to one commit?

I can do it for you if you like.

Basic idea is:

git rebase --interactive HEAD~4

Change the last three lines frompick tosquash and edit the commit message.

@JohnVillalovos - I think I successfully did this .. double check?

@JohnVillalovos
Copy link
Member

@JohnVillalovos - I think I successfully did this .. double check?

Squash was successful 👍

Can you do agit commit --amend and edit the commit message?

feat: add support for mutually exclusive attributes, consolidate attribute validation, fix boards.py _create_attradd exclusive tuple to RequiredOptional data class to support formutually exclusive attributesconsolidate _check_missing_create_attrs and _check_missing_update_attrsfrom mixins.py into _validate_attrs in utils.pymoved RequiredOptional from base.py to types.py  (DELETE THIS) **************************************************change _create_attrs in board list manager classes fromrequired=('label_ld',) toexclusive=('label_id','asignee_id','milestone_id')closes https://github.com/python-gitlab/python-gitlab/issues/1897DELETE ALL BELOW HERE: **********************************************************************************fix: check attributes.require and .exclusive before using in _validate_attrs (utils.py)style: recommended changes in PR reviewfix: corrected _check_missing refs to use _validate_attrs refs

…ibute validation, fix boards.py _create_attradd exclusive tuple to RequiredOptional data class to support formutually exclusive attributesconsolidate _check_missing_create_attrs and _check_missing_update_attrsfrom mixins.py into _validate_attrs in utils.pychange _create_attrs in board list manager classes fromrequired=('label_ld',) toexclusive=('label_id','asignee_id','milestone_id')closes#1897
@walterrowe
Copy link
ContributorAuthor

commit message amended

Copy link
Member

@JohnVillalovosJohnVillalovos left a comment

Choose a reason for hiding this comment

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

LGTM 👍

walterrowe reacted with thumbs up emoji
@walterrowe
Copy link
ContributorAuthor

thanks@JohnVillalovos

is this now pending@nejch review?

@nejch
Copy link
Member

Thanks for all the work on this@walterrowe! I had some thoughts on the logic for optionals as we said and I'd like to add some tests for this, but I'll do that in a follow-up, let's get this merged :)

walterrowe reacted with thumbs up emoji

@nejchnejch merged commit3fa330c intopython-gitlab:mainMay 31, 2022
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@JohnVillalovosJohnVillalovosJohnVillalovos approved these changes

@nejchnejchAwaiting requested review from nejch

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

Create a issue board list by milestone_id still depends on label_id
4 participants
@walterrowe@nejch@JohnVillalovos@codecov-commenter

[8]ページ先頭

©2009-2025 Movatter.jp