Commit f750cbee authored by Kirill Smelkov's avatar Kirill Smelkov

pylint: Add support for XLTE

XLTE(*) follows the same top-level packaging structure like
wendelin.core does.

Registration is done via new `register_xpkg` function instead of just
loop so that pkgname argument is properly captured in created lambda and
does not change after going to next iteration.

(*) https://lab.nexedi.com/kirr/xlte

/reviewed-by @jerome
/reviewed-on !1762
parent 421d6068
...@@ -471,22 +471,25 @@ for filename in os.listdir(os.path.dirname(lxml.__file__)): ...@@ -471,22 +471,25 @@ for filename in os.listdir(os.path.dirname(lxml.__file__)):
module_name, module_name,
__import__(module_name, fromlist=[module_name], level=0)) __import__(module_name, fromlist=[module_name], level=0))
# Wendelin is special namespace package which pylint fails to recognize, and so # Wendelin and XLTE are special namespace packages which pylint fails to recognize, and so
# complains about things like `from wendelin.bigarray.array_zodb import ZBigArray` # complains about things like `from wendelin.bigarray.array_zodb import ZBigArray`
# with `No name 'bigarray' in module 'wendelin' (no-name-in-module)`. # with `No name 'bigarray' in module 'wendelin' (no-name-in-module)`.
# #
# -> Teach pylint to properly understand wendelin package nature. # -> Teach pylint to properly understand such packages nature.
try: def register_xpkg(pkgname):
import wendelin try:
except ImportError: pkg = __import__(pkgname)
except ImportError:
pass pass
else: else:
def wendelin_transform(node): def xpkg_transform(node):
m = AstroidBuilder(MANAGER).string_build('__path__ = %r' % wendelin.__path__) m = AstroidBuilder(MANAGER).string_build('__path__ = %r' % pkg.__path__)
m.package = True m.package = True
m.name = 'wendelin' m.name = pkgname
return m return m
MANAGER.register_transform(Module, wendelin_transform, lambda node: node.name == 'wendelin') MANAGER.register_transform(Module, xpkg_transform, lambda node: node.name == pkgname)
register_xpkg('wendelin')
register_xpkg('xlte')
# prevent a crash with cryptography: # prevent a crash with cryptography:
# File "develop-eggs/astroid-1.3.8+slapospatched001-py2.7.egg/astroid/raw_building.py", line 360, in _set_proxied # File "develop-eggs/astroid-1.3.8+slapospatched001-py2.7.egg/astroid/raw_building.py", line 360, in _set_proxied
......
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