Commit 27ab8bd5 authored by Arnaud Fontaine's avatar Arnaud Fontaine

pylint: Fix false positive error `No name 'ElementMaker' in module...

pylint: Fix false positive error `No name 'ElementMaker' in module 'lxml.builder' (no-name-in-module)`.
parent c8e12a94
Pipeline #10153 passed with stage
...@@ -288,15 +288,22 @@ _what_not_even_god_should_do = [] ...@@ -288,15 +288,22 @@ _what_not_even_god_should_do = []
register_module_extender(MANAGER, 'AccessControl.PermissionRole', register_module_extender(MANAGER, 'AccessControl.PermissionRole',
AccessControl_PermissionRole_transform) AccessControl_PermissionRole_transform)
## No name 'OOBTree' in module 'BTrees.OOBTree' (no-name-in-module) ## Package dynamically extending the namespace of their modules with C
## ## extension symbols
## When the corresponding C Extension (BTrees._Foo) is available, update
## BTrees.Foo namespace from the C extension, otherwise use Python definitions
## by dropping the `Py` suffix in BTrees.Foo symbols.
import BTrees
import inspect
# astroid/brain/ added dynamically to sys.path by astroid __init__ # astroid/brain/ added dynamically to sys.path by astroid __init__
from py2gi import _gi_build_stub as build_stub from py2gi import _gi_build_stub as build_stub
def _register_module_extender_from_live_module(module_name, module):
def transform():
return AstroidBuilder(MANAGER).string_build(build_stub(module))
register_module_extender(MANAGER, module_name, transform)
# No name 'OOBTree' in module 'BTrees.OOBTree' (no-name-in-module)
#
# When the corresponding C Extension (BTrees._Foo) is available, update
# BTrees.Foo namespace from the C extension, otherwise use Python definitions
# by dropping the `Py` suffix in BTrees.Foo symbols.
import BTrees
import inspect
for module_name, module in inspect.getmembers(BTrees, inspect.ismodule): for module_name, module in inspect.getmembers(BTrees, inspect.ismodule):
if module_name[0] != '_': if module_name[0] != '_':
continue continue
...@@ -305,12 +312,20 @@ for module_name, module in inspect.getmembers(BTrees, inspect.ismodule): ...@@ -305,12 +312,20 @@ for module_name, module in inspect.getmembers(BTrees, inspect.ismodule):
except KeyError: except KeyError:
continue continue
else: else:
def _create_transform_function(module): _register_module_extender_from_live_module(extended_module.__name__,
def transform(): module)
return AstroidBuilder(MANAGER).string_build(build_stub(module))
return transform # No name 'ElementMaker' in module 'lxml.builder' (no-name-in-module)
register_module_extender(MANAGER, extended_module.__name__, #
_create_transform_function(module)) # imp.load_dynamic() on .so file
import lxml
import os
for filename in os.listdir(os.path.dirname(lxml.__file__)):
if filename.endswith('.so'):
module_name = 'lxml.' + filename[:-3]
_register_module_extender_from_live_module(
module_name,
__import__(module_name, fromlist=[module_name], level=0))
# Properly search for namespace packages: original astroid (as of 1.3.8) only # Properly search for namespace packages: original astroid (as of 1.3.8) only
# checks at top-level and it doesn't work for Shared.DC.ZRDB (defined in # checks at top-level and it doesn't work for Shared.DC.ZRDB (defined in
......
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