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

chore: add type-hints to gitlab/v4/objects/users.py#1515

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:masterfromJohnVillalovos:jlvillal/mypy_v4_obj_users
Oct 6, 2021
Merged

chore: add type-hints to gitlab/v4/objects/users.py#1515

nejch merged 1 commit intopython-gitlab:masterfromJohnVillalovos:jlvillal/mypy_v4_obj_users
Oct 6, 2021

Conversation

JohnVillalovos
Copy link
Member

Adding type-hints to gitlab/v4/objects/users.py

@codecov-commenter
Copy link

codecov-commenter commentedJun 13, 2021
edited
Loading

Codecov Report

Merging#1515 (51dd98b) intomaster (85713bb) willincrease coverage by0.00%.
The diff coverage is100.00%.

@@           Coverage Diff           @@##           master    #1515   +/-   ##=======================================  Coverage   91.15%   91.16%           =======================================  Files          74       74             Lines        4172     4176    +4     =======================================+ Hits         3803     3807    +4  Misses        369      369
FlagCoverage Δ
cli_func_v480.79% <100.00%> (+0.01%)⬆️
py_func_v480.10% <100.00%> (+0.01%)⬆️
unit82.35% <100.00%> (+0.01%)⬆️

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

Impacted FilesCoverage Δ
gitlab/v4/objects/users.py98.29% <100.00%> (+0.03%)⬆️

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.

I just have a question about how this will go if we continue this way for all modules. I haven't looked at alternatives at all so just asking atm.

Comment on lines +326 to +327
def get(self, id: Union[str, int], lazy: bool = False, **kwargs: Any) -> User:
return cast(User, super().get(id=id, lazy=lazy, **kwargs))
Copy link
Member

Choose a reason for hiding this comment

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

question: I already merged this for projects but now it has me thinking, is there any way to avoid adding all this boilerplate for typing? There will be alot of these I imagine if as we go module by module, and I guess will need to be copy/pasted for a lot of mixin usage.

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

I have tried and tried again and tried again... But so far I can't figure out a way to do it. If you can figure it out it will be awesome!

There are ways to do it if you return aself object. But since we are returningself._obj_cls() it doesn't seem like things are smart enough to understand that yet. Well at least notmypy

This will help editors and the type-checker in knowing thatgl.users.get() returns aUser object. Otherwise it will think it returns aRESTObject which isn't as useful.

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

Oh, you will probably like my idea for handlinggl.users.list() even less 😜

At the moment my best solution for that seems to be adding aUserList class or something like that. I haven't figured it out yet but thinking about it.

@JohnVillalovosJohnVillalovos self-assigned thisJun 13, 2021
Adding type-hints to gitlab/v4/objects/users.py
@JohnVillalovos
Copy link
MemberAuthor

@nejch Is there anything else that needs to be done for this to get merged?

@nejch
Copy link
Member

@nejch Is there anything else that needs to be done for this to get merged?

Sorry@JohnVillalovos I never ended up diving into whether we could avoid the extra code in the discussion above. Maybe I could try to find any typed projects that might rely heavily on managers and mixins?

@JohnVillalovos
Copy link
MemberAuthor

Sorry@JohnVillalovos I never ended up diving into whether we could avoid the extra code in the discussion above. Maybe I could try to find any typed projects that might rely heavily on managers and mixins?

Works for me. Would be cool if cleaner solution. So far I haven't been able to figure one out 😟

@JohnVillalovos
Copy link
MemberAuthor

@nejch Curious if you had time to think about this. My thought is that this works but isn't pretty. But sometimes that is what we have to do. And it is only two lines of code.

As the expression says, "Perfect is the enemy of good" 😊

@nejchnejch merged commit7753fa2 intopython-gitlab:masterOct 6, 2021
@nejch
Copy link
Member

@nejch Curious if you had time to think about this. My thought is that this works but isn't pretty. But sometimes that is what we have to do. And it is only two lines of code.

As the expression says, "Perfect is the enemy of good" blush

@JohnVillalovos I also haven't done much in this direction so let's merge :D Yeah, it won't be much to change if we do figure it out.

@JohnVillalovosJohnVillalovos deleted the jlvillal/mypy_v4_obj_users branchJanuary 4, 2022 06:55
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@nejchnejchnejch left review comments

Assignees

@JohnVillalovosJohnVillalovos

Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

3 participants
@JohnVillalovos@codecov-commenter@nejch

[8]ページ先頭

©2009-2025 Movatter.jp