Giter Club home page Giter Club logo

Comments (6)

alexvh avatar alexvh commented on July 21, 2024

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.

samrocketman avatar samrocketman commented on July 21, 2024

What would have been the proper way to delete a member from a group?

from python-gitlab3.

alexvh avatar alexvh commented on July 21, 2024

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.

samrocketman avatar samrocketman commented on July 21, 2024

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.

alexvh avatar alexvh commented on July 21, 2024

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.

doctormo avatar doctormo commented on July 21, 2024

I'm closing this bug report as new issues should be reported for delete problems and api protections.

from python-gitlab3.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.