diff mbox series

[3/3] python: remove semicolon from end of lines

Message ID 20180819184901.6395-3-nicolas.iooss@m4x.org (mailing list archive)
State Not Applicable
Headers show
Series [1/3] libselinux: add a const to suppress a build warning with Python 3.7 | expand

Commit Message

Nicolas Iooss Aug. 19, 2018, 6:49 p.m. UTC
Python does not need to end a statement with a semicolon. Doing this
gets reported by linters such as flake8 ("E703 statement ends with a
semicolon").

Remove such semicolons in the code and enable this warning in
scripts/run-flake8.

Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>
---
 python/sepolgen/src/sepolgen/audit.py | 2 +-
 python/sepolgen/src/sepolgen/yacc.py  | 8 ++++----
 python/sepolicy/sepolicy/manpage.py   | 2 +-
 scripts/run-flake8                    | 1 -
 4 files changed, 6 insertions(+), 7 deletions(-)

Comments

William Roberts Aug. 20, 2018, 9:51 p.m. UTC | #1
Ack on these as well

On Sun, Aug 19, 2018 at 11:49 AM, Nicolas Iooss <nicolas.iooss@m4x.org>
wrote:

> Python does not need to end a statement with a semicolon. Doing this
> gets reported by linters such as flake8 ("E703 statement ends with a
> semicolon").
>
> Remove such semicolons in the code and enable this warning in
> scripts/run-flake8.
>
> Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>
> ---
>  python/sepolgen/src/sepolgen/audit.py | 2 +-
>  python/sepolgen/src/sepolgen/yacc.py  | 8 ++++----
>  python/sepolicy/sepolicy/manpage.py   | 2 +-
>  scripts/run-flake8                    | 1 -
>  4 files changed, 6 insertions(+), 7 deletions(-)
>
> diff --git a/python/sepolgen/src/sepolgen/audit.py b/python/sepolgen/src/
> sepolgen/audit.py
> index daed58ce9643..4adb851f3e93 100644
> --- a/python/sepolgen/src/sepolgen/audit.py
> +++ b/python/sepolgen/src/sepolgen/audit.py
> @@ -258,7 +258,7 @@ class AVCMessage(AuditMessage):
>          if (scontext, tcontext, self.tclass, access_tuple) in
> avcdict.keys():
>              self.type, self.data = avcdict[(scontext, tcontext,
> self.tclass, access_tuple)]
>          else:
> -            self.type, self.data = audit2why.analyze(scontext, tcontext,
> self.tclass, self.accesses);
> +            self.type, self.data = audit2why.analyze(scontext, tcontext,
> self.tclass, self.accesses)
>              if self.type == audit2why.NOPOLICY:
>                  self.type = audit2why.TERULE
>              if self.type == audit2why.BADTCON:
> diff --git a/python/sepolgen/src/sepolgen/yacc.py b/python/sepolgen/src/
> sepolgen/yacc.py
> index f00635469af1..afef174849f2 100644
> --- a/python/sepolgen/src/sepolgen/yacc.py
> +++ b/python/sepolgen/src/sepolgen/yacc.py
> @@ -1864,10 +1864,10 @@ del _lr_action_items
>  """)
>
>          else:
> -            f.write("\n_lr_action = { ");
> +            f.write("\n_lr_action = { ")
>              for k,v in _lr_action.items():
>                  f.write("(%r,%r):%r," % (k[0],k[1],v))
> -            f.write("}\n");
> +            f.write("}\n")
>
>          if smaller:
>              # Factor out names to try and make smaller
> @@ -1901,10 +1901,10 @@ for _k, _v in _lr_goto_items.items():
>  del _lr_goto_items
>  """)
>          else:
> -            f.write("\n_lr_goto = { ");
> +            f.write("\n_lr_goto = { ")
>              for k,v in _lr_goto.items():
>                  f.write("(%r,%r):%r," % (k[0],k[1],v))
> -            f.write("}\n");
> +            f.write("}\n")
>
>          # Write production table
>          f.write("_lr_productions = [\n")
> diff --git a/python/sepolicy/sepolicy/manpage.py
> b/python/sepolicy/sepolicy/manpage.py
> index cb211ba083ca..cfcb7c3932d7 100755
> --- a/python/sepolicy/sepolicy/manpage.py
> +++ b/python/sepolicy/sepolicy/manpage.py
> @@ -539,7 +539,7 @@ class ManPage:
>                      self.fd = fd
>                      self.man_page_path = man_page_path
>              except KeyError:
> -                continue;
> +                continue
>              self.attributes[domain_type] = next(sepolicy.info(sepolicy.TYPE,
> ("%s") % domain_type))["attributes"]
>
>          self._header()
> diff --git a/scripts/run-flake8 b/scripts/run-flake8
> index 8a1f490b8a62..207edd20dd89 100755
> --- a/scripts/run-flake8
> +++ b/scripts/run-flake8
> @@ -14,7 +14,6 @@ IGNORE_LIST=''
>  IGNORE_LIST="$IGNORE_LIST,W191" # indentation contains tabs
>
>  IGNORE_LIST="$IGNORE_LIST,E101" # indentation contains mixed spaces and
> tabs
> -IGNORE_LIST="$IGNORE_LIST,E703" # statement ends with a semicolon
>  IGNORE_LIST="$IGNORE_LIST,E711" # comparison to None should be 'if cond
> is not None:'
>  IGNORE_LIST="$IGNORE_LIST,E712" # comparison to False should be 'if cond
> is False:' or 'if not cond:'
>  IGNORE_LIST="$IGNORE_LIST,E722" # do not use bare 'except'
> --
> 2.18.0
>
> _______________________________________________
> Selinux mailing list
> Selinux@tycho.nsa.gov
> To unsubscribe, send email to Selinux-leave@tycho.nsa.gov.
> To get help, send an email containing "help" to
> Selinux-request@tycho.nsa.gov.
>
<div dir="ltr">Ack on these as well</div><div class="gmail_extra"><br><div class="gmail_quote">On Sun, Aug 19, 2018 at 11:49 AM, Nicolas Iooss <span dir="ltr">&lt;<a href="mailto:nicolas.iooss@m4x.org" target="_blank">nicolas.iooss@m4x.org</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Python does not need to end a statement with a semicolon. Doing this<br>
gets reported by linters such as flake8 (&quot;E703 statement ends with a<br>
semicolon&quot;).<br>
<br>
Remove such semicolons in the code and enable this warning in<br>
scripts/run-flake8.<br>
<br>
Signed-off-by: Nicolas Iooss &lt;<a href="mailto:nicolas.iooss@m4x.org">nicolas.iooss@m4x.org</a>&gt;<br>
---<br>
 python/sepolgen/src/sepolgen/<wbr>audit.py | 2 +-<br>
 python/sepolgen/src/sepolgen/<wbr>yacc.py  | 8 ++++----<br>
 python/sepolicy/sepolicy/<wbr>manpage.py   | 2 +-<br>
 scripts/run-flake8                    | 1 -<br>
 4 files changed, 6 insertions(+), 7 deletions(-)<br>
<br>
diff --git a/python/sepolgen/src/<wbr>sepolgen/audit.py b/python/sepolgen/src/<wbr>sepolgen/audit.py<br>
index daed58ce9643..4adb851f3e93 100644<br>
--- a/python/sepolgen/src/<wbr>sepolgen/audit.py<br>
+++ b/python/sepolgen/src/<wbr>sepolgen/audit.py<br>
@@ -258,7 +258,7 @@ class AVCMessage(AuditMessage):<br>
         if (scontext, tcontext, self.tclass, access_tuple) in avcdict.keys():<br>
             self.type, self.data = avcdict[(scontext, tcontext, self.tclass, access_tuple)]<br>
         else:<br>
-            self.type, self.data = audit2why.analyze(scontext, tcontext, self.tclass, self.accesses);<br>
+            self.type, self.data = audit2why.analyze(scontext, tcontext, self.tclass, self.accesses)<br>
             if self.type == audit2why.NOPOLICY:<br>
                 self.type = audit2why.TERULE<br>
             if self.type == audit2why.BADTCON:<br>
diff --git a/python/sepolgen/src/<wbr>sepolgen/yacc.py b/python/sepolgen/src/<wbr>sepolgen/yacc.py<br>
index f00635469af1..afef174849f2 100644<br>
--- a/python/sepolgen/src/<wbr>sepolgen/yacc.py<br>
+++ b/python/sepolgen/src/<wbr>sepolgen/yacc.py<br>
@@ -1864,10 +1864,10 @@ del _lr_action_items<br>
 &quot;&quot;&quot;)<br>
