Skip to content

Commit 743bb96

Browse files
authored
typehints: fix *args, **kwargs. Do not lookup for pyi stubs. (#18)
Fix misprint.
1 parent 6490a9c commit 743bb96

File tree

6 files changed

+28
-33
lines changed

6 files changed

+28
-33
lines changed

advanced_descriptors/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
# License for the specific language governing permissions and limitations
1212
# under the License.
1313

14-
"""Advanded descriptors for special cases."""
14+
"""Advanced descriptors for special cases."""
1515

1616
from .separate_class_method import SeparateClassMethod
1717
from .advanced_property import AdvancedProperty
@@ -30,5 +30,5 @@
3030
'Dennis Dmitriev': 'dis-xcom@gmail.com',
3131
}
3232
__url__ = 'https://github.com/python-useful-helpers/advanced-descriptors'
33-
__description__ = "Advanded descriptors for special cases."
33+
__description__ = "Advanced descriptors for special cases."
3434
__license__ = "Apache License, Version 2.0"

advanced_descriptors/separate_class_method.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -99,15 +99,15 @@ class SeparateClassMethod(object):
9999

100100
def __init__(
101101
self,
102-
imeth=None, # type: typing.Optional[typing.Callable[..., typing.Any]]
103-
cmeth=None, # type: typing.Optional[typing.Callable[..., typing.Any]]
102+
imeth=None, # type: typing.Optional[typing.Callable]
103+
cmeth=None, # type: typing.Optional[typing.Callable]
104104
): # type: (...) -> None
105105
"""Separate class method and instance methods.
106106
107107
:param imeth: Instance method
108-
:type imeth: typing.Optional[typing.Callable[..., typing.Any]]
108+
:type imeth: typing.Optional[typing.Callable]
109109
:param cmeth: Class method
110-
:type cmeth: typing.Optional[typing.Callable[..., typing.Any]]
110+
:type cmeth: typing.Optional[typing.Callable]
111111
"""
112112
self.__instance_method = imeth
113113
self.__class_method = cmeth
@@ -116,10 +116,10 @@ def __get__(
116116
self,
117117
instance, # type: typing.Optional[typing.Any]
118118
owner # type: typing.Any
119-
): # type: (...) -> typing.Callable[..., typing.Any]
119+
): # type: (...) -> typing.Callable
120120
"""Get descriptor.
121121
122-
:rtype: typing.Callable[..., typing.Any]
122+
:rtype: typing.Callable
123123
:raises: AttributeError
124124
"""
125125
if instance is None or self.__instance_method is None:
@@ -134,51 +134,51 @@ def class_method(*args, **kwargs): # type: (typing.Tuple, typing.Dict) -> typin
134134
return class_method
135135

136136
@six.wraps(self.__instance_method)
137-
def instance_method(*args, **kwargs): # type: (typing.Tuple, typing.Dict) -> typing.Any
137+
def instance_method(*args, **kwargs): # type: (typing.Any, typing.Any) -> typing.Any
138138
"""Bound instance method."""
139139
return self.__instance_method(instance, *args, **kwargs) # type: ignore
140140

141141
return instance_method
142142

143143
def instance_method(
144144
self,
145-
imeth # type: typing.Optional[typing.Callable[..., typing.Any]]
145+
imeth # type: typing.Optional[typing.Callable]
146146
): # type: (...) -> SeparateClassMethod
147147
"""Descriptor to change instance method.
148148
149149
:param imeth: New instance method.
150-
:type imeth: typing.Optional[typing.Callable[..., typing.Any]]
150+
:type imeth: typing.Optional[typing.Callable]
151151
:rtype: SeparateClassMethod
152152
"""
153153
self.__instance_method = imeth
154154
return self
155155

156156
def class_method(
157157
self,
158-
cmeth # type: typing.Optional[typing.Callable[..., typing.Any]]
158+
cmeth # type: typing.Optional[typing.Callable]
159159
): # type: (...) -> SeparateClassMethod
160160
"""Descriptor to change class method.
161161
162162
:type cmeth: New class method.
163-
:type cmeth: typing.Optional[typing.Callable[..., typing.Any]]
163+
:type cmeth: typing.Optional[typing.Callable]
164164
:rtype: SeparateClassMethod
165165
"""
166166
self.__class_method = cmeth
167167
return self
168168

