-
-
Notifications
You must be signed in to change notification settings - Fork 933
Why is progress an object and not a function? #436
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
Comments
I see that the interface to the way progress is implemented seems over-engineered to you, which might be why this issue seems to be primarily about letting of some steam. Now that you have gathered some experience with the code, maybe you have an idea on how to change it to make it more suitable for the common case you were seeing. Please feel free to submit a PR that would increase the usability to your liking. |
I have patch for this in development. Need a bit of spare time to test and push. |
Hi @barry-scott you should check the changes I've done to the API for this feature to actually work. I did not change the implementation though, because (at least in my use case) an object was a good way to decouple UI work from git stuff: https://github.com/guyzmo/git-repo/blob/devel/git_repo/services/service.py#L24-34 HTH |
I do not understand what you are getting at. Here is a small example: class GitStuff:
class UiStuff:
Given the above why did you need to change the GitPython code to provide anything more the Barry
|
Oh now I see what you are doing… sorry I a bit slow on this. This is what you should code. class ProgressBar: # pragma: no cover
somewhere else in your code you have lines that look like this:
At no time you you ever need to drag in the stderr parsing logic that is the reason for the RemoteProgress to exist. I’m guessing you are not aware of the obj.func can be passed anywhere a func is required and python will invoke it
|
I was talking about the issue I opened I pushed a couple of weeks ago to get progress stuff to actually work correctly ☺ So what I meant when I said:
is that I focused on getting the thing working, not on changing the suggested API. I'm not saying it cannot be improved, though, just that it did not get in my way. Having the thing instantiated and with a method passed as a callback was short enough and readable with my use case. I agree that it can be improved further (and yes I'm aware of the many ways we can make it a one liner,
First you're not "dragging the stderr parsing logic", merely a reference to it through the means of a base class. The fact that it is a design bug is debatable. I do not believe this is bad design to have just a
Then, importing a class with some logic to be extended with a child class, as it's currently designed, is not a bad one either, for the same reasons as having an interface, but also because it makes it easier to override how parsing is done in case someone wants to do things slightly differently without having to monkey patch the module. For the note, that's the way the
I do know about that, and there are many other ways to work around the use of an object in this situation… Timtoady, but there should be one — and preferably only one — obvious way to do it. Though thinking about it, maybe could we have it both ways. Sometimes we might want a simple function to handle progress, sometimes we want something more heavy that could even need some under-the-hood tweaks. So what could be done would be to have the Then if pb is a function, it instanciates the default So then we could have:
or
the way I did in my code. |
N.B.: the 🦆 emoji is a duck (you'll only see it if you're using an unicode 9 font). |
ahah, in the end, what I just said is what you've done ☺ so we do agree! I missed the fact that there's been a patch along with this issue, I thought it's been closed because I worked on a separate thing related to progress. 👍 |
First thank you for spotting and fixing the progress buffering issue. I think you believe that its a feature that you can derive a class from RemoteProgress to use As you noticed the patch that implemented this change has full backwards compatibility. Your example does not need to derive from RemoteProgress. Call GitPython like this:
The only place where RemoteProgress is needs to be accessed is to get at the state constants: |
Having looked at the progress code I cannot see why I have to provided anything more
the the update() function. Requiring me to create a class seems to be asking me to do the work
of the library. Am I missing something?
The class has the internals of the parsing in it. Would I ever need to override this?
Why isn't details of the parse class hidden from the public API?
The text was updated successfully, but these errors were encountered: