Skip to content

Commit 3fed4cb

Browse files
committed
0.5.4: use six in requirements, req typing in python <3.7
1 parent ab4239d commit 3fed4cb

File tree

4 files changed

+6
-60
lines changed

4 files changed

+6
-60
lines changed

advanced_descriptors/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
'AdvancedProperty',
2222
)
2323

24-
__version__ = '0.5.3'
24+
__version__ = '0.5.4'
2525
__author__ = "Alexey Stepanov"
2626
__author_email__ = 'penguinolog@gmail.com'
2727
__url__ = 'https://github.com/penguinolog/advanced-descriptors'

advanced_descriptors/separate_class_method.py

Lines changed: 3 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
"""Separate class and instance methods with the same name."""
1717

18-
import functools
18+
import six
1919

2020
try: # pragma: no cover
2121
import typing
@@ -28,61 +28,6 @@
2828
'SeparateClassMethod',
2929
)
3030

31-
_WRAPPER_ASSIGNMENTS = (
32-
'__module__',
33-
'__name__',
34-
'__qualname__',
35-
'__doc__',
36-
'__annotations__'
37-
)
38-
_WRAPPER_UPDATES = ('__dict__',)
39-
40-
41-
def _update_wrapper(wrapper,
42-
wrapped,
43-
assigned=_WRAPPER_ASSIGNMENTS,
44-
updated=_WRAPPER_UPDATES):
45-
"""Update a wrapper function to look like the wrapped function.
46-
47-
wrapper is the function to be updated
48-
wrapped is the original function
49-
assigned is a tuple naming the attributes assigned directly
50-
from the wrapped function to the wrapper function (defaults to
51-
functools.WRAPPER_ASSIGNMENTS)
52-
updated is a tuple naming the attributes of the wrapper that
53-
are updated with the corresponding attribute from the wrapped
54-
function (defaults to functools.WRAPPER_UPDATES)
55-
"""
56-
for attr in assigned:
57-
try:
58-
value = getattr(wrapped, attr)
59-
except AttributeError:
60-
pass
61-
else:
62-
setattr(wrapper, attr, value)
63-
for attr in updated:
64-
getattr(wrapper, attr).update(getattr(wrapped, attr, {}))
65-
# Issue #17482: set __wrapped__ last so we don't inadvertently copy it
66-
# from the wrapped function when updating __dict__
67-
wrapper.__wrapped__ = wrapped
68-
# Return the wrapper so this can be used as a decorator via partial()
69-
return wrapper
70-
71-
72-
def _wraps(wrapped,
73-
assigned=_WRAPPER_ASSIGNMENTS,
74-
updated=_WRAPPER_UPDATES):
75-
"""Decorator factory to apply update_wrapper() to a wrapper function.
76-
77-
Returns a decorator that invokes update_wrapper() with the decorated
78-
function as the wrapper argument and the arguments to wraps() as the
79-
remaining arguments. Default arguments are as for update_wrapper().
80-
This is a convenience function to simplify applying partial() to
81-
update_wrapper().
82-
"""
83-
return functools.partial(
84-
_update_wrapper, wrapped=wrapped, assigned=assigned, updated=updated)
85-
8631

8732
class SeparateClassMethod(object):
8833
"""Separate class method and instance methods with the same name.
@@ -182,14 +127,14 @@ def __get__(self, instance, owner): # type: (...) -> TargetFunctionType
182127
if self.__class_method is None:
183128
raise AttributeError()
184129

185-
@_wraps(self.__class_method)
130+
@six.wraps(self.__class_method)
186131
def class_method(*args, **kwargs):
187132
"""Bound class method."""
188133
return self.__class_method(owner, *args, **kwargs)
189134

190135
return class_method
191136

192-
@_wraps(self.__class_method)
137+
@six.wraps(self.__instance_method)
193138
def instance_method(*args, **kwargs):
194139
"""Bound instance method."""
195140
return self.__instance_method(instance, *args, **kwargs)

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
six

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ def get_simple_vars_from_src(src):
238238
keywords=keywords,
239239
install_requires=required,
240240
extras_require={
241-
':python_version >= "2.7"': [
241+
':python_version < "3.7"': [
242242
'typing>=3.6',
243243
],
244244
},

0 commit comments

Comments
 (0)