[PATCH 02/10] syntax-check: Exclude 'scripts/*.py' from 'sc_prohibit_magic_number_exit'

Peter Krempa posted 10 patches 12 months ago
[PATCH 02/10] syntax-check: Exclude 'scripts/*.py' from 'sc_prohibit_magic_number_exit'
Posted by Peter Krempa 12 months ago
The contstants the syntax check rule suggests don't make sense in
python scripts.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
---
 build-aux/syntax-check.mk | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/build-aux/syntax-check.mk b/build-aux/syntax-check.mk
index eaeb6d4f23..bd9c21fc80 100644
--- a/build-aux/syntax-check.mk
+++ b/build-aux/syntax-check.mk
@@ -1516,6 +1516,9 @@ exclude_file_name_regexp--sc_black = \
 exclude_file_name_regexp--sc_spacing-check = \
   ^scripts/rpcgen/tests/test_demo\.[ch]$$

+exclude_file_name_regexp--sc_prohibit_magic_number_exit = \
+  ^scripts/.*\.py$$
+
 ## -------------- ##
 ## Implementation ##
 ## -------------- ##
-- 
2.43.0
_______________________________________________
Devel mailing list -- devel@lists.libvirt.org
To unsubscribe send an email to devel-leave@lists.libvirt.org
Re: [PATCH 02/10] syntax-check: Exclude 'scripts/*.py' from 'sc_prohibit_magic_number_exit'
Posted by Andrea Bolognani 11 months, 3 weeks ago
On Tue, Jan 16, 2024 at 05:12:36PM +0100, Peter Krempa wrote:
> +++ b/build-aux/syntax-check.mk
> @@ -1516,6 +1516,9 @@ exclude_file_name_regexp--sc_black = \
>  exclude_file_name_regexp--sc_spacing-check = \
>    ^scripts/rpcgen/tests/test_demo\.[ch]$$
>
> +exclude_file_name_regexp--sc_prohibit_magic_number_exit = \
> +  ^scripts/.*\.py$$

If you use sys.exit() instead of exit(), like the other Python
scripts are doing, you don't need this anymore.

-- 
Andrea Bolognani / Red Hat / Virtualization
_______________________________________________
Devel mailing list -- devel@lists.libvirt.org
To unsubscribe send an email to devel-leave@lists.libvirt.org
Re: [PATCH 02/10] syntax-check: Exclude 'scripts/*.py' from 'sc_prohibit_magic_number_exit'
Posted by Peter Krempa 11 months, 3 weeks ago
On Thu, Jan 25, 2024 at 08:34:40 -0800, Andrea Bolognani wrote:
> On Tue, Jan 16, 2024 at 05:12:36PM +0100, Peter Krempa wrote:
> > +++ b/build-aux/syntax-check.mk
> > @@ -1516,6 +1516,9 @@ exclude_file_name_regexp--sc_black = \
> >  exclude_file_name_regexp--sc_spacing-check = \
> >    ^scripts/rpcgen/tests/test_demo\.[ch]$$
> >
> > +exclude_file_name_regexp--sc_prohibit_magic_number_exit = \
> > +  ^scripts/.*\.py$$
> 
> If you use sys.exit() instead of exit(), like the other Python
> scripts are doing, you don't need this anymore.

Oh, I had to look up the difference and 'exit()' is allegedly meant for
interactive use, while scripts should use sys.exit(). TIL.
_______________________________________________
Devel mailing list -- devel@lists.libvirt.org
To unsubscribe send an email to devel-leave@lists.libvirt.org