-
Notifications
You must be signed in to change notification settings - Fork 8
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
fromString returning false
in case of error is not pythonic
#26
Comments
@allan-simon Hello! Could you please elaborate a bit more your case? Is it possible to provide a reproducible example? Please, take a look in the issue #19 as reference, that's good way to reproduce the case. Regards. |
sorry what I mean is that
should be
as it's very uncommon in python to have a function that returns (fromstring and other methods that return false as a way to convey an error occured ) |
@allan-simon Thank you for your prompt response! Your explanation has clarified my perspective. I agree that using Exceptions in these cases is more Pythonic and aligns better with best practices. However, changing the current design would introduce breaking changes, which is something we need to avoid. This fork was specifically created to fix a bug that was impacting the Conan client (details here: https://github.com/conan-io/python-patch-ng?tab=readme-ov-file#why-did-we-fork-this-project). Altering this behavior could affect not only Conan but also other users who rely on the current design and expect False to be returned in their code. Given this, I believe it's best to maintain the existing approach. |
@uilianries maybe a solution would be to add an optional error check to |
Which break the principle of "least surprise"
i.e most python libraries raise exception instead (ask for forgiveness not permission) so one could choose to not handle them , or handle them at a higher level
also it breaks static analysis tool that will say that
is not valid because
false
has no apply methodsThe text was updated successfully, but these errors were encountered: