Skip to content

Conversation

@nejch
Copy link
Member

@nejch nejch commented Aug 14, 2022

Closes #1495
Replaces #1577
Depended on #1699

@codecov-commenter
Copy link

Codecov Report

Merging #2236 (39cca82) into main (3f91d24) will increase coverage by 0.00%.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##             main    #2236   +/-   ##
=======================================
  Coverage   95.43%   95.44%           
=======================================
  Files          81       81           
  Lines        5369     5375    +6     
=======================================
+ Hits         5124     5130    +6     
  Misses        245      245           
Flag Coverage Δ
api_func_v4 81.39% <100.00%> (+0.03%) ⬆️
cli_func_v4 83.05% <57.14%> (-0.04%) ⬇️
unit 87.23% <57.14%> (-0.05%) ⬇️

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

Impacted Files Coverage Δ
gitlab/v4/objects/repositories.py 83.56% <100.00%> (+1.47%) ⬆️

Copy link
Member

@JohnVillalovos JohnVillalovos left a comment

Choose a reason for hiding this comment

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

@nejch Looks good to me. Left a comment, but for sure could be something we don't do or do later.

This is approved, feel free to merge with my blessing!

@exc.on_http_error(exc.GitlabGetError)
def repository_merge_base(
self, refs: List[str], **kwargs: Any
) -> Union[Dict[str, Any], requests.Response]:
Copy link
Member

Choose a reason for hiding this comment

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

This made me think if we should start forcing these to just be a Dict?

Copy link
Member Author

@nejch nejch Aug 16, 2022

Choose a reason for hiding this comment

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

Thanks @JohnVillalovos! Makes sense to me! I was looking at doing this via overloading http_get/http_request to narrow the types there already, depending on the streamed/raw arguments but it got a bit out of hand. Then I think we wouldn't need to do it in "downstream" methods, IIUC. I will look into it again :)

But it requires quite a few overloads for all the possible signatures. This is what I was looking at https://medium.com/analytics-vidhya/making-sense-of-typing-overload-437e6deecade.

custom_types={"refs": types.ArrayAttribute},
transform_data=True,
)
return self.manager.gitlab.http_get(path, query_data=query_data, **kwargs)
Copy link
Member

Choose a reason for hiding this comment

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

To force it to be a Dict I think could do this:

Suggested change
return self.manager.gitlab.http_get(path, query_data=query_data, **kwargs)
result = self.manager.gitlab.http_get(path, query_data=query_data, raw=False, streamed=False, **kwargs)
if TYPE_CHECKING:
assert isinstance(result, dict)
return result

@JohnVillalovos JohnVillalovos merged commit dd4fbd5 into main Aug 19, 2022
@JohnVillalovos JohnVillalovos deleted the feat/merge-base branch August 19, 2022 23:24
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.

No merge_base API support while GitLab v4 API has.

4 participants