Comments (6)
That specific example's a definite bug due to my lazily coded delete_member() function. I'll issue a fix for it soon. Update functions may have a similar issue...
"Perhaps doing a test for object type before executing anything and provide a meaningful exception."
For similar cases, I'll probably add something like this.
Part of the problem stems from confusion of having multiple types of users/members. It's not something I like, but I don't know how to avoid given the current GitLab API. Adding some type checking here and there like you suggested may work well enough. I'm open to any other ideas though.
Thanks for the feedback!
from python-gitlab3.
What would have been the proper way to delete a member from a group?
from python-gitlab3.
Due in part to the crippled group membership API (no get or update) and the inflexibility of group.delete_member(), there's only one awkward way to do it and that's to use a Member object returned from a call to group.members(). This is obviously a problem, heh. I'll see about allowing delete_member/delete_user/etc. to accept any type of user or member object.
*edit: Just realized you can also use group.find_member() and pass the result to group.delete_member() (or call delete() on the result). This still isn't ideal though since find_member() will potentially have to query the entire list of members to return a single one.
from python-gitlab3.
Perhaps modify this function so that when a sub_api
is added you set a value, parent_api
, in the Class. Then when certain functions are called (e.g. delete()
) it checks that the object being passed matches the type (e.g. type User
) and that parent_api
is set to the current Class type self
. This way only children objects can be passed as an argument and if a global User
object is passed parent_api
will either ==
to None
or to GitLab
depending on how you want to set it up.
from python-gitlab3.
Committed a workaround for now to ensure the type is correct, but ideally I'd like to make it more flexible and, e.g. allow a gitlab3.User object be passed to gitlab3.Group.delete_member().
from python-gitlab3.
I'm closing this bug report as new issues should be reported for delete problems and api protections.
from python-gitlab3.
Related Issues (20)
- Does not work with GitLab 6.4.3 HOT 2
- Please release v0.5.3 HOT 1
- NotImplementedError: a tzinfo subclass must implement dst() HOT 1
- Can only connect to one server at a time HOT 1
- Support Python 3 HOT 1
- Boolean values are incorrectly marshaled on save HOT 1
- Transferring a project is forbidden with GitLab 7.6.2 HOT 5
- API interfaces are out of date HOT 10
- gitlab3.exceptions.MissingRequiredAttribute HOT 2
- project information update HOT 1
- get single project by id or namespace/name HOT 1
- Creation of projects in groups HOT 4
- Gitlab API v4 approaching HOT 4
- Use incremental tags HOT 2
- type error while dash in project name HOT 1
- get_user error
- Possible issue with DELETE group and project HOT 2
- How to get all projects from all users HOT 1
- Error when adding ssh key to user HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from python-gitlab3.