[ovs-dev] flake8: Ignore bare except violations
diff mbox series

Message ID 20180112203958.12000-1-aconole@redhat.com
State Superseded
Headers show
Series
  • [ovs-dev] flake8: Ignore bare except violations
Related show

Commit Message

Aaron Conole Jan. 12, 2018, 8:39 p.m. UTC
And update the URL which lists error codes (and also points to
additional sources for error codes).

Signed-off-by: Aaron Conole <aconole@redhat.com>
---
 Makefile.am | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Comments

Ben Pfaff Jan. 12, 2018, 9:07 p.m. UTC | #1
On Fri, Jan 12, 2018 at 03:39:58PM -0500, Aaron Conole wrote:
> And update the URL which lists error codes (and also points to
> additional sources for error codes).
> 
> Signed-off-by: Aaron Conole <aconole@redhat.com>

Would you mind explaining a bit more?  Do we have violations of this
rule?  I don't get failures here myself, so is it a rule added in some
newer version of flake8 than what I'm running?

Thanks,

Ben.
Aaron Conole Jan. 12, 2018, 9:38 p.m. UTC | #2
Ben Pfaff <blp@ovn.org> writes:

> On Fri, Jan 12, 2018 at 03:39:58PM -0500, Aaron Conole wrote:
>> And update the URL which lists error codes (and also points to
>> additional sources for error codes).
>> 
>> Signed-off-by: Aaron Conole <aconole@redhat.com>
>
> Would you mind explaining a bit more?  Do we have violations of this
> rule?  I don't get failures here myself, so is it a rule added in some
> newer version of flake8 than what I'm running?

I think it's probably from a newer version of flake8 (3.5.0, mccabe:
0.6.1, pycodestyle: 2.3.1, pyflakes: 1.6.0).  Without this patch, I get
the following errors (probably I should have included this in my commit
message - apologies):

  utilities/checkpatch.py:476:5: E722 do not use bare except'
  utilities/checkpatch.py:514:5: E722 do not use bare except'
  utilities/ovs-dev.py:189:5: E722 do not use bare except'
  utilities/ovs-dev.py:192:9: E722 do not use bare except'
  utilities/ovs-dev.py:197:5: E722 do not use bare except'
  utilities/bugtool/ovs-bugtool.in:360:13: E722 do not use bare except'
  utilities/bugtool/ovs-bugtool.in:434:5: E722 do not use bare except'
  utilities/bugtool/ovs-bugtool.in:470:13: E722 do not use bare except'
  utilities/bugtool/ovs-bugtool.in:609:9: E722 do not use bare except'
  utilities/bugtool/ovs-bugtool.in:679:5: E722 do not use bare except'
  utilities/bugtool/ovs-bugtool.in:712:13: E722 do not use bare except'
  utilities/bugtool/ovs-bugtool.in:735:5: E741 ambiguous variable name 'l'
  utilities/bugtool/ovs-bugtool.in:744:9: E722 do not use bare except'
  utilities/bugtool/ovs-bugtool.in:751:9: E722 do not use bare except'
  utilities/bugtool/ovs-bugtool.in:825:5: E722 do not use bare except'
  utilities/bugtool/ovs-bugtool.in:1006:13: E722 do not use bare except'
  utilities/bugtool/ovs-bugtool.in:1041:13: E722 do not use bare except'
  utilities/bugtool/ovs-bugtool.in:1079:5: E722 do not use bare except'
  utilities/bugtool/ovs-bugtool.in:1124:5: E741 ambiguous variable name 'l'
  utilities/bugtool/ovs-bugtool.in:1202:5: E722 do not use bare except'
  utilities/bugtool/ovs-bugtool.in:1247:9: E722 do not use bare except'
  utilities/bugtool/ovs-bugtool.in:1257:13: E722 do not use bare except'
  utilities/bugtool/ovs-bugtool.in:1328:9: E722 do not use bare except'
  tests/test-daemon.py:60:5: E722 do not use bare except'
  tests/test-l7.py:23:1: E722 do not use bare except'
  tests/test-unixctl.py:96:5: E722 do not use bare except'
  xenserver/usr_share_openvswitch_scripts_ovs-xapi-sync:404:5: E722 do not use bare except'
  python/ovs/fcntl_win.py:39:9: E722 do not use bare except'
  python/ovs/poller.py:38:1: E722 do not use bare except'
  python/ovs/socket_util.py:151:13: E722 do not use bare except'
  python/ovs/stream.py:169:17: E722 do not use bare except'
  python/ovs/stream.py:578:17: E722 do not use bare except'
  python/ovs/timeval.py:51:1: E722 do not use bare except'
  python/ovstest/util.py:52:5: E722 do not use bare except'
  vtep/ovs-vtep:767:5: E722 do not use bare except'

