-
-
Notifications
You must be signed in to change notification settings - Fork 298
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
Return None instead of -1 on failure (when success result is a bookmark ID) #648
Comments
im undecided on this the reasoning seem good but it may break other program that use buku but after checking related buku project, not a lot of program use buku with python also the next release should be major version, so maybe just go for it? i havent check bukuserver yet |
Might be because of this 😅 |
Let's do the change. We'll document this in the release notes. |
…I found a few other things which can be improved in the source of the main buku file, so I'm opening respective issues to discuss them. I suggest fixing them along with this one. |
…Tried my hand at implementing the suggested changes (for this and other issues on buku API). You can check it out committed here. This includes: returning And yes, I've made sure all the tests pass (aside from the network one blocked for me by a remote server), and both CLI and GUI appear to be working (can't say I did a lot of manual checks though). |
as note #651 this is another refactor issue rejected i thought with new release some refactor will be accepted but only this issue based on #648 (comment) e: and this also accepted #654 |
i miss that 653 i agree on the issue because it dont touch code structure at all do you want to make pr for this? if yes also edit the docstring so type is only on code type hint e: not sure where to put this but if you import something from |
Well the word "optional" in the docstring can be interpreted as aimed at the parameter itself rather than the value type, so I figured there's no issue keeping it as it is. As for
I can make one, but only after #646 is closed – to avoid merge conflicts (it involves checking the same |
i disagree with this.
dont worry about it, just make it with minimum effort as possible |
As of now, several
BukuDb
methods (get_rec_id()
,get_max_id()
,add_rec()
) return a bookmark ID on success, but on failure they return-1
. I suggest changing their failure value toNone
.Reasoning:
None
is always a valid return valueNone
is basically meant for this kind of purposeif buku.add_rec(…)
)is None
insteadof == -1
)-1
is an idiomatically valid index value in Python, which makes it even worse of a fit for "no index" value for this language.The text was updated successfully, but these errors were encountered: