#6874 pylint 1.7.1 fails
Closed: fixed Opened by cheimes.

AttributeError: 'Module' object has no attribute 'source_file'

Node objects no longer have a source_file attribute. node.path seems to work.

Traceback (most recent call last):
  File "/usr/lib64/python2.7/multiprocessing/process.py", line 258, in _bootstrap
    self.run()
  File ".../pylint/lint.py", line 208, in run
    result = self._run_linter(file_or_module[0])
  File ".../pylint/lint.py", line 237, in _run_linter
    linter.check(file_or_module)
  File ".../pylint/lint.py", line 726, in check
    self._do_check(files_or_modules)
  File ".../pylint/lint.py", line 855, in _do_check
    self.check_astroid_module(ast_node, walker, rawcheckers, tokencheckers)
  File ".../pylint/lint.py", line 934, in check_astroid_module
    walker.walk(ast_node)
  File ".../pylint/utils.py", line 970, in walk
    cb(astroid)
  File ".../pylint_plugins.py", line 325, in visit_module
    self._get_forbidden_import_rule(node))
  File ".../pylint_plugins.py", line 314, in _get_forbidden_import_rule
    path = node.source_file
AttributeError: 'Module' object has no attribute 'source_file'

Additional warnings and failures

pylint 1.7 has additional checkers

