Commit d656f635 authored by Arnaud Fontaine's avatar Arnaud Fontaine

pylint: Handle primitive types for no-name-in-module.

This fixes errors such as:
E: No name '_dtmldir' in module 'Products.ERP5Type' (no-name-in-module)

Where _dtmldir is 'PATH/TO/Products/ERP5Type/dtml/', dynamically added to
Products.ERP5Type module.
parent b29d164c
Pipeline #9944 passed with stage
in 0 seconds
......@@ -210,19 +210,37 @@ def _getattr(self, name, *args, **kw):
except AttributeError:
raise e
# XXX: What about int, str or bool not having __module__?
# REQUEST object (or any object non acquisition-wrapped)
if (isinstance(attr, str) and
attr == '<Special Object Used to Force Acquisition>'):
raise e
try:
origin_module_name = attr.__module__
except AttributeError:
raise e
if self.name == origin_module_name:
raise
from astroid import nodes
if isinstance(attr, dict):
ast = nodes.Dict(attr)
elif isinstance(attr, list):
ast = nodes.List(attr)
elif isinstance(attr, tuple):
ast = nodes.Tuple(attr)
elif isinstance(attr, set):
ast = nodes.Set(attr)
else:
try:
ast = nodes.Const(attr)
except Exception:
raise e
else:
if self.name == origin_module_name:
raise
# ast_from_class() actually works for any attribute of a Module
try:
ast = MANAGER.ast_from_class(attr)
except AstroidBuildingException:
raise e
# ast_from_class() actually works for any attribute of a Module
try:
ast = MANAGER.ast_from_class(attr)
except AstroidBuildingException:
raise e
self.locals[name] = [ast]
return [ast]
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment