mbox series

[00/13] Fix some issues found by flake8

Message ID 20180804194734.12577-1-nicolas.iooss@m4x.org (mailing list archive)
Headers show
Series Fix some issues found by flake8 | expand

Message

Nicolas Iooss Aug. 4, 2018, 7:47 p.m. UTC
Hi,

I have been working on a script which uses flake8 to discover issues in
Python code. This led me to discover several issues which are fixed by
these patches. Distribution maintainers might be interested in
backporting some of them (at least patches 5 and 10 and probably the
ones which fix usage of undefined variables).

As Travis-CI is experiencing issues today (it fails to launch new
builds), I have not been able to test the integration of my script with
Travis-CI yet. Once it works again I will submit this script too.

Thanks,
Nicolas

---
Here comes the description generated by "git format-patch --cover":

Nicolas Iooss (13):
  libselinux: fix flake8 warnings in SWIG-generated code
  python/sepolgen: do not import twice the modules
  python/sepolgen: return NotImplemented instead of raising it
  python/sepolicy: drop unused CheckPolicyType
  python/sepolicy: use lowercase variable name
  python/sepolgen: fix refpolicy parsing of "permissive"
  python/sepolgen: silence linter warning about has_key
  python/sepolgen: comment buggy code
  python/sepolgen: use self when accessing members in FilesystemUse
  python/sepolicy: fix "procotol" misspelling
  python/sepolicy: use variables which exists in the gui.py
  python/sepolicy: do not import sepolicy.generate.DAEMON twice
  python/sepolicy: do not import types

 libselinux/src/selinuxswig_python.i        |  5 +++--
 python/sepolgen/src/sepolgen/interfaces.py | 10 +++++-----
 python/sepolgen/src/sepolgen/refparser.py  |  4 ++--
 python/sepolgen/src/sepolgen/refpolicy.py  |  6 +++---
 python/sepolgen/src/sepolgen/util.py       |  6 +-----
 python/sepolicy/sepolicy.py                | 12 +-----------
 python/sepolicy/sepolicy/generate.py       |  1 -
 python/sepolicy/sepolicy/gui.py            | 12 ++++++------
 8 files changed, 21 insertions(+), 35 deletions(-)

Comments

William Roberts Aug. 6, 2018, 3:05 p.m. UTC | #1
On Sat, Aug 4, 2018 at 12:47 PM, Nicolas Iooss <nicolas.iooss@m4x.org>
wrote:

> Hi,
>
> I have been working on a script which uses flake8 to discover issues in
> Python code. This led me to discover several issues which are fixed by
> these patches. Distribution maintainers might be interested in
> backporting some of them (at least patches 5 and 10 and probably the
> ones which fix usage of undefined variables).
>
> As Travis-CI is experiencing issues today (it fails to launch new
> builds), I have not been able to test the integration of my script with
> Travis-CI yet. Once it works again I will submit this script too.
>
> Thanks,
> Nicolas
>
> ---
> Here comes the description generated by "git format-patch --cover":
>
> Nicolas Iooss (13):
>   libselinux: fix flake8 warnings in SWIG-generated code
>   python/sepolgen: do not import twice the modules
>   python/sepolgen: return NotImplemented instead of raising it
>   python/sepolicy: drop unused CheckPolicyType
>   python/sepolicy: use lowercase variable name
>   python/sepolgen: fix refpolicy parsing of "permissive"
>
  python/sepolgen: silence linter warning about has_key
>

This is the only one I don't particularly like:

>   python/sepolgen: comment buggy code
>

If we choose to comment out it out, a block comment explaining why would be
helpful or just delete it if it is dead code.

   python/sepolgen: use self when accessing members in FilesystemUse