I assumed that since it appears in many files, it's probably okay to be
ignoring this error (bare except hides the exception, which is usually
'bad form').  Maybe another approach would be to try and fix them all,
but that means understanding which exceptions should be handled and
allowing the rest to bubble up to the user.  That would take more time
than I have, though.

> Thanks,
>
> Ben.
Ben Pfaff Jan. 12, 2018, 9:52 p.m. UTC | #3
On Fri, Jan 12, 2018 at 04:38:18PM -0500, Aaron Conole wrote:
> Ben Pfaff <blp@ovn.org> writes:
> 
> > On Fri, Jan 12, 2018 at 03:39:58PM -0500, Aaron Conole wrote:
> >> And update the URL which lists error codes (and also points to
> >> additional sources for error codes).
> >> 
> >> Signed-off-by: Aaron Conole <aconole@redhat.com>
> >
> > Would you mind explaining a bit more?  Do we have violations of this
> > rule?  I don't get failures here myself, so is it a rule added in some
> > newer version of flake8 than what I'm running?
> 
> I think it's probably from a newer version of flake8 (3.5.0, mccabe:
> 0.6.1, pycodestyle: 2.3.1, pyflakes: 1.6.0).  Without this patch, I get
> the following errors (probably I should have included this in my commit
> message - apologies):
> 
>   utilities/checkpatch.py:476:5: E722 do not use bare except'
>   utilities/checkpatch.py:514:5: E722 do not use bare except'
>   utilities/ovs-dev.py:189:5: E722 do not use bare except'
>   utilities/ovs-dev.py:192:9: E722 do not use bare except'
>   utilities/ovs-dev.py:197:5: E722 do not use bare except'
>   utilities/bugtool/ovs-bugtool.in:360:13: E722 do not use bare except'
>   utilities/bugtool/ovs-bugtool.in:434:5: E722 do not use bare except'
>   utilities/bugtool/ovs-bugtool.in:470:13: E722 do not use bare except'
>   utilities/bugtool/ovs-bugtool.in:609:9: E722 do not use bare except'
>   utilities/bugtool/ovs-bugtool.in:679:5: E722 do not use bare except'
>   utilities/bugtool/ovs-bugtool.in:712:13: E722 do not use bare except'
>   utilities/bugtool/ovs-bugtool.in:735:5: E741 ambiguous variable name 'l'
>   utilities/bugtool/ovs-bugtool.in:744:9: E722 do not use bare except'
>   utilities/bugtool/ovs-bugtool.in:751:9: E722 do not use bare except'
>   utilities/bugtool/ovs-bugtool.in:825:5: E722 do not use bare except'
>   utilities/bugtool/ovs-bugtool.in:1006:13: E722 do not use bare except'
>   utilities/bugtool/ovs-bugtool.in:1041:13: E722 do not use bare except'
>   utilities/bugtool/ovs-bugtool.in:1079:5: E722 do not use bare except'
>   utilities/bugtool/ovs-bugtool.in:1124:5: E741 ambiguous variable name 'l'
>   utilities/bugtool/ovs-bugtool.in:1202:5: E722 do not use bare except'
>   utilities/bugtool/ovs-bugtool.in:1247:9: E722 do not use bare except'
>   utilities/bugtool/ovs-bugtool.in:1257:13: E722 do not use bare except'
>   utilities/bugtool/ovs-bugtool.in:1328:9: E722 do not use bare except'
>   tests/test-daemon.py:60:5: E722 do not use bare except'
>   tests/test-l7.py:23:1: E722 do not use bare except'
>   tests/test-unixctl.py:96:5: E722 do not use bare except'
>   xenserver/usr_share_openvswitch_scripts_ovs-xapi-sync:404:5: E722 do not use bare except'
>   python/ovs/fcntl_win.py:39:9: E722 do not use bare except'
>   python/ovs/poller.py:38:1: E722 do not use bare except'
>   python/ovs/socket_util.py:151:13: E722 do not use bare except'
>   python/ovs/stream.py:169:17: E722 do not use bare except'
>   python/ovs/stream.py:578:17: E722 do not use bare except'
>   python/ovs/timeval.py:51:1: E722 do not use bare except'
>   python/ovstest/util.py:52:5: E722 do not use bare except'
>   vtep/ovs-vtep:767:5: E722 do not use bare except'
> 
> I assumed that since it appears in many files, it's probably okay to be
> ignoring this error (bare except hides the exception, which is usually
> 'bad form').  Maybe another approach would be to try and fix them all,
> but that means understanding which exceptions should be handled and
> allowing the rest to bubble up to the user.  That would take more time
> than I have, though.

