[PATCH] test-check-pyflakes.t: accept warnings for unused imports in windows.py

Adrian Buehlmann adrian at cadifra.com
Tue Aug 2 09:18:53 CDT 2011


On 2011-08-02 15:54, Augie Fackler wrote:
> On Tue, Aug 2, 2011 at 2:07 AM, Adrian Buehlmann <adrian at cadifra.com> wrote:
>> On 2011-08-02 09:03, Adrian Buehlmann wrote:
>>> On 2011-08-02 02:26, Mads Kiilerich wrote:
>>>> # HG changeset patch
>>>> # User Mads Kiilerich <mads at kiilerich.com>
>>>> # Date 1312244721 -7200
>>>> # Node ID adf2946cbb9b74a3c22a7754e55e5f1e209cbdca
>>>> # Parent  d0424f39984c6d623dc8c55b85de66f15e27abd6
>>>> test-check-pyflakes.t: accept warnings for unused imports in windows.py
>>>>
>>>> The intention with the imports is to make the functions defined in win32
>>>> available in the namespace of the windows module.
>>>
>>> Indeed. And those names *are* used. Just not in windows.py. Which
>>> pyflakes fails to see for these mass imports.
>>>
>>>> diff --git a/tests/test-check-pyflakes.t b/tests/test-check-pyflakes.t
>>>> --- a/tests/test-check-pyflakes.t
>>>> +++ b/tests/test-check-pyflakes.t
>>>> @@ -4,8 +4,20 @@
>>>>    mercurial/hgweb/server.py:*: 'activeCount' imported but unused (glob)
>>>>    mercurial/commands.py:*: 'base85' imported but unused (glob)
>>>>    mercurial/commands.py:*: 'bdiff' imported but unused (glob)
>>>> +  mercurial/windows.py:*: 'executablepath' imported but unused (glob)
>>>> +  mercurial/windows.py:*: 'getuser' imported but unused (glob)
>>>> +  mercurial/windows.py:*: 'hidewindow' imported but unused (glob)
>>>> +  mercurial/windows.py:*: 'lookupreg' imported but unused (glob)
>>>> +  mercurial/windows.py:*: 'makedir' imported but unused (glob)
>>>>    mercurial/commands.py:*: 'mpatch' imported but unused (glob)
>>>> +  mercurial/windows.py:*: 'nlinks' imported but unused (glob)
>>>> +  mercurial/windows.py:*: 'oslink' imported but unused (glob)
>>>>    mercurial/commands.py:*: 'osutil' imported but unused (glob)
>>>> +  mercurial/windows.py:*: 'samedevice' imported but unused (glob)
>>>> +  mercurial/windows.py:*: 'samefile' imported but unused (glob)
>>>> +  mercurial/windows.py:*: 'setsignalhandler' imported but unused (glob)
>>>> +  mercurial/windows.py:*: 'spawndetached' imported but unused (glob)
>>>> +  mercurial/windows.py:*: 'testpid' imported but unused (glob)
>>>>    hgext/inotify/linux/__init__.py:*: 'from _inotify import *' used; unable to detect undefined names (glob)
>>
>> Another problem with this fix is that, as soon as one of these happens
>> to be used in windows.py, we have to adapt this again. Obscure.
>>
>>> So we have to update test-check-pyflakes.t each time we add such an
>>> import. Tedious.
>>>
>>> FWIW, my first version of the patch ("windows: eliminate win32 wildcard
>>> import") - which you didn't like - sidestepped this pyflakes problem.
> 
> I don't relish the idea of disabling pyflakes on an entire file
> either. That said, pylint can notice comments in a particular format
> for disabling warnings on a per-line or per-file basis. Is there some
> equivalent feature in pyflakes?

It's the only file that has a mass import list. And windows.py is
special anyway. It's amazing to see that many linux people caring about
windows specific code.

What problem is pyflakes solving in windows.py exactly? Do we really
need to spend that much time on this detail?


More information about the Mercurial-devel mailing list