<br>
         else:<br>
-            f.write(&quot;\n_lr_action = { &quot;);<br>
+            f.write(&quot;\n_lr_action = { &quot;)<br>
             for k,v in _lr_action.items():<br>
                 f.write(&quot;(%r,%r):%r,&quot; % (k[0],k[1],v))<br>
-            f.write(&quot;}\n&quot;);<br>
+            f.write(&quot;}\n&quot;)<br>
<br>
         if smaller:<br>
             # Factor out names to try and make smaller<br>
@@ -1901,10 +1901,10 @@ for _k, _v in _lr_goto_items.items():<br>
 del _lr_goto_items<br>
 &quot;&quot;&quot;)<br>
         else:<br>
-            f.write(&quot;\n_lr_goto = { &quot;);<br>
+            f.write(&quot;\n_lr_goto = { &quot;)<br>
             for k,v in _lr_goto.items():<br>
                 f.write(&quot;(%r,%r):%r,&quot; % (k[0],k[1],v))                    <br>
-            f.write(&quot;}\n&quot;);<br>
+            f.write(&quot;}\n&quot;)<br>
<br>
         # Write production table<br>
         f.write(&quot;_lr_productions = [\n&quot;)<br>
diff --git a/python/sepolicy/sepolicy/<wbr>manpage.py b/python/sepolicy/sepolicy/<wbr>manpage.py<br>
index cb211ba083ca..cfcb7c3932d7 100755<br>
--- a/python/sepolicy/sepolicy/<wbr>manpage.py<br>
+++ b/python/sepolicy/sepolicy/<wbr>manpage.py<br>
@@ -539,7 +539,7 @@ class ManPage:<br>
                     self.fd = fd<br>
                     self.man_page_path = man_page_path<br>
             except KeyError:<br>
-                continue;<br>
+                continue<br>
             self.attributes[domain_type] = next(<a href="http://sepolicy.info" rel="noreferrer" target="_blank">sepolicy.info</a>(sepolicy.<wbr>TYPE, (&quot;%s&quot;) % domain_type))[&quot;attributes&quot;]<br>
<br>
         self._header()<br>
diff --git a/scripts/run-flake8 b/scripts/run-flake8<br>
index 8a1f490b8a62..207edd20dd89 100755<br>
--- a/scripts/run-flake8<br>
+++ b/scripts/run-flake8<br>
@@ -14,7 +14,6 @@ IGNORE_LIST=&#39;&#39;<br>
 IGNORE_LIST=&quot;$IGNORE_LIST,<wbr>W191&quot; # indentation contains tabs<br>
<br>
 IGNORE_LIST=&quot;$IGNORE_LIST,<wbr>E101&quot; # indentation contains mixed spaces and tabs<br>
-IGNORE_LIST=&quot;$IGNORE_LIST,<wbr>E703&quot; # statement ends with a semicolon<br>
 IGNORE_LIST=&quot;$IGNORE_LIST,<wbr>E711&quot; # comparison to None should be &#39;if cond is not None:&#39;<br>
 IGNORE_LIST=&quot;$IGNORE_LIST,<wbr>E712&quot; # comparison to False should be &#39;if cond is False:&#39; or &#39;if not cond:&#39;<br>
 IGNORE_LIST=&quot;$IGNORE_LIST,<wbr>E722&quot; # do not use bare &#39;except&#39;<br>
<span class="HOEnZb"><font color="#888888">-- <br>
2.18.0<br>
<br>
______________________________<wbr>_________________<br>
Selinux mailing list<br>
<a href="mailto:Selinux@tycho.nsa.gov">Selinux@tycho.nsa.gov</a><br>
To unsubscribe, send email to <a href="mailto:Selinux-leave@tycho.nsa.gov">Selinux-leave@tycho.nsa.gov</a>.<br>
To get help, send an email containing &quot;help&quot; to <a href="mailto:Selinux-request@tycho.nsa.gov">Selinux-request@tycho.nsa.gov</a>.<br>
</font></span></blockquote></div><br></div>
Nicolas Iooss Aug. 22, 2018, 5:59 a.m. UTC | #2
On Mon, Aug 20, 2018 at 11:51 PM William Roberts
<bill.c.roberts@gmail.com> wrote:
>
> Ack on these as well

Thanks, I applied these patches and the previous ones I sent.

Nicolas

>
> On Sun, Aug 19, 2018 at 11:49 AM, Nicolas Iooss <nicolas.iooss@m4x.org> wrote:
>>
>> Python does not need to end a statement with a semicolon. Doing this
>> gets reported by linters such as flake8 ("E703 statement ends with a
>> semicolon").
>>
>> Remove such semicolons in the code and enable this warning in
>> scripts/run-flake8.
>>
>> Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>
>> ---
>>  python/sepolgen/src/sepolgen/audit.py | 2 +-
>>  python/sepolgen/src/sepolgen/yacc.py  | 8 ++++----
>>  python/sepolicy/sepolicy/manpage.py   | 2 +-
>>  scripts/run-flake8                    | 1 -
>>  4 files changed, 6 insertions(+), 7 deletions(-)
>>
>> diff --git a/python/sepolgen/src/sepolgen/audit.py b/python/sepolgen/src/sepolgen/audit.py
>> index daed58ce9643..4adb851f3e93 100644
>> --- a/python/sepolgen/src/sepolgen/audit.py
>> +++ b/python/sepolgen/src/sepolgen/audit.py
>> @@ -258,7 +258,7 @@ class AVCMessage(AuditMessage):
>>          if (scontext, tcontext, self.tclass, access_tuple) in avcdict.keys():
>>              self.type, self.data = avcdict[(scontext, tcontext, self.tclass, access_tuple)]
>>          else:
>> -            self.type, self.data = audit2why.analyze(scontext, tcontext, self.tclass, self.accesses);
>> +            self.type, self.data = audit2why.analyze(scontext, tcontext, self.tclass, self.accesses)
>>              if self.type == audit2why.NOPOLICY:
>>                  self.type = audit2why.TERULE
>>              if self.type == audit2why.BADTCON:
>> diff --git a/python/sepolgen/src/sepolgen/yacc.py b/python/sepolgen/src/sepolgen/yacc.py
>> index f00635469af1..afef174849f2 100644
>> --- a/python/sepolgen/src/sepolgen/yacc.py
>> +++ b/python/sepolgen/src/sepolgen/yacc.py
>> @@ -1864,10 +1864,10 @@ del _lr_action_items
>>  """)
>>
>>          else:
>> -            f.write("\n_lr_action = { ");
>> +            f.write("\n_lr_action = { ")
>>              for k,v in _lr_action.items():
>>                  f.write("(%r,%r):%r," % (k[0],k[1],v))
>> -            f.write("}\n");
>> +            f.write("}\n")
>>
>>          if smaller:
>>              # Factor out names to try and make smaller
>> @@ -1901,10 +1901,10 @@ for _k, _v in _lr_goto_items.items():
>>  del _lr_goto_items
>>  """)
>>          else:
>> -            f.write("\n_lr_goto = { ");
>> +            f.write("\n_lr_goto = { ")
>>              for k,v in _lr_goto.items():
>>                  f.write("(%r,%r):%r," % (k[0],k[1],v))
>> -            f.write("}\n");
>> +            f.write("}\n")
>>
>>          # Write production table
>>          f.write("_lr_productions = [\n")
>> diff --git a/python/sepolicy/sepolicy/manpage.py b/python/sepolicy/sepolicy/manpage.py
>> index cb211ba083ca..cfcb7c3932d7 100755
>> --- a/python/sepolicy/sepolicy/manpage.py
>> +++ b/python/sepolicy/sepolicy/manpage.py
>> @@ -539,7 +539,7 @@ class ManPage:
>>                      self.fd = fd
>>                      self.man_page_path = man_page_path
>>              except KeyError:
>> -                continue;
>> +                continue
>>              self.attributes[domain_type] = next(sepolicy.info(sepolicy.TYPE, ("%s") % domain_type))["attributes"]
>>
>>          self._header()
>> diff --git a/scripts/run-flake8 b/scripts/run-flake8
>> index 8a1f490b8a62..207edd20dd89 100755
>> --- a/scripts/run-flake8
>> +++ b/scripts/run-flake8
>> @@ -14,7 +14,6 @@ IGNORE_LIST=''
>>  IGNORE_LIST="$IGNORE_LIST,W191" # indentation contains tabs
>>
>>  IGNORE_LIST="$IGNORE_LIST,E101" # indentation contains mixed spaces and tabs
>> -IGNORE_LIST="$IGNORE_LIST,E703" # statement ends with a semicolon
>>  IGNORE_LIST="$IGNORE_LIST,E711" # comparison to None should be 'if cond is not None:'
>>  IGNORE_LIST="$IGNORE_LIST,E712" # comparison to False should be 'if cond is False:' or 'if not cond:'
>>  IGNORE_LIST="$IGNORE_LIST,E722" # do not use bare 'except'
>> --
>> 2.18.0
>>
>> _______________________________________________
>> Selinux mailing list
>> Selinux@tycho.nsa.gov
>> To unsubscribe, send email to Selinux-leave@tycho.nsa.gov.
>> To get help, send an email containing "help" to Selinux-request@tycho.nsa.gov.
>
>
diff mbox series

Patch

diff --git a/python/sepolgen/src/sepolgen/audit.py b/python/sepolgen/src/sepolgen/audit.py
index daed58ce9643..4adb851f3e93 100644
--- a/python/sepolgen/src/sepolgen/audit.py
+++ b/python/sepolgen/src/sepolgen/audit.py
@@ -258,7 +258,7 @@  class AVCMessage(AuditMessage):
         if (scontext, tcontext, self.tclass, access_tuple) in avcdict.keys():
             self.type, self.data = avcdict[(scontext, tcontext, self.tclass, access_tuple)]
         else:
-            self.type, self.data = audit2why.analyze(scontext, tcontext, self.tclass, self.accesses);
+            self.type, self.data = audit2why.analyze(scontext, tcontext, self.tclass, self.accesses)
             if self.type == audit2why.NOPOLICY:
                 self.type = audit2why.TERULE
             if self.type == audit2why.BADTCON:
diff --git a/python/sepolgen/src/sepolgen/yacc.py b/python/sepolgen/src/sepolgen/yacc.py
index f00635469af1..afef174849f2 100644
--- a/python/sepolgen/src/sepolgen/yacc.py
+++ b/python/sepolgen/src/sepolgen/yacc.py
@@ -1864,10 +1864,10 @@  del _lr_action_items
 """)
             
         else:
-            f.write("\n_lr_action = { ");
+            f.write("\n_lr_action = { ")
             for k,v in _lr_action.items():
                 f.write("(%r,%r):%r," % (k[0],k[1],v))
-            f.write("}\n");
+            f.write("}\n")
 
         if smaller:
             # Factor out names to try and make smaller
@@ -1901,10 +1901,10 @@  for _k, _v in _lr_goto_items.items():
 del _lr_goto_items
 """)
         else:
