Skip to content

feat(types): add __dir__ to RESTObject to expose attributes - #1072

Merged
max-wittig merged 1 commit into
python-gitlab:masterfrom
spyoungtech:feat/restobject-dir
Apr 14, 2020
Merged

feat(types): add __dir__ to RESTObject to expose attributes#1072
max-wittig merged 1 commit into
python-gitlab:masterfrom
spyoungtech:feat/restobject-dir

Conversation

@spyoungtech

@spyoungtech spyoungtech commented Apr 14, 2020

Copy link
Copy Markdown
Contributor

This change adds the __dir__ magic method to the RESTObject class in order to expose and allow introspection on the attributes that the object might have.

This is very useful to me when exploring the API in an interactive console.

Normally I'll call dir(obj) (or obj? in iPython shell) to try to discover what methods and attributes exist for the object. However, the attributes in the .attributes property are not currently exposed, requiring the extra step of checking .attributes on each object I explore this way.

Hope this makes sense and that this change, if accepted, will help others.

@max-wittig

Copy link
Copy Markdown
Member

Didn't even know about dir() 😮

This change does make sense! Thanks for your contribution!

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.

2 participants