-
Notifications
You must be signed in to change notification settings - Fork 62
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
frontend: unify naming convention for safe methods #2922
Conversation
frontend/coprs_frontend/alembic/versions/4d06318043d3_add_buildchroot_id_and_coprchroot_id.py
Fixed
Show fixed
Hide fixed
1d8b232
to
f2fb5f3
Compare
the fail in CI (copr-common rawhide) seems unrelated to this PR (some problem with package python-six) also these linter issues were there before 💀 bad linter! :D |
Detecting that this is a function rename is a rather complicated task not implemented in csdiff. You need to be a bit more benevolent if you rename calls. :-) |
Can you document the style in |
Even though, ... I don't know. I don't feel anyhow "safe" when I'm calling "_safe" methods. And creating new doesn't make much sense to me. My personal feeling is that we should much better document the method behavior in docstrings.... |
I also somewhat dislike that this "safe" concept leaks outside the |
hmm that's true... but what to do with the safe methods in them? keep them as they are or delete safe suffix?
As I understood it, they are safe because they catch not-found tracebacks and instead of reraising them (and causing traceback mess in the API calls -> would result to 500 I guess) it translates it to 404 with reasonable message so this is somewhat safe.
I am not against getting rid of the suffixes completely and documenting it... I care only about clarifying the inconsistency :D we can shortly discuss it at standup |
I am all for changing the status quo because nobody really knows what "safe" means (probably because on every place it means something different)
But this is IMHO too many cases My favorite is
I think we shouldn't have to care if we raised our custom exception or the default SQLAlchemy exception. If we do, we should IMHO fix our error handler instead. So, I would remove the suffix entirely.
I cannot make up my mind here but I guess having methods about which we know that they don't raise any exceptions, is a good idea. If we change the naming as I suggested above, we could say that "safe" means "safe from exceptions" and simply use However, in many cases What do you think? |
I agree, and to your question - I think we should have Repeating my concern; we should stay on Frontend with this concept, and we should document it. |
|
+1
From what I've seen the
Looking at the PR changes, even the original code with
Absolutely. |
I'd vote for that one, yes. |
no progress |
d5f8bc4
to
867d0d5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
vcs-diff-lint found more than 10 potential problems in the proposed changes. Check the Files changed tab for more details.
dfa790a
to
107e173
Compare
Originally, safe methods were considered as methods raising ObjectNotFound for API (mainly with session.one() method). Now methods which returns None or ignores the error completely are also considered as "safe". For the sake of consistency: - *_or_none -> returns None if object was not found in the database - *_safe -> methods that ignores error completely (they basically log and/or are safe from exceptions) and renaming some of the current safe methods to normal ones that aren't safe by the new rules
107e173
to
504549c
Compare
LGTM but I would suggest running beaker tests against this just to be sure. |
It's going to be done before the release this week, so merging. |
Originally, safe methods were considered as methods raising ObjectNotFound for API (mainly with session.one() method). Now methods which returns None or ignores the error completely are also considered as "safe".
For the sake of consistency:
and renaming some of the current safe methods to normal ones that aren't safe by the new rules