Skip to content

Commit b60b083

Browse files
committed
Merge pull request #3047 from charris/2to3-callable
2to3: Fix callable.
2 parents 00a946e + 5ee9272 commit b60b083

File tree

5 files changed

+10
-5
lines changed

5 files changed

+10
-5
lines changed

docscrape.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import pydoc
99
from StringIO import StringIO
1010
from warnings import warn
11+
import collections
1112

1213
class Reader(object):
1314
"""A line-based string reader.
@@ -495,7 +496,7 @@ def methods(self):
495496
return [name for name,func in inspect.getmembers(self._cls)
496497
if ((not name.startswith('_')
497498
or name in self.extra_public_methods)
498-
and callable(func))]
499+
and isinstance(func, collections.Callable))]
499500

500501
@property
501502
def properties(self):

docscrape_sphinx.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import re, inspect, textwrap, pydoc
22
import sphinx
33
from docscrape import NumpyDocString, FunctionDoc, ClassDoc
4+
import collections
45

56
class SphinxDocString(NumpyDocString):
67
def __init__(self, docstring, config={}):
@@ -212,7 +213,7 @@ def get_doc_object(obj, what=None, doc=None, config={}):
212213
what = 'class'
213214
elif inspect.ismodule(obj):
214215
what = 'module'
215-
elif callable(obj):
216+
elif isinstance(obj, collections.Callable):
216217
what = 'function'
217218
else:
218219
what = 'object'

linkcode.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
"""
1111

1212
import warnings
13+
import collections
1314
warnings.warn("This extension has been submitted to Sphinx upstream. "
1415
"Use the version from there if it is accepted "
1516
"https://bitbucket.org/birkenfeld/sphinx/pull-request/47/sphinxextlinkcode",
@@ -29,7 +30,7 @@ def doctree_read(app, doctree):
2930
env = app.builder.env
3031

3132
resolve_target = getattr(env.config, 'linkcode_resolve', None)
32-
if not callable(env.config.linkcode_resolve):
33+
if not isinstance(env.config.linkcode_resolve, collections.Callable):
3334
raise LinkcodeError(
3435
"Function `linkcode_resolve` is not given in conf.py")
3536

numpydoc.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
"""
1818

1919
import sphinx
20+
import collections
2021

2122
if sphinx.__version__ < '1.0.1':
2223
raise RuntimeError("Sphinx 1.0.1 or newer is required")
@@ -82,7 +83,7 @@ def mangle_signature(app, what, name, obj, options, sig, retann):
8283
'initializes x; see ' in pydoc.getdoc(obj.__init__))):
8384
return '', ''
8485

85-
if not (callable(obj) or hasattr(obj, '__argspec_is_invalid_')): return
86+
if not (isinstance(obj, collections.Callable) or hasattr(obj, '__argspec_is_invalid_')): return
8687
if not hasattr(obj, '__doc__'): return
8788

8889
doc = SphinxDocString(pydoc.getdoc(obj))

traitsdoc.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import numpydoc
2626

2727
import comment_eater
28+
import collections
2829

2930
class SphinxTraitsDoc(SphinxClassDoc):
3031
def __init__(self, cls, modulename='', func_doc=SphinxFunctionDoc):
@@ -117,7 +118,7 @@ def get_doc_object(obj, what=None, config=None):
117118
what = 'class'
118119
elif inspect.ismodule(obj):
119120
what = 'module'
120-
elif callable(obj):
121+
elif isinstance(obj, collections.Callable):
121122
what = 'function'
122123
else:
123124
what = 'object'

0 commit comments

Comments
 (0)