-
Notifications
You must be signed in to change notification settings - Fork 671
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -547,9 +547,8 @@ class AccessRequestMixin(_RestObjectBase): | |
_updated_attrs: Dict[str, Any] | ||
manager: base.RESTManager | ||
|
||
@cli.register_custom_action( | ||
("ProjectAccessRequest", "GroupAccessRequest"), (), ("access_level",) | ||
) | ||
@cli.register_custom_action(("ProjectAccessRequest", "GroupAccessRequest")) | ||
@base.custom_attrs(optional=("access_level",)) | ||
@exc.on_http_error(exc.GitlabUpdateError) | ||
def approve( | ||
self, access_level: int = gitlab.const.DEVELOPER_ACCESS, **kwargs: Any | ||
|
@@ -721,7 +720,8 @@ def time_stats(self, **kwargs: Any) -> Dict[str, Any]: | |
assert not isinstance(result, requests.Response) | ||
return result | ||
|
||
@cli.register_custom_action(("ProjectIssue", "ProjectMergeRequest"), ("duration",)) | ||
@cli.register_custom_action(("ProjectIssue", "ProjectMergeRequest")) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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? There was a problem hiding this comment. Choose a reason for hiding this commentThe 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), 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: 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. |
||
@base.custom_attrs(required=("duration",)) | ||
@exc.on_http_error(exc.GitlabTimeTrackingError) | ||
def time_estimate(self, duration: str, **kwargs: Any) -> Dict[str, Any]: | ||
"""Set an estimated time of work for the object. | ||
|
@@ -759,7 +759,8 @@ def reset_time_estimate(self, **kwargs: Any) -> Dict[str, Any]: | |
assert not isinstance(result, requests.Response) | ||
return result | ||
|
||
@cli.register_custom_action(("ProjectIssue", "ProjectMergeRequest"), ("duration",)) | ||
@cli.register_custom_action(("ProjectIssue", "ProjectMergeRequest")) | ||
@base.custom_attrs(required=("duration",)) | ||
@exc.on_http_error(exc.GitlabTimeTrackingError) | ||
def add_spent_time(self, duration: str, **kwargs: Any) -> Dict[str, Any]: | ||
"""Add time spent working on the object. | ||
|
@@ -833,9 +834,8 @@ def participants(self, **kwargs: Any) -> Dict[str, Any]: | |
|
||
|
||
class BadgeRenderMixin(_RestManagerBase): | ||
@cli.register_custom_action( | ||
("GroupBadgeManager", "ProjectBadgeManager"), ("link_url", "image_url") | ||
) | ||
@cli.register_custom_action(("GroupBadgeManager", "ProjectBadgeManager")) | ||
@base.custom_attrs(required=("link_url", "image_url")) | ||
@exc.on_http_error(exc.GitlabRenderError) | ||
def render(self, link_url: str, image_url: str, **kwargs: Any) -> Dict[str, Any]: | ||
"""Preview link_url and image_url after interpolation. | ||
|
Uh oh!
There was an error while loading. Please reload this page.