8000 Fix deprecation warning for 3.7 and up · staticdev/github4.py@dd210a3 · GitHub
[go: up one dir, main page]

Skip to content
This repository was archived by the owner on May 22, 2021. It is now read-only.

Commit dd210a3

Browse files
committed
Fix deprecation warning for 3.7 and up
Fix sigmavirus24#963
1 parent 043d61f commit dd210a3

File tree

4 files changed

+22
-7
lines changed

4 files changed

+22
-7
lines changed

AUTHORS.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,4 +181,6 @@ Contributors
181181

182182
- Steven Nyman (@stevennyman)
183183

184-
- Tigran Tchougourian (@NargiT)
184+
- Tigran Tchougourian (@NargiT)
185+
186+
- Dimitri Merejkowsky (@dmer 10000 ejkowsky)

src/github3/session.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
# -*- coding: utf-8 -*-
22
"""Module containing session and auth logic."""
3-
from collections import Callable
3+
try:
4+
import collections.abc as abc_collections
5+
except ImportError:
6+
# For Python 2.7 compatibility
7+
import collections as abc_collections
8+
49
import datetime
510
from contextlib import contextmanager
611
from logging import getLogger
@@ -193,7 +198,7 @@ def two_factor_auth_callback(self, callback):
193198
if not callback:
194199
return
195200

196-
if not isinstance(callback, Callable):
201+
if not isinstance(callback, abc_collections.Callable):
197202
raise ValueError("Your callback should be callable")
198203

199204
self.two_factor_auth_cb = callback

src/github3/structs.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# -*- coding: utf-8 -*-
2-
import collections
2+
try:
3+
import collections.abc as abc_collections
4+
except ImportError:
5+
# For Python 2.7 compatibility
6+
import collections as abc_collections
37
import functools
48

59
from requests.compat import urlparse, urlencode
@@ -8,7 +12,7 @@
812
from . import models
913

1014

11-
class GitHubIterator(models.GitHubCore, collections.Iterator):
15+
class GitHubIterator(models.GitHubCore, abc_collections.Iterator):
1216
"""The :class:`GitHubIterator` class powers all of the iter_* methods."""
1317

1418
def __init__(

src/github3/utils.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
# -*- coding: utf-8 -*-
22
"""A collection of useful utilities."""
3-
import collections
3+
try:
4+
import collections.abc as abc_collections
5+
except ImportError:
6+
# For Python 2.7 compatibility
7+
import collections as abc_collections
48
import datetime
59
import re
610

@@ -68,7 +72,7 @@ def stream_response_to_file(response, path=None):
6872
fd = None
6973
filename = None
7074
if path:
71-
if isinstance(getattr(path, "write", None), collections.Callable):
75+
if isinstance(getattr(path, "write", None), abc_collections.Callable):
7276
pre_opened = True
7377
fd = path
7478
filename = getattr(fd, "name", None)

0 commit comments

Comments
 (0)
0