Skip to content

FIX: Fix collections.abc imports #195

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 13, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions numpydoc/docscrape.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@
import re
import pydoc
from warnings import warn
import collections
from collections import namedtuple
try:
from collections.abc import Callable, Mapping
except ImportError:
from collections import Callable, Mapping
import copy
import sys

Expand Down Expand Up @@ -106,10 +110,10 @@ def __str__(self):
return message


Parameter = collections.namedtuple('Parameter', ['name', 'type', 'desc'])
Parameter = namedtuple('Parameter', ['name', 'type', 'desc'])


class NumpyDocString(collections.Mapping):
class NumpyDocString(Mapping):
"""Parses a numpydoc string to an abstract representation

Instances define a mapping from section title to structured data.
Expand Down Expand Up @@ -607,7 +611,7 @@ def methods(self):
return [name for name, func in inspect.getmembers(self._cls)
if ((not name.startswith('_')
or name in self.extra_public_methods)
and isinstance(func, collections.Callable)
and isinstance(func, Callable)
and self._is_show_member(name))]

@property
Expand Down
7 changes: 5 additions & 2 deletions numpydoc/docscrape_sphinx.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@
import inspect
import textwrap
import pydoc
import collections
try:
from collections.abc import Callable
except ImportError:
from collections import Callable
import os

from jinja2 import FileSystemLoader
Expand Down Expand Up @@ -413,7 +416,7 @@ def get_doc_object(obj, what=None, doc=None, config={}, builder=None):
what = 'class'
elif inspect.ismodule(obj):
what = 'module'
elif isinstance(obj, collections.Callable):
elif isinstance(obj, Callable):
what = 'function'
else:
what = 'object'
Expand Down
7 changes: 5 additions & 2 deletions numpydoc/numpydoc.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@
import re
import pydoc
import inspect
import collections
try:
from collections.abc import Callable
except ImportError:
from collections import Callable
import hashlib

from docutils.nodes import citation, Text
Expand Down Expand Up @@ -156,7 +159,7 @@ def mangle_signature(app, what, name, obj, options, sig, retann):
'initializes x; see ' in pydoc.getdoc(obj.__init__))):
return '', ''

if not (isinstance(obj, collections.Callable) or
if not (isinstance(obj, Callable) or
hasattr(obj, '__argspec_is_invalid_')):
return

Expand Down