77import re
88import textwrap
99
10- import astroid .builder
10+ from astroid .bases import BoundMethod
1111from astroid .brain .helpers import register_module_extender
12+ from astroid .builder import AstroidBuilder
1213from astroid .exceptions import InferenceError
1314from astroid .manager import AstroidManager
14-
15- _BUILDER = astroid .builder .AstroidBuilder (AstroidManager ())
16-
15+ from astroid .nodes import List , Module
1716
1817CAPITALS = re .compile ("([A-Z])" )
1918
@@ -24,7 +23,7 @@ def _pep8(name, caps=CAPITALS):
2423
2524def _nose_tools_functions ():
2625 """Get an iterator of names and bound methods."""
27- module = _BUILDER .string_build (
26+ module = AstroidBuilder () .string_build (
2827 textwrap .dedent (
2928 """
3029 import unittest
@@ -42,10 +41,10 @@ class Test(unittest.TestCase):
4241 for method in case .methods ():
4342 if method .name .startswith ("assert" ) and "_" not in method .name :
4443 pep8_name = _pep8 (method .name )
45- yield pep8_name , astroid . BoundMethod (method , case )
44+ yield pep8_name , BoundMethod (method , case )
4645 if method .name == "assertEqual" :
4746 # nose also exports assert_equals.
48- yield "assert_equals" , astroid . BoundMethod (method , case )
47+ yield "assert_equals" , BoundMethod (method , case )
4948
5049
5150def _nose_tools_transform (node ):
@@ -55,7 +54,7 @@ def _nose_tools_transform(node):
5554
5655def _nose_tools_trivial_transform ():
5756 """Custom transform for the nose.tools module."""
58- stub = _BUILDER .string_build ("""__all__ = []""" )
57+ stub = AstroidBuilder () .string_build ("""__all__ = []""" )
5958 all_entries = ["ok_" , "eq_" ]
6059
6160 for pep8_name , method in _nose_tools_functions ():
@@ -65,7 +64,7 @@ def _nose_tools_trivial_transform():
6564 # Update the __all__ variable, since nose.tools
6665 # does this manually with .append.
6766 all_assign = stub ["__all__" ].parent
68- all_object = astroid . List (all_entries )
67+ all_object = List (all_entries )
6968 all_object .parent = all_assign
7069 all_assign .value = all_object
7170 return stub
@@ -75,5 +74,5 @@ def _nose_tools_trivial_transform():
7574 AstroidManager (), "nose.tools.trivial" , _nose_tools_trivial_transform
7675)
7776AstroidManager ().register_transform (
78- astroid . Module , _nose_tools_transform , lambda n : n .name == "nose.tools"
77+ Module , _nose_tools_transform , lambda n : n .name == "nose.tools"
7978)
0 commit comments