[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
gnulib-tool.py: Fix pylint 'attribute-defined-outside-init' warnings.
From: |
Collin Funk |
Subject: |
gnulib-tool.py: Fix pylint 'attribute-defined-outside-init' warnings. |
Date: |
Tue, 16 Apr 2024 21:11:31 -0700 |
User-agent: |
Mozilla Thunderbird |
I mentioned a change involving moving an attribute definition to its
proper place in __init__ here:
https://lists.gnu.org/archive/html/bug-gnulib/2024-04/msg00270.html
But I noticed that pylint will warn about these [1]. So it seems
easier to fix them all at once instead of in the middle of other
changes.
$ pylint *.py | grep W0201
GLError.py:119:12: W0201: Attribute 'message' defined outside __init__
(attribute-defined-outside-init)
GLImport.py:1043:8: W0201: Attribute 'assistant' defined outside __init__
(attribute-defined-outside-init)
GLModuleSystem.py:916:8: W0201: Attribute 'modules' defined outside __init__
(attribute-defined-outside-init)
GLError seems like it was never completed, since we have the error
messages repeated under "if __name__ == '__main__':". But it seems
__repr__ expects 'messages' to be initialized to None. So we can just
do that now in __init__.
GLImport defines 'assistant' in GLImport.execute(). I plan to remove
that definition and just mutate an instance attribute. Before that
change, it is harmless to initialize it to a GLFileAssistant in
__init__ so lets do that. We already unnecessarily create a
GLFileSystem that we don't need to [2] [3]. :)
The GLModuleSystem.transitive_closure() function defines a 'modules'
attribute that is never used. We can just remove it.
[1]
https://pylint.readthedocs.io/en/latest/user_guide/messages/warning/attribute-defined-outside-init.html
[2]
https://git.savannah.gnu.org/cgit/gnulib.git/tree/pygnulib/GLImport.py?id=64a7072ee8636c53bc2000505668bd0e33bb427e#n305
[3]
https://git.savannah.gnu.org/cgit/gnulib.git/tree/pygnulib/GLImport.py?id=64a7072ee8636c53bc2000505668bd0e33bb427e#n1134
Collin
0001-gnulib-tool.py-Fix-pylint-attribute-defined-outside-.patch
Description: Text Data
- gnulib-tool.py: Fix pylint 'attribute-defined-outside-init' warnings.,
Collin Funk <=
- Re: gnulib-tool.py: Fix pylint 'attribute-defined-outside-init' warnings., Bruno Haible, 2024/04/17
- Re: gnulib-tool.py: Fix pylint 'attribute-defined-outside-init' warnings., Collin Funk, 2024/04/17
- Re: gnulib-tool.py: Fix pylint 'attribute-defined-outside-init' warnings., Bruno Haible, 2024/04/17
- Re: gnulib-tool.py: Fix pylint 'attribute-defined-outside-init' warnings., Collin Funk, 2024/04/17
- Re: gnulib-tool.py: Fix pylint 'attribute-defined-outside-init' warnings., Bruno Haible, 2024/04/18
- Re: gnulib-tool.py: Fix pylint 'attribute-defined-outside-init' warnings., Collin Funk, 2024/04/18
- Re: gnulib-tool.py: Fix pylint 'attribute-defined-outside-init' warnings., Bruno Haible, 2024/04/19