/logilab-astng-0.23.1/test/regrtest_data/package/import_package_subpackage_module.py

# · Python · 68 lines · 44 code · 0 blank · 24 comment · 0 complexity · 0201d38fc6dba22547ee0a32e7ed233b MD5 · raw file

  1. # pylint: disable-msg=I0011,C0301,W0611
  2. # copyright 2003-2010 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
  3. # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
  4. # copyright 2003-2010 Sylvain Thenault, all rights reserved.
  5. # contact mailto:thenault@gmail.com
  6. #
  7. # This file is part of logilab-astng.
  8. #
  9. # logilab-astng is free software: you can redistribute it and/or modify it
  10. # under the terms of the GNU Lesser General Public License as published by the
  11. # Free Software Foundation, either version 2.1 of the License, or (at your
  12. # option) any later version.
  13. #
  14. # logilab-astng is distributed in the hope that it will be useful, but
  15. # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  16. # FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
  17. # for more details.
  18. #
  19. # You should have received a copy of the GNU Lesser General Public License along
  20. # with logilab-astng. If not, see <http://www.gnu.org/licenses/>.
  21. """I found some of my scripts trigger off an AttributeError in pylint
  22. 0.8.1 (with common 0.12.0 and astng 0.13.1).
  23. Traceback (most recent call last):
  24. File "/usr/bin/pylint", line 4, in ?
  25. lint.Run(sys.argv[1:])
  26. File "/usr/lib/python2.4/site-packages/pylint/lint.py", line 729, in __init__
  27. linter.check(args)
  28. File "/usr/lib/python2.4/site-packages/pylint/lint.py", line 412, in check
  29. self.check_file(filepath, modname, checkers)
  30. File "/usr/lib/python2.4/site-packages/pylint/lint.py", line 426, in check_file
  31. astng = self._check_file(filepath, modname, checkers)
  32. File "/usr/lib/python2.4/site-packages/pylint/lint.py", line 450, in _check_file
  33. self.check_astng_module(astng, checkers)
  34. File "/usr/lib/python2.4/site-packages/pylint/lint.py", line 494, in check_astng_module
  35. self.astng_events(astng, [checker for checker in checkers
  36. File "/usr/lib/python2.4/site-packages/pylint/lint.py", line 511, in astng_events
  37. self.astng_events(child, checkers, _reversed_checkers)
  38. File "/usr/lib/python2.4/site-packages/pylint/lint.py", line 511, in astng_events
  39. self.astng_events(child, checkers, _reversed_checkers)
  40. File "/usr/lib/python2.4/site-packages/pylint/lint.py", line 508, in astng_events
  41. checker.visit(astng)
  42. File "/usr/lib/python2.4/site-packages/logilab/astng/utils.py", line 84, in visit
  43. method(node)
  44. File "/usr/lib/python2.4/site-packages/pylint/checkers/variables.py", line 295, in visit_import
  45. self._check_module_attrs(node, module, name_parts[1:])
  46. File "/usr/lib/python2.4/site-packages/pylint/checkers/variables.py", line 357, in _check_module_attrs
  47. self.add_message('E0611', args=(name, module.name),
  48. AttributeError: Import instance has no attribute 'name'
  49. You can reproduce it by:
  50. (1) create package structure like the following:
  51. package/
  52. __init__.py
  53. subpackage/
  54. __init__.py
  55. module.py
  56. (2) in package/__init__.py write:
  57. import subpackage
  58. (3) run pylint with a script importing package.subpackage.module.
  59. """
  60. __revision__ = '$Id: import_package_subpackage_module.py,v 1.1 2005-11-10 15:59:32 syt Exp $'
  61. import package.subpackage.module