************* Module ipaclient.plugins.automount
lib/python2.7/site-packages/ipaclient/plugins/automount.py:106: [C1801(len-as-condition), automountlocation_tofiles.output_for_cli] Do not use `len(SEQUENCE)` as condition value)
lib/python2.7/site-packages/ipaclient/plugins/automount.py:171: [C1801(len-as-condition), automountlocation_import.forward] Do not use `len(SEQUENCE)` as condition value)
lib/python2.7/site-packages/ipaclient/plugins/automount.py:230: [C1801(len-as-condition), automountlocation_import.forward] Do not use `len(SEQUENCE)` as condition value)
lib/python2.7/site-packages/ipaclient/plugins/automount.py:278: [C1801(len-as-condition), automountlocation_import.output_for_cli] Do not use `len(SEQUENCE)` as condition value)
lib/python2.7/site-packages/ipaclient/plugins/automount.py:288: [C1801(len-as-condition), automountlocation_import.output_for_cli] Do not use `len(SEQUENCE)` as condition value)
lib/python2.7/site-packages/ipaclient/plugins/automount.py:297: [C1801(len-as-condition), automountlocation_import.output_for_cli] Do not use `len(SEQUENCE)` as condition value)
************* Module ipaclient.csrgen
lib/python2.7/site-packages/ipaclient/csrgen.py:441: [W1646(invalid-str-codec), OpenSSLAdaptor.sign_csr] non-text encoding used in str.decode)
************* Module ipaclient.remote_plugins.schema
lib/python2.7/site-packages/ipaclient/remote_plugins/schema.py:244: [R1705(no-else-return), _SchemaCommandPlugin.NO_CLI] Unnecessary "else" after "return")
lib/python2.7/site-packages/ipaclient/remote_plugins/schema.py:576: [E1101(no-member), get_package] Instance of 'module' has no 'register' member)
************* Module ipalib.text
lib/python2.7/site-packages/ipalib/text.py:137: [W1641(eq-without-hash), LazyText] Implementing __eq__ without also implementing __hash__)
lib/python2.7/site-packages/ipalib/text.py:193: [C0205(single-string-used-for-slots), Gettext] Class __slots__ should be a non-string iterable)
lib/python2.7/site-packages/ipalib/text.py:256: [R1705(no-else-return), Gettext.as_unicode] Unnecessary "else" after "return")
lib/python2.7/site-packages/ipalib/text.py:271: [C0205(single-string-used-for-slots), FixMe] Class __slots__ should be a non-string iterable)
lib/python2.7/site-packages/ipalib/text.py:411: [R1705(no-else-return), NGettext.__call__] Unnecessary "else" after "return")
lib/python2.7/site-packages/ipalib/text.py:445: [R1705(no-else-return), ConcatenatedLazyText.__add__] Unnecessary "else" after "return")
lib/python2.7/site-packages/ipalib/text.py:451: [R1705(no-else-return), ConcatenatedLazyText.__radd__] Unnecessary "else" after "return")
************* Module ipalib.config
lib/python2.7/site-packages/ipalib/config.py:276: [E1137(unsupported-assignment-operation), Env.__setitem__] 'self.__d' does not support item assignment)
lib/python2.7/site-packages/ipalib/config.py:382: [C1801(len-as-condition), Env._merge_from_file] Do not use `len(SEQUENCE)` as condition value)
************* Module ipalib.plugable
lib/python2.7/site-packages/ipalib/plugable.py:166: [R1705(no-else-return), Plugin.__summary_getter] Unnecessary "else" after "return")
************* Module ipalib.aci
lib/python2.7/site-packages/ipalib/aci.py:43: [W1641(eq-without-hash), ACI] Implementing __eq__ without also implementing __hash__)
lib/python2.7/site-packages/ipalib/aci.py:167: [C1801(len-as-condition), ACI.validate] Do not use `len(SEQUENCE)` as condition value)
************* Module ipalib.util
lib/python2.7/site-packages/ipalib/util.py:145: [R1705(no-else-return), isvalid_base64] Unnecessary "else" after "return")
lib/python2.7/site-packages/ipalib/util.py:195: [R1705(no-else-return), normalize_zone] Unnecessary "else" after "return")
lib/python2.7/site-packages/ipalib/util.py:952: [R1705(no-else-return), detect_dns_zone_realm_type] Unnecessary "else" after "return")
************* Module ipalib.x509
lib/python2.7/site-packages/ipalib/x509.py:96: [R1705(no-else-return), strip_header] Unnecessary "else" after "return")
************* Module ipalib.parameters
lib/python2.7/site-packages/ipalib/parameters.py:126: [R1705(no-else-return), _is_null] Unnecessary "else" after "return")
lib/python2.7/site-packages/ipalib/parameters.py:219: [C1801(len-as-condition), DefaultFrom.__init__] Do not use `len(SEQUENCE)` as condition value)
lib/python2.7/site-packages/ipalib/parameters.py:759: [R1705(no-else-return), Param.normalize] Unnecessary "else" after "return")
lib/python2.7/site-packages/ipalib/parameters.py:841: [C1801(len-as-condition), Param.convert] Do not use `len(SEQUENCE)` as condition value)
lib/python2.7/site-packages/ipalib/parameters.py:1229: [E1130(invalid-unary-operand-type), Decimal._enforce_precision] bad operand type for unary -: precision)
lib/python2.7/site-packages/ipalib/parameters.py:1340: [R1705(no-else-return), Data._rule_pattern] Unnecessary "else" after "return")
lib/python2.7/site-packages/ipalib/parameters.py:1502: [W0235(useless-super-delegation), IA5Str.__init__] Useless super delegation in method '__init__')
lib/python2.7/site-packages/ipalib/parameters.py:1557: [R1705(no-else-return), Enum._rule_values] Unnecessary "else" after "return")
************* Module ipapython.log_manager
lib/python2.7/site-packages/ipapython/log_manager.py:1362: [R1704(redefined-argument-from-local), LogManager.remove_handler] Redefining argument with the local name 'logger')
************* Module ipapython.ipavalidate
lib/python2.7/site-packages/ipapython/ipavalidate.py:34: [R1705(no-else-return), Email] Unnecessary "else" after "return")
lib/python2.7/site-packages/ipapython/ipavalidate.py:61: [R1705(no-else-return), Plain] Unnecessary "else" after "return")
lib/python2.7/site-packages/ipapython/ipavalidate.py:79: [R1705(no-else-return), String] Unnecessary "else" after "return")
lib/python2.7/site-packages/ipapython/ipavalidate.py:100: [R1705(no-else-return), Path] Unnecessary "else" after "return")
lib/python2.7/site-packages/ipapython/ipavalidate.py:128: [R1705(no-else-return), GoodName] Unnecessary "else" after "return")
************* Module ipapython.dn
lib/python2.7/site-packages/ipapython/dn.py:529: [R1705(no-else-return), cmp_rdns] Unnecessary "else" after "return")
lib/python2.7/site-packages/ipapython/dn.py:877: [C1801(len-as-condition), RDN._get_attr] Do not use `len(SEQUENCE)` as condition value)
lib/python2.7/site-packages/ipapython/dn.py:882: [C1801(len-as-condition), RDN._set_attr] Do not use `len(SEQUENCE)` as condition value)
lib/python2.7/site-packages/ipapython/dn.py:890: [C1801(len-as-condition), RDN._get_value] Do not use `len(SEQUENCE)` as condition value)
lib/python2.7/site-packages/ipapython/dn.py:895: [C1801(len-as-condition), RDN._set_value] Do not use `len(SEQUENCE)` as condition value)
************* Module ipapython.ssh
lib/python2.7/site-packages/ipapython/ssh.py:157: [R1705(no-else-return), SSHPublicKey._parse_openssh] Unnecessary "else" after "return")
************* Module ipalib.rpc
lib/python2.7/site-packages/ipalib/rpc.py:178: [R1705(no-else-return), xml_wrap] Unnecessary "else" after "return")
lib/python2.7/site-packages/ipalib/rpc.py:184: [R1705(no-else-return), xml_wrap] Unnecessary "else" after "return")
lib/python2.7/site-packages/ipalib/rpc.py:217: [R1705(no-else-return), xml_unwrap] Unnecessary "else" after "return")
lib/python2.7/site-packages/ipalib/rpc.py:348: [R1705(no-else-return), _JSONPrimer._enc_datetime] Unnecessary "else" after "return")
lib/python2.7/site-packages/ipalib/rpc.py:359: [R1705(no-else-return), _JSONPrimer._enc_dnsname] Unnecessary "else" after "return")
lib/python2.7/site-packages/ipalib/rpc.py:397: [R1705(no-else-return), json_encode_binary] Unnecessary "else" after "return")
lib/python2.7/site-packages/ipalib/rpc.py:408: [R1705(no-else-return), _ipa_obj_hook] Unnecessary "else" after "return")
lib/python2.7/site-packages/ipalib/rpc.py:492: [R1705(no-else-return), MultiProtocolTransport.getparser] Unnecessary "else" after "return")
************* Module ipalib.frontend
lib/python2.7/site-packages/ipalib/frontend.py:529: [C1801(len-as-condition), Command.args_options_2_params] Do not use `len(SEQUENCE)` as condition value)
lib/python2.7/site-packages/ipalib/frontend.py:532: [C1801(len-as-condition), Command.args_options_2_params] Do not use `len(SEQUENCE)` as condition value)
lib/python2.7/site-packages/ipalib/frontend.py:841: [C1801(len-as-condition), Command._on_finalize] Do not use `len(SEQUENCE)` as condition value)
lib/python2.7/site-packages/ipalib/frontend.py:1338: [R1705(no-else-return), Attribute.obj_full_name] Unnecessary "else" after "return")
lib/python2.7/site-packages/ipalib/frontend.py:1351: [R1705(no-else-return), Attribute.obj] Unnecessary "else" after "return")
************* Module ipalib.cli
lib/python2.7/site-packages/ipalib/cli.py:122: [C1801(len-as-condition), textui.max_col_width] Do not use `len(SEQUENCE)` as condition value)
lib/python2.7/site-packages/ipalib/cli.py:171: [R1705(no-else-return), textui.encode_binary] Unnecessary "else" after "return")
lib/python2.7/site-packages/ipalib/cli.py:304: [C1801(len-as-condition), textui.print_attribute] Do not use `len(SEQUENCE)` as condition value)
lib/python2.7/site-packages/ipalib/cli.py:311: [C1801(len-as-condition), textui.print_attribute] Do not use `len(SEQUENCE)` as condition value)
lib/python2.7/site-packages/ipalib/cli.py:324: [C1801(len-as-condition), textui.print_attribute] Do not use `len(SEQUENCE)` as condition value)
lib/python2.7/site-packages/ipalib/cli.py:847: [C1801(len-as-condition), help.print_commands] Do not use `len(SEQUENCE)` as condition value)
lib/python2.7/site-packages/ipalib/cli.py:975: [C1801(len-as-condition), show_api.__traverse_namespace] Do not use `len(SEQUENCE)` as condition value)
lib/python2.7/site-packages/ipalib/cli.py:997: [E1137(unsupported-assignment-operation), Collector.__setattr__] 'self.__options' does not support item assignment)
lib/python2.7/site-packages/ipalib/cli.py:1069: [C1801(len-as-condition), cli.get_command] Do not use `len(SEQUENCE)` as condition value)
lib/python2.7/site-packages/ipalib/cli.py:1076: [C1801(len-as-condition), cli.get_command] Do not use `len(SEQUENCE)` as condition value)
lib/python2.7/site-packages/ipalib/cli.py:1117: [R1705(no-else-return), cli.run] Unnecessary "else" after "return")
lib/python2.7/site-packages/ipalib/cli.py:1213: [R1705(no-else-return), cli.__get_arg_name] Unnecessary "else" after "return")
lib/python2.7/site-packages/ipalib/cli.py:1327: [R1705(no-else-return), IPAHelpFormatter.format_description] Unnecessary "else" after "return")
************* Module ipapython.ipautil
lib/python2.7/site-packages/ipapython/ipautil.py:31: [W1648(bad-python3-import), ] Module moved in Python 3)
lib/python2.7/site-packages/ipapython/ipautil.py:238: [R1705(no-else-return), format_netloc] Unnecessary "else" after "return")
lib/python2.7/site-packages/ipapython/ipautil.py:286: [R1705(no-else-return), shell_quote] Unnecessary "else" after "return")
lib/python2.7/site-packages/ipapython/ipautil.py:295: [R1705(no-else-return), _log_arg] Unnecessary "else" after "return")
lib/python2.7/site-packages/ipapython/ipautil.py:628: [R1705(no-else-return), CIDict.keys] Unnecessary "else" after "return")
lib/python2.7/site-packages/ipapython/ipautil.py:634: [R1705(no-else-return), CIDict.items] Unnecessary "else" after "return")
lib/python2.7/site-packages/ipapython/ipautil.py:640: [R1705(no-else-return), CIDict.values] Unnecessary "else" after "return")
lib/python2.7/site-packages/ipapython/ipautil.py:716: [C1801(len-as-condition), GeneralizedTimeZone.__init__] Do not use `len(SEQUENCE)` as condition value)
lib/python2.7/site-packages/ipapython/ipautil.py:758: [C1801(len-as-condition), parse_generalized_time] Do not use `len(SEQUENCE)` as condition value)
lib/python2.7/site-packages/ipapython/ipautil.py:770: [C1801(len-as-condition), parse_generalized_time] Do not use `len(SEQUENCE)` as condition value)
lib/python2.7/site-packages/ipapython/ipautil.py:781: [C1801(len-as-condition), parse_generalized_time] Do not use `len(SEQUENCE)` as condition value)
lib/python2.7/site-packages/ipapython/ipautil.py:786: [C1801(len-as-condition), parse_generalized_time] Do not use `len(SEQUENCE)` as condition value)
************* Module ipapython.config
lib/python2.7/site-packages/ipapython/config.py:155: [C1801(len-as-condition), IPAConfig.get_server] Do not use `len(SEQUENCE)` as condition value)
lib/python2.7/site-packages/ipapython/config.py:250: [C1801(len-as-condition), init_config] Do not use `len(SEQUENCE)` as condition value)
************* Module ipapython.ipaldap
lib/python2.7/site-packages/ipapython/ipaldap.py:169: [W1641(eq-without-hash), LDAPEntry] Implementing __eq__ without also implementing __hash__)
lib/python2.7/site-packages/ipapython/ipaldap.py:849: [R1705(no-else-return), LDAPClient.encode] Unnecessary "else" after "return")
lib/python2.7/site-packages/ipapython/ipaldap.py:882: [R1705(no-else-return), LDAPClient.decode] Unnecessary "else" after "return")