>   python/sepolicy: fix "procotol" misspelling
>   python/sepolicy: use variables which exists in the gui.py
>   python/sepolicy: do not import sepolicy.generate.DAEMON twice
>   python/sepolicy: do not import types
>
>  libselinux/src/selinuxswig_python.i        |  5 +++--
>  python/sepolgen/src/sepolgen/interfaces.py | 10 +++++-----
>  python/sepolgen/src/sepolgen/refparser.py  |  4 ++--
>  python/sepolgen/src/sepolgen/refpolicy.py  |  6 +++---
>  python/sepolgen/src/sepolgen/util.py       |  6 +-----
>  python/sepolicy/sepolicy.py                | 12 +-----------
>  python/sepolicy/sepolicy/generate.py       |  1 -
>  python/sepolicy/sepolicy/gui.py            | 12 ++++++------
>  8 files changed, 21 insertions(+), 35 deletions(-)
>
> --
> 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"><br><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Aug 4, 2018 at 12:47 PM, 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">Hi,<br>
<br>
I have been working on a script which uses flake8 to discover issues in<br>
Python code. This led me to discover several issues which are fixed by<br>
these patches. Distribution maintainers might be interested in<br>
backporting some of them (at least patches 5 and 10 and probably the<br>
ones which fix usage of undefined variables).<br>
<br>
As Travis-CI is experiencing issues today (it fails to launch new<br>
builds), I have not been able to test the integration of my script with<br>
Travis-CI yet. Once it works again I will submit this script too.<br>
<br>
Thanks,<br>
Nicolas<br>
<br>
---<br>
Here comes the description generated by &quot;git format-patch --cover&quot;:<br>
<br>
Nicolas Iooss (13):<br>
  libselinux: fix flake8 warnings in SWIG-generated code<br>
  python/sepolgen: do not import twice the modules<br>
  python/sepolgen: return NotImplemented instead of raising it<br>
  python/sepolicy: drop unused CheckPolicyType<br>
  python/sepolicy: use lowercase variable name<br>
  python/sepolgen: fix refpolicy parsing of &quot;permissive&quot;<br>
</blockquote><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">  python/sepolgen: silence linter warning about has_key<br>
</blockquote><div><br></div><div>This is the only one I don&#39;t particularly like: </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">  python/sepolgen: comment buggy code<br></blockquote><div><br></div><div>If we choose to comment out it out, a block comment explaining why would be</div><div>helpful or just delete it if it is dead code.</div><div><br></div><div>   python/sepolgen: use self when accessing members in FilesystemUse</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
  python/sepolicy: fix &quot;procotol&quot; misspelling<br>
  python/sepolicy: use variables which exists in the gui.py<br>
  python/sepolicy: do not import sepolicy.generate.DAEMON twice<br>
  python/sepolicy: do not import types<br>
<br>
 libselinux/src/selinuxswig_<wbr>python.i        |  5 +++--<br>
 python/sepolgen/src/sepolgen/<wbr>interfaces.py | 10 +++++-----<br>
 python/sepolgen/src/sepolgen/<wbr>refparser.py  |  4 ++--<br>
 python/sepolgen/src/sepolgen/<wbr>refpolicy.py  |  6 +++---<br>
 python/sepolgen/src/sepolgen/<wbr>util.py       |  6 +-----<br>
 python/sepolicy/sepolicy.py                | 12 +-----------<br>
 python/sepolicy/sepolicy/<wbr>generate.py       |  1 -<br>
 python/sepolicy/sepolicy/gui.<wbr>py            | 12 ++++++------<br>
 8 files changed, 21 insertions(+), 35 deletions(-)<br>
