Skip to content
This repository was archived by the owner on Nov 3, 2023. It is now read-only.

Commit 697bb52

Browse files
committed
Merge remote-tracking branch 'refs/remotes/upstream/master' into win-tests
2 parents da53c4d + 00007ee commit 697bb52

File tree

3 files changed

+39
-14
lines changed

3 files changed

+39
-14
lines changed

pep257.py

Lines changed: 35 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -54,22 +54,41 @@ def next(obj, default=nothing):
5454

5555
PROJECT_CONFIG = ('setup.cfg', 'tox.ini', '.pep257')
5656

57-
humanize = lambda string: re(r'(.)([A-Z]+)').sub(r'\1 \2', string).lower()
58-
is_magic = lambda name: name.startswith('__') and name.endswith('__')
59-
is_ascii = lambda string: all(ord(char) < 128 for char in string)
60-
is_blank = lambda string: not string.strip()
61-
leading_space = lambda string: re('\s*').match(string).group()
57+
58+
def humanize(string):
59+
return re(r'(.)([A-Z]+)').sub(r'\1 \2', string).lower()
60+
61+
62+
def is_magic(name):
63+
return name.startswith('__') and name.endswith('__')
64+
65+
66+
def is_ascii(string):
67+
return all(ord(char) < 128 for char in string)
68+
69+
70+
def is_blank(string):
71+
return not string.strip()
72+
73+
74+
def leading_space(string):
75+
return re('\s*').match(string).group()
6276

6377

6478
class Value(object):
6579

66-
__init__ = lambda self, *args: vars(self).update(zip(self._fields, args))
67-
__hash__ = lambda self: hash(repr(self))
68-
__eq__ = lambda self, other: other and vars(self) == vars(other)
80+
def __init__(self, *args):
81+
vars(self).update(zip(self._fields, args))
82+
83+
def __hash__(self):
84+
return hash(repr(self))
85+
86+
def __eq__(self, other):
87+
return other and vars(self) == vars(other)
6988

7089
def __repr__(self):
71-
format_arg = lambda arg: '{}={!r}'.format(arg, getattr(self, arg))
72-
kwargs = ', '.join(format_arg(arg) for arg in self._fields)
90+
kwargs = ', '.join('{}={!r}'.format(field, getattr(self, field))
91+
for field in self._fields)
7392
return '{}({})'.format(self.__class__.__name__, kwargs)
7493

7594

@@ -83,7 +102,9 @@ class Definition(Value):
83102
all = property(lambda self: self.module.all)
84103
_slice = property(lambda self: slice(self.start - 1, self.end))
85104
source = property(lambda self: ''.join(self._source[self._slice]))
86-
__iter__ = lambda self: chain([self], *self.children)
105+
106+
def __iter__(self):
107+
return chain([self], *self.children)
87108

88109
@property
89110
def _publicity(self):
@@ -100,7 +121,9 @@ class Module(Definition):
100121
_nest = staticmethod(lambda s: {'def': Function, 'class': Class}[s])
101122
module = property(lambda self: self)
102123
all = property(lambda self: self._all)
103-
__str__ = lambda self: 'at module level'
124+
125+
def __str__(self):
126+
return 'at module level'
104127

105128

106129
class Function(Definition):

test.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@
88

99
def expect(*args):
1010
"""Decorator that expects a certain PEP 257 violation."""
11-
none = lambda a: None
11+
def none(a):
12+
return None
13+
1214
if len(args) == 1:
1315
return lambda f: expected.add((f.__name__, args[0])) or none(f()) or f
1416
expected.add(args)

tox.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ deps = pytest
1414

1515
[pytest]
1616
pep8ignore =
17-
test.py E701
17+
test.py E701 E704
1818
norecursedirs = docs .tox
1919

2020

0 commit comments

Comments
 (0)