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

refactor: decouple CLI from custom method arguments#1999

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

Closed
nejch wants to merge1 commit intomainfromrefactor/decouple-cli-from-custom-args

Conversation

nejch
Copy link
Member

A more generic approach for#1985

This helps towards#1982. This way, instead of handling parameters in every individual custom method, we can add them in a more declarative way in the decorators and just pull payload in POST/PUT methods from that.

It will also help us completely decouple the CLI from the API client hopefully - making it easier to switch libraries or approaches if we can untangle this.

@codecov-commenter
Copy link

codecov-commenter commentedMay 1, 2022
edited
Loading

Codecov Report

Merging#1999 (5628004) intomain (0e3c461) willincrease coverage by0.05%.
The diff coverage is100.00%.

@@            Coverage Diff             @@##             main    #1999      +/-   ##==========================================+ Coverage   94.62%   94.68%   +0.05%==========================================  Files          78       78                Lines        4983     5038      +55     ==========================================+ Hits         4715     4770      +55  Misses        268      268
FlagCoverage Δ
cli_func_v482.77% <100.00%> (+0.19%)⬆️
py_func_v481.16% <100.00%> (+0.20%)⬆️
unit85.74% <100.00%> (+0.15%)⬆️

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

Impacted FilesCoverage Δ
gitlab/base.py100.00% <100.00%> (ø)
gitlab/cli.py100.00% <100.00%> (ø)
gitlab/exceptions.py100.00% <100.00%> (ø)
gitlab/mixins.py92.24% <100.00%> (+0.08%)⬆️
gitlab/types.py98.11% <100.00%> (+0.03%)⬆️
gitlab/v4/objects/artifacts.py100.00% <100.00%> (ø)
gitlab/v4/objects/commits.py95.06% <100.00%> (+0.18%)⬆️
gitlab/v4/objects/container_registry.py96.42% <100.00%> (+0.13%)⬆️
gitlab/v4/objects/deploy_keys.py96.55% <100.00%> (+0.12%)⬆️
gitlab/v4/objects/files.py100.00% <100.00%> (ø)
... and7 more

@nejchnejch marked this pull request as ready for reviewMay 1, 2022 19:20
@nejch
Copy link
MemberAuthor

Incidentally this makes a few of the decorators a bit more readable.. and should be much more readable when I get to removing the@cli.register_custom_action somehow, to completely get rid of the CLI from the API client itself.

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.

Sorry for the short review. I haven't yet read the whole PR but wanted to leave a couple comments.

@nejchnejchforce-pushed therefactor/decouple-cli-from-custom-args branch fromc8d6dcc to8d3de21CompareMay 29, 2022 16:03
@nejchnejchforce-pushed therefactor/decouple-cli-from-custom-args branch from8d3de21 to4561157CompareJune 6, 2022 08:34
@nejchnejchforce-pushed therefactor/decouple-cli-from-custom-args branch from4561157 to5628004CompareJune 6, 2022 08:41
@nejch
Copy link
MemberAuthor

@JohnVillalovos this should be ready for another round I think. If the value of this PR isn't really clear I can add a draft PR built on top of it, where I start removing custom argument parsing from some of the custom methods to start demoing that, similar to what I did inhttps://github.com/python-gitlab/python-gitlab/pull/1985/files.

returnresult

@cli.register_custom_action(("ProjectIssue","ProjectMergeRequest"), ("duration",))
@cli.register_custom_action(("ProjectIssue","ProjectMergeRequest"))

Choose a reason for hiding this comment

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

What happens if these two decorators are put in reverse order?

Does it work? My guess is no. If not, do we detect a problem? My guess is also no.

If my guesses are correct can we add a way to detect improper usage and make sure the unit tests or something else fails?

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

Good question.. the thing is that, as I said in the comment above#1999 (comment),@cli.register_custom_action is the very next thing we'd want to get rid of if we want to fully decouple the CLI from the client. :( So not sure we should invest time in that and then remove it right after. 🤔


My idea for that was, instead of manually assigning custom methods to classes at each method definition, simply collect all non-standard (create,..) public methods for each Manager and RESTObject in the CLI module, kind of how we already collect the classes for the CLI:
https://github.com/python-gitlab/python-gitlab/blob/main/gitlab/cli.py#L97

Let me check if I can do that in a clean way in a separate commit or follow-up PR, I'll mark this a draft until then.

Maybe it makes sense I open an issue with a mini roadmap to untangling the CLI from the API so we have clear steps on how to get there.

@JohnVillalovos
Copy link
Member

JohnVillalovos commentedJun 6, 2022
edited
Loading

Thanks@nejch

Some quick comments

Can the commit message be improved? It seems to only have a subject line.

Am I correct in thinking (based on looking athttps://github.com/python-gitlab/python-gitlab/pull/1985/files) that the_custom_attrs will be used to determine which values should be sent in thePOST body versus in the URL string? If I am correct, would it make more sense to figure out what can not be in thePOST body and put everything that can be in thePOST body by default? For examplesudo is something that has to be in the query-string (or header) but not in thePOST body. Maybe there are a few others like that??

@nejchnejch marked this pull request as draftJune 7, 2022 06:56
@nejch
Copy link
MemberAuthor

Closing this to reduce the number of drafts open - I'll keep the branch and reopen when ready.

@nejchnejch closed thisAug 6, 2022
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@JohnVillalovosJohnVillalovosJohnVillalovos left review comments

@max-wittigmax-wittigAwaiting requested review from max-wittig

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

3 participants

@nejch@codecov-commenter@JohnVillalovos

[8]ページ先頭

©2009-2025 Movatter.jp