<span class="HOEnZb"><font color="#888888"><br>
-- <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></div>
Nicolas Iooss Aug. 6, 2018, 8:26 p.m. UTC | #2
On Mon, Aug 6, 2018 at 5:05 PM, William Roberts
<bill.c.roberts@gmail.com> wrote:
>
> On Sat, Aug 4, 2018 at 12:47 PM, Nicolas Iooss <nicolas.iooss@m4x.org>
> wrote:
>>
>> Hi,
>>
>> I have been working on a script which uses flake8 to discover issues in
>> Python code. This led me to discover several issues which are fixed by
>> these patches. Distribution maintainers might be interested in
>> backporting some of them (at least patches 5 and 10 and probably the
>> ones which fix usage of undefined variables).
>>
>> As Travis-CI is experiencing issues today (it fails to launch new
>> builds), I have not been able to test the integration of my script with
>> Travis-CI yet. Once it works again I will submit this script too.
>>
>> Thanks,
>> Nicolas
>>
>> ---
>> Here comes the description generated by "git format-patch --cover":
>>
>> Nicolas Iooss (13):
>>   libselinux: fix flake8 warnings in SWIG-generated code
>>   python/sepolgen: do not import twice the modules
>>   python/sepolgen: return NotImplemented instead of raising it
>>   python/sepolicy: drop unused CheckPolicyType
>>   python/sepolicy: use lowercase variable name
>>   python/sepolgen: fix refpolicy parsing of "permissive"
>>
>>   python/sepolgen: silence linter warning about has_key
>
>
> This is the only one I don't particularly like:
>>
>>   python/sepolgen: comment buggy code
>
>
> If we choose to comment out it out, a block comment explaining why would be
> helpful or just delete it if it is dead code.

It feels like this code could be useful if an interface parameter
("$1") is used as a permission, which is why I have not deleted it. I
suggest adding the following comment:

    # This function currently ignores parameters which are used in permission.
    # The following code has been present for a long time and contains two
    # syntax errors (__param_insert takes 4 arguments and PERM is not defined)
    # which proves that it is actually dead code.
    #for perm in av.perms:
    #    if access.is_idparam(perm):
    #        if __param_insert(perm, PERM) == 1:
    #            ret = 1

Does this suit you? By the way, I do not have a strong opinion about
commenting or deleting it, so I am fine if we choose to remove this
code instead.

Thanks for your review,
Nicolas
William Roberts Aug. 7, 2018, 5:01 p.m. UTC | #3
On Mon, Aug 6, 2018 at 1:26 PM, Nicolas Iooss <nicolas.iooss@m4x.org> wrote:

> On Mon, Aug 6, 2018 at 5:05 PM, William Roberts
> <bill.c.roberts@gmail.com> wrote:
> >
> > On Sat, Aug 4, 2018 at 12:47 PM, Nicolas Iooss <nicolas.iooss@m4x.org>
> > wrote:
> >>
> >> Hi,
> >>
> >> I have been working on a script which uses flake8 to discover issues in
> >> Python code. This led me to discover several issues which are fixed by
> >> these patches. Distribution maintainers might be interested in
> >> backporting some of them (at least patches 5 and 10 and probably the
> >> ones which fix usage of undefined variables).
> >>
> >> As Travis-CI is experiencing issues today (it fails to launch new
> >> builds), I have not been able to test the integration of my script with
> >> Travis-CI yet. Once it works again I will submit this script too.
> >>
> >> Thanks,
> >> Nicolas
> >>
> >> ---
> >> Here comes the description generated by "git format-patch --cover":
> >>
> >> Nicolas Iooss (13):
> >>   libselinux: fix flake8 warnings in SWIG-generated code
> >>   python/sepolgen: do not import twice the modules
> >>   python/sepolgen: return NotImplemented instead of raising it
> >>   python/sepolicy: drop unused CheckPolicyType
> >>   python/sepolicy: use lowercase variable name
> >>   python/sepolgen: fix refpolicy parsing of "permissive"
> >>
> >>   python/sepolgen: silence linter warning about has_key
> >
> >
> > This is the only one I don't particularly like:
> >>
> >>   python/sepolgen: comment buggy code
> >
> >
> > If we choose to comment out it out, a block comment explaining why would
> be
> > helpful or just delete it if it is dead code.
>
> It feels like this code could be useful if an interface parameter
> ("$1") is used as a permission, which is why I have not deleted it. I
> suggest adding the following comment:
>
>     # This function currently ignores parameters which are used in
> permission.
>     # The following code has been present for a long time and contains two
>     # syntax errors (__param_insert takes 4 arguments and PERM is not
> defined)
>     # which proves that it is actually dead code.
>     #for perm in av.perms:
>     #    if access.is_idparam(perm):
>     #        if __param_insert(perm, PERM) == 1:
>     #            ret = 1
>
> Does this suit you? By the way, I do not have a strong opinion about
> commenting or deleting it, so I am fine if we choose to remove this
> code instead.
>