https://github.com/freeipa/freeipa/pull/720 is a band-aid for 4.5 and 4.6 until all issues have been addressed.

Metadata Update from @mbasti:
- Issue assigned to mbasti

Metadata Update from @mbasti:
- Issue set to the milestone: FreeIPA 4.6

master:

  • b64ec757883284a765745ef4fbd78fb55bf0e228 tox: use pylint 1.6.x for now

master:

  • 5f640de76e57272d7b7707e710bbee19a8eda79a Pylint: fix ipa_forbidden_import checker
  • 7eb02a49ed86c0640266af47d11c9efa91bc54cb pylint: ignore new checks added in 1.7

Metadata Update from @mbasti:
- Issue assigned to stlaz (was: mbasti)

I am currently working on fixing this, please note that there are also false positives on python3 move of stat module which did not really happen:
https://bugzilla.redhat.com/show_bug.cgi?id=1483869

master:

  • e6a9de8a2ea453843e71ff717bee7dd74383db64 py3: remove Exception.message appearances
  • 2bc5b7f044435921b9fa1d5728731a843919102e py3: remove relative import

Metadata Update from @tkrizek:
- Issue set to the milestone: FreeIPA 4.6.1 (was: FreeIPA 4.6)

master:

  • a765746e95579a3f37c9caab5c2506f86b6acc02 pylint: fix not-context-manager false positives
  • 806784dbd9e69a89c7a705c89bf42ba1fd4265c9 csrgen: fix incorrect codec for pyasn BitString
  • b57f87c9a020acad1ff9393c8f09a4c33713ccf1 pylint: fix no-member in schema plugin
  • 216d37b7f0c26b82ae90bde6beb187acdf754e22 dcerpc: refactor assess_dcerpc_exception
  • 3c616d733b6be9958c301027f5bf308c4c6ec366 dcerpc: disable unbalanced-tuple-unpacking
  • f7fc3a3fc1bf25158206cd26d90aa392037fe17a parameters: convert Decimal.precision to int
  • 353d4934afa0e4a83d2458cebeaf362c7ce567e9 pylint: Iterate through dictionaries
  • 33f13b6df92374342d0066bdb9bfc23f1647a623 sudocmd: fix unsupported assignment
  • f2701f3a0b535737f46bdb53732d7e4ea73ad167 pylint: make unsupported-assignment-operation check local
  • ae0bd124f5f13aea7b2f648e6ae7132b11910b2a install.util: disable no-value-for-parameter
  • fab589d7f5bb378d97b470cef0550355d34ab7dc pylint: disable hash for some classes
  • 82d0279381d7f6c3e9a30554c8dfa4a9e5e0196c secrets: disable relative-imports for custodia
  • 0ae2473be0835655a1433bff47228ddabe602177 rpcserver: don't call xmlserver.Command
  • c7f90159a3d5e000805603cd05d7395471af009f Change the requirements for pylint in wheel
  • 76c6ffe1250aa5dcacbef544724f765aae8f59ca Change Travis CI container to FreeIPA-owned
  • a30095b3a6e4917e4a70a7f9f89478236244d28d travis: remove "fast" from "makecache fast"