Thanks for the extra info.  Would you mind reposting with that added
information?
Aaron Conole Jan. 12, 2018, 10:29 p.m. UTC | #4
Ben Pfaff <blp@ovn.org> writes:

> On Fri, Jan 12, 2018 at 04:38:18PM -0500, Aaron Conole wrote:
>> Ben Pfaff <blp@ovn.org> writes:
>> 
>> > On Fri, Jan 12, 2018 at 03:39:58PM -0500, Aaron Conole wrote:
>> >> And update the URL which lists error codes (and also points to
>> >> additional sources for error codes).
>> >> 
>> >> Signed-off-by: Aaron Conole <aconole@redhat.com>
>> >
>> > Would you mind explaining a bit more?  Do we have violations of this
>> > rule?  I don't get failures here myself, so is it a rule added in some
>> > newer version of flake8 than what I'm running?
>> 
>> I think it's probably from a newer version of flake8 (3.5.0, mccabe:
>> 0.6.1, pycodestyle: 2.3.1, pyflakes: 1.6.0).  Without this patch, I get
>> the following errors (probably I should have included this in my commit
>> message - apologies):
>> 
>>   utilities/checkpatch.py:476:5: E722 do not use bare except'
>>   utilities/checkpatch.py:514:5: E722 do not use bare except'
>>   utilities/ovs-dev.py:189:5: E722 do not use bare except'
>>   utilities/ovs-dev.py:192:9: E722 do not use bare except'
>>   utilities/ovs-dev.py:197:5: E722 do not use bare except'
>>   utilities/bugtool/ovs-bugtool.in:360:13: E722 do not use bare except'
>>   utilities/bugtool/ovs-bugtool.in:434:5: E722 do not use bare except'
>>   utilities/bugtool/ovs-bugtool.in:470:13: E722 do not use bare except'
>>   utilities/bugtool/ovs-bugtool.in:609:9: E722 do not use bare except'
>>   utilities/bugtool/ovs-bugtool.in:679:5: E722 do not use bare except'
>>   utilities/bugtool/ovs-bugtool.in:712:13: E722 do not use bare except'
>>   utilities/bugtool/ovs-bugtool.in:735:5: E741 ambiguous variable name 'l'
>>   utilities/bugtool/ovs-bugtool.in:744:9: E722 do not use bare except'
>>   utilities/bugtool/ovs-bugtool.in:751:9: E722 do not use bare except'
>>   utilities/bugtool/ovs-bugtool.in:825:5: E722 do not use bare except'
>>   utilities/bugtool/ovs-bugtool.in:1006:13: E722 do not use bare except'
>>   utilities/bugtool/ovs-bugtool.in:1041:13: E722 do not use bare except'
>>   utilities/bugtool/ovs-bugtool.in:1079:5: E722 do not use bare except'
>>   utilities/bugtool/ovs-bugtool.in:1124:5: E741 ambiguous variable name 'l'
>>   utilities/bugtool/ovs-bugtool.in:1202:5: E722 do not use bare except'
>>   utilities/bugtool/ovs-bugtool.in:1247:9: E722 do not use bare except'
>>   utilities/bugtool/ovs-bugtool.in:1257:13: E722 do not use bare except'
>>   utilities/bugtool/ovs-bugtool.in:1328:9: E722 do not use bare except'
>>   tests/test-daemon.py:60:5: E722 do not use bare except'
>>   tests/test-l7.py:23:1: E722 do not use bare except'
>>   tests/test-unixctl.py:96:5: E722 do not use bare except'
>>   xenserver/usr_share_openvswitch_scripts_ovs-xapi-sync:404:5: E722
>> do not use bare except'
>>   python/ovs/fcntl_win.py:39:9: E722 do not use bare except'
>>   python/ovs/poller.py:38:1: E722 do not use bare except'
>>   python/ovs/socket_util.py:151:13: E722 do not use bare except'
>>   python/ovs/stream.py:169:17: E722 do not use bare except'
>>   python/ovs/stream.py:578:17: E722 do not use bare except'
>>   python/ovs/timeval.py:51:1: E722 do not use bare except'
>>   python/ovstest/util.py:52:5: E722 do not use bare except'
>>   vtep/ovs-vtep:767:5: E722 do not use bare except'
>> 
>> I assumed that since it appears in many files, it's probably okay to be
>> ignoring this error (bare except hides the exception, which is usually
>> 'bad form').  Maybe another approach would be to try and fix them all,
>> but that means understanding which exceptions should be handled and
>> allowing the rest to bubble up to the user.  That would take more time
>> than I have, though.
>
> Thanks for the extra info.  Would you mind reposting with that added
> information?