-            f.write("\n_lr_goto = { ");
+            f.write("\n_lr_goto = { ")
             for k,v in _lr_goto.items():
                 f.write("(%r,%r):%r," % (k[0],k[1],v))                    
-            f.write("}\n");
+            f.write("}\n")
 
         # Write production table
         f.write("_lr_productions = [\n")
diff --git a/python/sepolicy/sepolicy/manpage.py b/python/sepolicy/sepolicy/manpage.py
index cb211ba083ca..cfcb7c3932d7 100755
--- a/python/sepolicy/sepolicy/manpage.py
+++ b/python/sepolicy/sepolicy/manpage.py
@@ -539,7 +539,7 @@  class ManPage:
                     self.fd = fd
                     self.man_page_path = man_page_path
             except KeyError:
-                continue;
+                continue
             self.attributes[domain_type] = next(sepolicy.info(sepolicy.TYPE, ("%s") % domain_type))["attributes"]
 
         self._header()
diff --git a/scripts/run-flake8 b/scripts/run-flake8
index 8a1f490b8a62..207edd20dd89 100755
--- a/scripts/run-flake8
+++ b/scripts/run-flake8
@@ -14,7 +14,6 @@  IGNORE_LIST=''
 IGNORE_LIST="$IGNORE_LIST,W191" # indentation contains tabs
 
 IGNORE_LIST="$IGNORE_LIST,E101" # indentation contains mixed spaces and tabs
-IGNORE_LIST="$IGNORE_LIST,E703" # statement ends with a semicolon
 IGNORE_LIST="$IGNORE_LIST,E711" # comparison to None should be 'if cond is not None:'
 IGNORE_LIST="$IGNORE_LIST,E712" # comparison to False should be 'if cond is False:' or 'if not cond:'
 IGNORE_LIST="$IGNORE_LIST,E722" # do not use bare 'except'