#694 pylint errors from other files shown on __init__.py

closed-wont-fix
nobody
None
5
2008-05-05
2008-05-04
Conrado PLG
No

If you are editing a __init__.py file (from a package) and another file in the project (in the same package) has some pylint errors, the errors are also shown in the __init__.py file.

PyDev 1.3.15, Eclipse 3.3.3 on Windows XP SP 2

Discussion

  • Fabio Zadrozny
    Fabio Zadrozny
    2008-05-04

    Logged In: YES
    user_id=617340
    Originator: NO

    That's a PyLint bug: http://www.logilab.org/ticket/2473 (so, I suggest adding some comments to that bug explaining it there... you can also reference this bug in the logilab bug)

    When you run PyLint on an __init__.py file, it gives errors on the whole package and not only on that file... At least, doing it in the command line here on a simple example:

    Having a structure with /mod1/mod2/ (with __init__.py in each) and a file aa.py inside mod2, executing the command below yields errors for aa.py too:

    python d:\bin\Python251\Lib\site-packages\pylint\lint.py --include-ids=y d:\temp\temp_workspace_2\testjyhon\src\mod1\mod2\__init__.py

    or executing as:

    python d:\bin\Python251\Lib\site-packages\pylint\lint.py --include-ids=y __init__.py

    yields the output below:

    No config file found, using default configuration
    ************* Module __init__
    C0111: 1: Missing docstring
    C0103: 1:A: Invalid name "A" (should match [A-Z_][a-zA-Z0-9]+$)
    C0111: 1:A: Missing docstring
    R0903: 1:A: Too few public methods (0/2)
    ************* Module aa
    C0111: 1: Missing docstring
    C0111: 4:BBBBB: Missing docstring
    E0602: 6:BBBBB.__init__: Undefined variable 'undefinederror'
    R0903: 4:BBBBB: Too few public methods (0/2)
    C0103: 7:A: Invalid name "A" (should match [A-Z_][a-zA-Z0-9]+$)
    C0111: 7:A: Missing docstring
    E0602: 9:A.__init__: Undefined variable 'undefinederror'
    R0903: 7:A: Too few public methods (0/2)

     
  • Fabio Zadrozny
    Fabio Zadrozny
    2008-05-04

    Logged In: YES
    user_id=617340
    Originator: NO

    Marking as won't fix because it should be fixed in PyLint and not in Pydev.

     
  • Fabio Zadrozny
    Fabio Zadrozny
    2008-05-04

    • status: open --> open-wont-fix
     
  • Fabio Zadrozny
    Fabio Zadrozny
    2008-05-05

    • status: open-wont-fix --> closed-wont-fix
     
  • Logged In: YES
    user_id=884962
    Originator: NO

    I must disagree here, for me it makes a difference between using the full path for __init__.py or not:

    siebert@steffen:~/testworkspace/test/testpackage$ pylint --include-ids=y -r n /home/siebert/testworkspace/test/testpackage/__init__.py
    ************* Module __init__
    C0111: 5:Dummy: Missing docstring
    W0232: 5:Dummy: Class has no __init__ method
    ************* Module Test2
    C0111: 1: Missing docstring
    W0611: 1: Unused import os
    ************* Module Test
    C0111: 1: Missing docstring
    C0111: 4:Test: Missing docstring
    W0232: 4:Test: Class has no __init__ method
    W0611: 1: Unused import sys

    siebert@steffen:~/testworkspace/test/testpackage$ pylint --include-ids=y -r n __init__.py
    ************* Module __init__
    C0111: 5:Dummy: Missing docstring
    W0232: 5:Dummy: Class has no __init__ method

    I'm using pylint 0.14.0

    The following patch for pylint seem to fix the problem, but I'm not 100% sure that it doesn't break something else:

    siebert@steffen:/usr/lib/python2.5/site-packages/pylint$ diff lint.py.orig lint.py
    534c534
    < if not modname.endswith('.__init__') and '__init__.py' in filepath:
    ---
    > if not modname.endswith('__init__') and '__init__.py' in filepath:

    Same tests with the patched pylint:

    siebert@steffen:~/testworkspace/test/testpackage$ pylint --include-ids=y -r n /home/siebert/testworkspace/test/testpackage/__init__.py
    ************* Module __init__
    C0111: 5:Dummy: Missing docstring
    W0232: 5:Dummy: Class has no __init__ method

    siebert@steffen:~/testworkspace/test/testpackage$ pylint --include-ids=y -r n __init__.py
    ************* Module __init__
    C0111: 5:Dummy: Missing docstring
    W0232: 5:Dummy: Class has no __init__ method

     
  • Fabio Zadrozny
    Fabio Zadrozny
    2008-05-09

    Logged In: YES
    user_id=617340
    Originator: NO

    The difference may be regarding windows / linux.

    Thanks for the info (maybe it should be reported to the PyLint guys too)

    Cheers,

    Fabio

     
  • Logged In: YES
    user_id=884962
    Originator: NO

    Hi,

    I send a message to the Python-Projects (pylint) mailing list about this issue and my patch.

    Another somewhat related question: Does PyDev need the full report of pylint, or only the messages so I can use the --reports=n option?

    Ciao,
    Steffen

     
  • Fabio Zadrozny
    Fabio Zadrozny
    2008-05-13

    Logged In: YES
    user_id=617340
    Originator: NO

    It only needs the messages (so having --reports=n should be safe -- although I didn't test it).