Sure, just did.  Almost forgot to send this, though.  Thanks for the
review, Ben!

Patch
diff mbox series

diff --git a/Makefile.am b/Makefile.am
index d7cfdcd52..2c655df2e 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -359,7 +359,7 @@  endif
 
 if HAVE_FLAKE8
 ALL_LOCAL += flake8-check
-# http://flake8.readthedocs.org/en/latest/warnings.html
+# http://flake8.readthedocs.org/en/latest/user/error-codes.html
 # All warnings explicitly selected or ignored should be listed below.
 #
 # E***, W*** -- warnings from pep8
@@ -371,6 +371,7 @@  ALL_LOCAL += flake8-check
 #   E128 continuation line under-indented for visual indent
 #   E129 visually indented line with same indent as next logical line
 #   E131 continuation line unaligned for hanging indent
+#   E722 do not use bare except, specify exception instead
 #   W503 line break before binary operator
 # F*** -- warnings native to flake8
 #   F811 redefinition of unused <name> from line <N> (only from flake8 v2.0)
@@ -381,7 +382,7 @@  ALL_LOCAL += flake8-check
 #   H233 Python 3.x incompatible use of print operator
 #   H238 old style class declaration, use new style (inherit from `object`)
 FLAKE8_SELECT = H231,H232,H233,H238
-FLAKE8_IGNORE = E121,E123,E125,E126,E127,E128,E129,E131,W503,F811,D,H,I
+FLAKE8_IGNORE = E121,E123,E125,E126,E127,E128,E129,E131,E722,W503,F811,D,H,I
 flake8-check: $(FLAKE8_PYFILES)
 	$(FLAKE8_WERROR)$(AM_V_GEN) \
 	  src='$^' && \