style: switching from yapf to isort/black

This commit is contained in:
Romain Dorgueil
2018-08-11 06:34:37 +02:00
parent ebba06822b
commit d1c9beae97
93 changed files with 805 additions and 816 deletions

View File

@ -147,14 +147,14 @@ class TestBagType(unittest.TestCase):
self.assertEqual(Zero()._asdict(), {})
self.assertEqual(Zero()._fields, ())
Dot = BagType('Dot', ('d', ))
self.assertEqual(Dot(1), (1, ))
self.assertEqual(Dot._make([1]), (1, ))
Dot = BagType('Dot', ('d',))
self.assertEqual(Dot(1), (1,))
self.assertEqual(Dot._make([1]), (1,))
self.assertEqual(Dot(1).d, 1)
self.assertEqual(repr(Dot(1)), 'Dot(d=1)')
self.assertEqual(Dot(1)._asdict(), {'d': 1})
self.assertEqual(Dot(1)._replace(d=999), (999, ))
self.assertEqual(Dot(1)._fields, ('d', ))
self.assertEqual(Dot(1)._replace(d=999), (999,))
self.assertEqual(Dot(1)._fields, ('d',))
n = 5000 if sys.version_info >= (3, 7) else 254
names = list(set(''.join([choice(string.ascii_letters) for j in range(10)]) for i in range(n)))
@ -178,7 +178,7 @@ class TestBagType(unittest.TestCase):
def test_pickle(self):
p = TBag(x=10, y=20, z=30)
for module in (pickle, ):
for module in (pickle,):
loads = getattr(module, 'loads')
dumps = getattr(module, 'dumps')
for protocol in range(-1, module.HIGHEST_PROTOCOL + 1):
@ -206,25 +206,191 @@ class TestBagType(unittest.TestCase):
# Broader test of all interesting names taken from the code, old
# template, and an example
words = {
'Alias', 'At', 'AttributeError', 'Build', 'Bypass', 'Create', 'Encountered', 'Expected', 'Field', 'For',
'Got', 'Helper', 'IronPython', 'Jython', 'KeyError', 'Make', 'Modify', 'Note', 'OrderedDict', 'Point',
'Return', 'Returns', 'Type', 'TypeError', 'Used', 'Validate', 'ValueError', 'Variables', 'a', 'accessible',
'add', 'added', 'all', 'also', 'an', 'arg_list', 'args', 'arguments', 'automatically', 'be', 'build',
'builtins', 'but', 'by', 'cannot', 'class_namespace', 'classmethod', 'cls', 'collections', 'convert',
'copy', 'created', 'creation', 'd', 'debugging', 'defined', 'dict', 'dictionary', 'doc', 'docstring',
'docstrings', 'duplicate', 'effect', 'either', 'enumerate', 'environments', 'error', 'example', 'exec', 'f',
'f_globals', 'field', 'field_names', 'fields', 'formatted', 'frame', 'function', 'functions', 'generate',
'getter', 'got', 'greater', 'has', 'help', 'identifiers', 'indexable', 'instance', 'instantiate',
'interning', 'introspection', 'isidentifier', 'isinstance', 'itemgetter', 'iterable', 'join', 'keyword',
'keywords', 'kwds', 'len', 'like', 'list', 'map', 'maps', 'message', 'metadata', 'method', 'methods',
'module', 'module_name', 'must', 'name', 'named', 'namedtuple', 'namedtuple_', 'names', 'namespace',
'needs', 'new', 'nicely', 'num_fields', 'number', 'object', 'of', 'operator', 'option', 'p', 'particular',
'pickle', 'pickling', 'plain', 'pop', 'positional', 'property', 'r', 'regular', 'rename', 'replace',
'replacing', 'repr', 'repr_fmt', 'representation', 'result', 'reuse_itemgetter', 's', 'seen', 'sequence',
'set', 'side', 'specified', 'split', 'start', 'startswith', 'step', 'str', 'string', 'strings', 'subclass',
'sys', 'targets', 'than', 'the', 'their', 'this', 'to', 'tuple_new', 'type', 'typename', 'underscore',
'unexpected', 'unpack', 'up', 'use', 'used', 'user', 'valid', 'values', 'variable', 'verbose', 'where',
'which', 'work', 'x', 'y', 'z', 'zip'
'Alias',
'At',
'AttributeError',
'Build',
'Bypass',
'Create',
'Encountered',
'Expected',
'Field',
'For',
'Got',
'Helper',
'IronPython',
'Jython',
'KeyError',
'Make',
'Modify',
'Note',
'OrderedDict',
'Point',
'Return',
'Returns',
'Type',
'TypeError',
'Used',
'Validate',
'ValueError',
'Variables',
'a',
'accessible',
'add',
'added',
'all',
'also',
'an',
'arg_list',
'args',
'arguments',
'automatically',
'be',
'build',
'builtins',
'but',
'by',
'cannot',
'class_namespace',
'classmethod',
'cls',
'collections',
'convert',
'copy',
'created',
'creation',
'd',
'debugging',
'defined',
'dict',
'dictionary',
'doc',
'docstring',
'docstrings',
'duplicate',
'effect',
'either',
'enumerate',
'environments',
'error',
'example',
'exec',
'f',
'f_globals',
'field',
'field_names',
'fields',
'formatted',
'frame',
'function',
'functions',
'generate',
'getter',
'got',
'greater',
'has',
'help',
'identifiers',
'indexable',
'instance',
'instantiate',
'interning',
'introspection',
'isidentifier',
'isinstance',
'itemgetter',
'iterable',
'join',
'keyword',
'keywords',
'kwds',
'len',
'like',
'list',
'map',
'maps',
'message',
'metadata',
'method',
'methods',
'module',
'module_name',
'must',
'name',
'named',
'namedtuple',
'namedtuple_',
'names',
'namespace',
'needs',
'new',
'nicely',
'num_fields',
'number',
'object',
'of',
'operator',
'option',
'p',
'particular',
'pickle',
'pickling',
'plain',
'pop',
'positional',
'property',
'r',
'regular',
'rename',
'replace',
'replacing',
'repr',
'repr_fmt',
'representation',
'result',
'reuse_itemgetter',
's',
'seen',
'sequence',
'set',
'side',
'specified',
'split',
'start',
'startswith',
'step',
'str',
'string',
'strings',
'subclass',
'sys',
'targets',
'than',
'the',
'their',
'this',
'to',
'tuple_new',
'type',
'typename',
'underscore',
'unexpected',
'unpack',
'up',
'use',
'used',
'user',
'valid',
'values',
'variable',
'verbose',
'where',
'which',
'work',
'x',
'y',
'z',
'zip',
}
sorted_words = tuple(sorted(words))
T = BagType('T', sorted_words)
@ -252,7 +418,7 @@ class TestBagType(unittest.TestCase):
self.assertEqual(t.__getnewargs__(), values)
def test_repr(self):
A = BagType('A', ('x', ))
A = BagType('A', ('x',))
self.assertEqual(repr(A(1)), 'A(x=1)')
# repr should show the name of the subclass
@ -273,6 +439,18 @@ class TestBagType(unittest.TestCase):
def test_annoying_attribute_names(self):
self._create(
'__slots__', '__getattr__', '_attrs', '_fields', '__new__', '__getnewargs__', '__repr__', '_make', 'get',
'_replace', '_asdict', '_cls', 'self', 'tuple'
'__slots__',
'__getattr__',
'_attrs',
'_fields',
'__new__',
'__getnewargs__',
'__repr__',
'_make',
'get',
'_replace',
'_asdict',
'_cls',
'self',
'tuple',
)