Skip to content

methods deprecation #280

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

Closed
guyzmo opened this issue Jun 24, 2017 · 11 comments · Fixed by #287
Closed

methods deprecation #280

guyzmo opened this issue Jun 24, 2017 · 11 comments · Fixed by #287

Comments

@guyzmo
Copy link
Contributor

guyzmo commented Jun 24, 2017

I've had a report for deprecation warnings in git-repo when using gitlab. I then looked at the release notes, and found out that a bunch of the Gitlab object's API is getting deprecated.

Though, I actually need those in git-repo where I initialise objects in two steps, first I initialise the instances (and importantly request's session) then I load the configuration, and finally the connect method configures the gitlab object.

So either having a method to configure the object after it has been instanciated (with an API similar to the constructor), or keeping the setters really matter to me! Or I'll end up forced to monkey patched internals of python-gitlab and that can end up ugly 😖

cf this issue

Thank you for your lib ♥

@gpocentek
Copy link
Contributor

Hi @guyzmo :)

Could you explain a little more why you need to instantiate the request session first? I'm trying to understand the use case.

My idea with the change is that it doesn't really make sense to have a gitlab object without its authentication and URL parameters. But maybe I missed something...

Thanks!

@guyzmo
Copy link
Contributor Author

guyzmo commented Jun 24, 2017

the process is the following:

  • instanciate the Gitlab object (along with the Session object)
  • read configuration files, use the CLI arguments as well to configure both gitlab and session
  • and finally initiate the connection

Fundamentally, the reason I need to have the session the earliest is because of [betamax(https://github.com/sigmavirus24/betamax) which hijacks the requests session, at construction time.

So if you really want to go the way you're thinking about, then add a requests.Session dependency injection (if that's not already the case).

However you think about it, you're not supposed to make a request to the gitlab server before I explicitely issue a .auth() request (to control when it happens), so what real change would it make to have setters that configures like the constructor or doing it incrementally between instantiation and first request?

@guyzmo
Copy link
Contributor Author

guyzmo commented Jun 24, 2017

(added a link to the code where I use it in the issue)

https://github.com/guyzmo/git-repo/blob/devel/git_repo/services/ext/gitlab.py#L34,L36

@gpocentek
Copy link
Contributor

gpocentek commented Jun 24, 2017

I see! I think you don't need the deprecated methods: https://github.com/gpocentek/git-repo/tree/python-gitlab/280

Let me know if this looks OK.

@guyzmo
Copy link
Contributor Author

guyzmo commented Jun 24, 2017

cf my comments your PR won't pass the tests, as I won't have access to self.gl.session anymore at the time the constructor is called, and before the connect() method is called.

So it's either dependency injection (with the session= parameter to python-gitlab's constructor) or it's the way it was ☺

BTW, see how the same thing is done with sigmavirus24/github3.py.

and the hack I had to do to improve the python-gogs lib for my needs, used there.

@guyzmo
Copy link
Contributor Author

guyzmo commented Jul 1, 2017

So, how do you think shall be the way ahead? Dependency injection of the requests.Session() would be Ok?

@guyzmo
Copy link
Contributor Author

guyzmo commented Jul 1, 2017

basically, have something like that, in the gitlab constructor:

    def __init__(self, url, private_token=None, email=None, password=None,
                 ssl_verify=True, http_username=None, http_password=None,
                 timeout=None, session=None, api_version='3'):
        # …
        #: Create a session object for requests
        self.session = session or requests.Session()
        # …

guyzmo added a commit to guyzmo/python-gitlab that referenced this issue Jul 8, 2017
fixes python-gitlab#280

Signed-off-by: Guyzmo <guyzmo+github+pub@m0g.net>
guyzmo added a commit to guyzmo/python-gitlab that referenced this issue Jul 8, 2017
fixes python-gitlab#280

Signed-off-by: Guyzmo <guyzmo+github+pub@m0g.net>
@guyzmo
Copy link
Contributor Author

guyzmo commented Jul 8, 2017

hop @gpocentek here you go! Just pushed a 2 lines patch that will make me happy, and shouldn't change much of your new design. I'm preparing a PR on my side for using that patch 👍

@guyzmo
Copy link
Contributor Author

guyzmo commented Jul 9, 2017

(N.B.: any ETA for this change to make it to pypi? Just to sync my next release up with yours 😉)

@gpocentek
Copy link
Contributor

@guyzmo I'd like to merge my v4 branch first. It's a big change and I need a bit more time.

I'll probably ping you to validate it BTW, you're the only downstream project maintainer I know ;)

@guyzmo
Copy link
Contributor Author

guyzmo commented Jul 10, 2017

@guyzmo I'd like to merge my v4 branch first. It's a big change and I need a bit more time.

Sure!

I'll probably ping you to validate it BTW

cool 👍 BTW I'm also zmo on freenode if you use IRC.

you're the only downstream project maintainer I know ;)

That's because I'm the nicer one 😁

mdhausman pushed a commit to wayfair-archive/python-gitlab that referenced this issue Aug 1, 2017
fixes python-gitlab#280

Signed-off-by: Guyzmo <guyzmo+github+pub@m0g.net>
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 15, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants