-
Notifications
You must be signed in to change notification settings - Fork 671
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
nejch
merged 1 commit into
python-gitlab:master
from
JohnVillalovos:jlvillal/mypy_v4_obj_users
Oct 6, 2021
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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 a lot 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.
There was a problem hiding this comment.
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 a
self
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 that
gl.users.get()
returns aUser
object. Otherwise it will think it returns aRESTObject
which isn't as useful.There was a problem hiding this comment.
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 handling
gl.users.list()
even less 😜At the moment my best solution for that seems to be adding a
UserList
class or something like that. I haven't figured it out yet but thinking about it.