Skip to content

Commit 130cdd3

Browse files
committed
typing: readability & external analisys
1 parent 3fed4cb commit 130cdd3

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

advanced_descriptors/separate_class_method.py

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,10 @@
1818
import six
1919

2020
try: # pragma: no cover
21-
import typing
22-
TargetFunctionType = typing.Optional[typing.Callable[..., typing.Any]]
21+
import typing # pylint: disable=unused-import
2322
except ImportError: # pragma: no cover
23+
# noinspection PyRedeclaration
2424
typing = None
25-
TargetFunctionType = None
2625

2726
__all__ = (
2827
'SeparateClassMethod',
@@ -104,8 +103,8 @@ class SeparateClassMethod(object):
104103

105104
def __init__(
106105
self,
107-
imeth=None, # type: TargetFunctionType
108-
cmeth=None, # type: TargetFunctionType
106+
imeth=None, # type: typing.Optional[typing.Callable]
107+
cmeth=None, # type: typing.Optional[typing.Callable]
109108
):
110109
"""Separate class method and instance methods.
111110
@@ -117,7 +116,11 @@ def __init__(
117116
self.__instance_method = imeth
118117
self.__class_method = cmeth
119118

120-
def __get__(self, instance, owner): # type: (...) -> TargetFunctionType
119+
def __get__(
120+
self,
121+
instance, # type: owner
122+
owner # type: type
123+
): # type: (...) -> typing.Callable
121124
"""Get descriptor.
122125
123126
:rtype: typing.Callable[..., typing.Any]
@@ -143,7 +146,7 @@ def instance_method(*args, **kwargs):
143146

144147
def instance_method(
145148
self,
146-
imeth # type: TargetFunctionType
149+
imeth # type: typing.Optional[typing.Callable]
147150
): # type: (...) -> SeparateClassMethod
148151
"""Descriptor to change instance method.
149152
@@ -156,7 +159,7 @@ def instance_method(
156159

157160
def class_method(
158161
self,
159-
cmeth # type: TargetFunctionType
162+
cmeth # type: typing.Optional[typing.Callable]
160163
): # type: (...) -> SeparateClassMethod
161164
"""Descriptor to change class method.
162165
@@ -168,15 +171,15 @@ def class_method(
168171
return self
169172

170173
@property
171-
def imeth(self): # type: (SeparateClassMethod) -> TargetFunctionType
174+
def imeth(self): # type: () -> typing.Optional[typing.Callable]
172175
"""Instance method instance.
173176
174177
:rtype: typing.Optional[typing.Callable[..., typing.Any]]
175178
"""
176179
return self.__instance_method
177180

178181
@property
179-
def cmeth(self): # type: (SeparateClassMethod) -> TargetFunctionType
182+
def cmeth(self): # type: () -> typing.Optional[typing.Callable]
180183
"""Class method instance.
181184
182185
:rtype: typing.Optional[typing.Callable[..., typing.Any]]

0 commit comments

Comments
 (0)