Replace to broad exceptions into the Dev#38489
Conversation
92b404a to
022eeb6
Compare
|
I feel some of the exceptions shouldn’t be ValueError. This type is for when a value is not right, but some of those aren’t specifically pointing to a value. RuntimeError would be better for at least some cases. |
Could you point in which cases better use |
|
Answering for @uranusjr I think possibly yes - those that do not print value that is wrong, could be runtime errors. This is completely incosequential though in dev tools, because those exception are not a 'library" type of exceptions that could be handled by a caller in a different way. But if I were to made a rule for "if we do not print the value that is wrong and if the value is not directly provided by the user, it should be a runtime error." But I am ok with any approach here, as it is, as I said inconsquential. |
|
BTW. If we want to be REALLY correct here - every time we send a ValueError (i.e. user provided a value that is wrong), we should do: Generally speaking raising exception when user input and user console tools is involved, is quite wrong.. So if we want to correct it, then I'd rather say:
|
|
Added my suggestions. @uranusjr -> maybe you can review those and say what you think? |
|
Should we just complete thaat one :) ? |
f1a9faf to
4df4175
Compare
Taragolis
left a comment
There was a problem hiding this comment.
I hope I do not miss any suggested changes
|
The error in the tests not related to this changes |
Co-authored-by: Jarek Potiuk <jarek@potiuk.com> Co-authored-by: Tzu-ping Chung <uranusjr@gmail.com>
Co-authored-by: Tzu-ping Chung <uranusjr@gmail.com>
26e77a5 to
74939c9
Compare
* Replace to broad exceptions into the Dev * Add changes according to the review Co-authored-by: Jarek Potiuk <jarek@potiuk.com> Co-authored-by: Tzu-ping Chung <uranusjr@gmail.com> * RuntimeError -> SystemExit if detect it run in __main__ Co-authored-by: Tzu-ping Chung <uranusjr@gmail.com> --------- Co-authored-by: Jarek Potiuk <jarek@potiuk.com> Co-authored-by: Tzu-ping Chung <uranusjr@gmail.com> (cherry picked from commit cc901cd)
Similar to: #38344
This one less affect the tests but still better to use custom or other more appropriate builtin exceptions rather than just Exception.
This one was found by TRY002 rule it has a bit confusing message
We might want to activate this rule later on, just need to resolve it into the providers first (or add noqa):
^ Add meaningful description above
Read the Pull Request Guidelines for more information.
In case of fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
In case of a new dependency, check compliance with the ASF 3rd Party License Policy.
In case of backwards incompatible changes please leave a note in a newsfragment file, named
{pr_number}.significant.rstor{issue_number}.significant.rst, in newsfragments.