I'm all for deleting it. I think we should just do that.


>
> Thanks for your review,
> Nicolas
>
>
<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Aug 6, 2018 at 1:26 PM, 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"><div class="HOEnZb"><div class="h5">On Mon, Aug 6, 2018 at 5:05 PM, William Roberts<br>
&lt;<a href="mailto:bill.c.roberts@gmail.com">bill.c.roberts@gmail.com</a>&gt; wrote:<br>
&gt;<br>
&gt; On Sat, Aug 4, 2018 at 12:47 PM, Nicolas Iooss &lt;<a href="mailto:nicolas.iooss@m4x.org">nicolas.iooss@m4x.org</a>&gt;<br>
&gt; wrote:<br>
&gt;&gt;<br>
&gt;&gt; Hi,<br>
&gt;&gt;<br>
&gt;&gt; I have been working on a script which uses flake8 to discover issues in<br>
&gt;&gt; Python code. This led me to discover several issues which are fixed by<br>
&gt;&gt; these patches. Distribution maintainers might be interested in<br>
&gt;&gt; backporting some of them (at least patches 5 and 10 and probably the<br>
&gt;&gt; ones which fix usage of undefined variables).<br>
&gt;&gt;<br>
&gt;&gt; As Travis-CI is experiencing issues today (it fails to launch new<br>
&gt;&gt; builds), I have not been able to test the integration of my script with<br>
&gt;&gt; Travis-CI yet. Once it works again I will submit this script too.<br>
&gt;&gt;<br>
&gt;&gt; Thanks,<br>
&gt;&gt; Nicolas<br>
&gt;&gt;<br>
&gt;&gt; ---<br>
&gt;&gt; Here comes the description generated by &quot;git format-patch --cover&quot;:<br>
&gt;&gt;<br>
&gt;&gt; Nicolas Iooss (13):<br>
&gt;&gt;   libselinux: fix flake8 warnings in SWIG-generated code<br>
&gt;&gt;   python/sepolgen: do not import twice the modules<br>
&gt;&gt;   python/sepolgen: return NotImplemented instead of raising it<br>
&gt;&gt;   python/sepolicy: drop unused CheckPolicyType<br>
&gt;&gt;   python/sepolicy: use lowercase variable name<br>
&gt;&gt;   python/sepolgen: fix refpolicy parsing of &quot;permissive&quot;<br>
&gt;&gt;<br>
&gt;&gt;   python/sepolgen: silence linter warning about has_key<br>
&gt;<br>
&gt;<br>
&gt; This is the only one I don&#39;t particularly like:<br>
&gt;&gt;<br>
&gt;&gt;   python/sepolgen: comment buggy code<br>
&gt;<br>
&gt;<br>
&gt; If we choose to comment out it out, a block comment explaining why would be<br>
&gt; helpful or just delete it if it is dead code.<br>
<br>
</div></div>It feels like this code could be useful if an interface parameter<br>
(&quot;$1&quot;) is used as a permission, which is why I have not deleted it. I<br>
suggest adding the following comment:<br>
<br>
    # This function currently ignores parameters which are used in permission.<br>
    # The following code has been present for a long time and contains two<br>
    # syntax errors (__param_insert takes 4 arguments and PERM is not defined)<br>
    # which proves that it is actually dead code.<br>
    #for perm in av.perms:<br>
    #    if access.is_idparam(perm):<br>
    #        if __param_insert(perm, PERM) == 1:<br>
    #            ret = 1<br>
<br>
Does this suit you? By the way, I do not have a strong opinion about<br>
commenting or deleting it, so I am fine if we choose to remove this<br>
code instead.<br></blockquote><div><br></div><div>I&#39;m all for deleting it. I think we should just do that.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Thanks for your review,<br>
Nicolas<br>
<br>
</blockquote></div><br></div></div>