169169
@property
170-
def imeth(self): # type: () -> typing.Optional[typing.Callable[..., typing.Any]]
170+
def imeth(self): # type: () -> typing.Optional[typing.Callable]
171171
"""Instance method instance.
172172
173-
:rtype: typing.Optional[typing.Callable[..., typing.Any]]
173+
:rtype: typing.Optional[typing.Callable]
174174
"""
175175
return self.__instance_method
176176

177177
@property
178-
def cmeth(self): # type: () -> typing.Optional[typing.Callable[..., typing.Any]]
178+
def cmeth(self): # type: () -> typing.Optional[typing.Callable]
179179
"""Class method instance.
180180
181-
:rtype: typing.Optional[typing.Callable[..., typing.Any]]
181+
:rtype: typing.Optional[typing.Callable]
182182
"""
183183
return self.__class_method
184184

doc/source/separate_classmethod.rst

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,32 +14,32 @@ API: SeparateClassMethod
1414
.. py:method:: __init__(imeth=None, cmeth=None, )
1515
1616
:param imeth: Instance method
17-
:type imeth: ``typing.Optional[typing.Callable[..., typing.Any]]``
17+
:type imeth: ``typing.Optional[typing.Callable]``
1818
:param cmeth: Class method
19-
:type cmeth: ``typing.Optional[typing.Callable[..., typing.Any]]``
19+
:type cmeth: ``typing.Optional[typing.Callable]``
2020

2121
.. py:method:: instance_method(imeth)
2222
2323
Descriptor to change instance method.
2424

2525
:param imeth: New instance method.
26-
:type imeth: ``typing.Optional[typing.Callable[..., typing.Any]]``
26+
:type imeth: ``typing.Optional[typing.Callable]``
2727
:rtype: ``SeparateClassMethod``
2828

2929
.. py:method:: class_method(cmeth)
3030
3131
Descriptor to change class method.
3232

3333
:type cmeth: New class method.
34-
:type cmeth: ``typing.Optional[typing.Callable[..., typing.Any]]``
34+
:type cmeth: ``typing.Optional[typing.Callable]``
3535
:rtype: ``SeparateClassMethod``
3636

3737
.. py:attribute:: imeth
3838
39-
``typing.Optional[typing.Callable[..., typing.Any]]``
39+
``typing.Optional[typing.Callable]``
4040
Instance method instance.
4141

4242
.. py:attribute:: cmeth
4343
44-
``typing.Optional[typing.Callable[..., typing.Any]]``
44+
``typing.Optional[typing.Callable]``
4545
Class method instance.

setup.cfg

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,5 @@ count = True
4545
test=pytest
4646

4747
[tool:pytest]
48-
addopts = -vv --cov-config .coveragerc --cov=advanced_descriptors
48+
addopts = -vvv -s -p no:django -p no:ipdb
49+
testpaths = test

setup.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,14 @@
1111
# License for the specific language governing permissions and limitations
1212
# under the License.
1313

14-
"""Advanded descriptors for special cases."""
14+
"""Advanced descriptors for special cases."""
1515

1616
from __future__ import print_function
1717

1818
import ast
1919
import collections
2020
from distutils.command import build_ext
2121
import distutils.errors
22-
import glob
2322
import os.path
2423
import shutil
2524
import sys
@@ -259,12 +258,7 @@ def get_simple_vars_from_src(src):
259258
"!=36.2.0",
260259
install_requires=required,
261260
package_data={
262-
'advanced_descriptors': [
263-
os.path.basename(filename)
264-
for filename in glob.glob(os.path.join('advanced_descriptors', '*.pyi'))
265-
] + [
266-
'py.typed'
267-
],
261+
'advanced_descriptors': ['py.typed'],
268262
},
269263
)
270264
if cythonize is not None:

tox.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ deps =
2525
py{27,py}: mock
2626

2727
commands =
28-
py.test -vv --junitxml=unit_result.xml --html=report.html --cov-config .coveragerc --cov-report html --cov=advanced_descriptors {posargs:test}
28+
py.test -vv --junitxml=unit_result.xml --html=report.html --self-contained-html --cov-config .coveragerc --cov-report html --cov=advanced_descriptors {posargs:test}
2929
coverage report --fail-under 89
3030

3131
[testenv:py34-nocov]

0 commit comments

Comments
 (0)