Metadata Update from @stlaz:
- Issue close_status updated to: fixed
- Issue status updated to: Closed (was: Open)

Metadata Update from @stlaz:
- Issue status updated to: Open (was: Closed)

ipa-4-6:

  • 0565600635777b71a96e63ed421820e0a0891ae5 Travis: archive logs of py3 jobs
  • ce148ed700b354b4324e65fe5a6097b80bdfc442 pylint: fix not-context-manager false positives
  • 47352fb19df83675863167601d57a6d28c278eb2 csrgen: fix incorrect codec for pyasn BitString
  • 7c64aca2d08fdc40901f4b5bf04a9d093944086a pylint: fix no-member in schema plugin
  • 0b8207df865b28288519a1b6bcfea52f3c693096 dcerpc: refactor assess_dcerpc_exception
  • f80af622810afc05675eaf7d0b91217ca41a05ab dcerpc: disable unbalanced-tuple-unpacking
  • 25d8229bf9843b857b1918026dc45da92771fa7c parameters: convert Decimal.precision to int
  • 06f3aad5cf26b36e40abd0dd5fc547690c5c5b3d pylint: Iterate through dictionaries
  • 568926fd74f395be5c3b6a2d3bc811732c470fcc sudocmd: fix unsupported assignment
  • 9cf1f1d4cbe38730dff7f35476fd1a5ad09ca605 pylint: make unsupported-assignment-operation check local
  • e67cdb01c40f9eaec4518b327bd72fdd3100253c install.util: disable no-value-for-parameter
  • 2952af4dc450363ae6c6a466812ae4ef32d087f4 pylint: disable hash for some classes
  • 388bc9459216183deda2336220ca1f5d6f9d0698 secrets: disable relative-imports for custodia
  • dfeadfed2c6fe1540933c46b540c657344a6a264 rpcserver: don't call xmlserver.Command
  • 0449a4c8113719004297db3466fd189f22544875 Change the requirements for pylint in wheel
  • 79d9bdcec388b5b21b46fcb5a35d93d5b246ace2 Change Travis CI container to FreeIPA-owned
  • 4f4b0ef61b9c9beb5d07db3e89a40d391fbaeaa3 travis: remove "fast" from "makecache fast"

Metadata Update from @stlaz:
- Issue close_status updated to: fixed
- Issue status updated to: Closed (was: Open)

Metadata