Skip to content

Commit 55c60e9

Browse files
authored
Merge pull request #485 from tacaswell/mnt_improve_warnings
MNT: improve warnings
2 parents 253d913 + ba9b182 commit 55c60e9

File tree

5 files changed

+19
-7
lines changed

5 files changed

+19
-7
lines changed

toolz/compatibility.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"needed in Python 3 and has been deprecated. Please "
44
"import these utilities directly from the standard library. "
55
"This module will be removed in a future release.",
6-
category=DeprecationWarning)
6+
category=DeprecationWarning, stacklevel=2)
77

88
import operator
99
import sys

toolz/functoolz.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,12 @@
55
from importlib import import_module
66
from textwrap import dedent
77
from types import MethodType
8+
import sys
89

910
from .utils import no_default
1011

12+
PYPY = hasattr(sys, 'pypy_version_info') and sys.version_info[0] > 2
13+
1114

1215
__all__ = ('identity', 'apply', 'thread_first', 'thread_last', 'memoize',
1316
'compose', 'compose_left', 'pipe', 'complement', 'juxt', 'do',

toolz/tests/test_compatibility.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,10 @@
1-
import toolz.compatibility
1+
2+
import pytest
3+
import importlib
4+
5+
def test_compat_warn():
6+
with pytest.warns(DeprecationWarning):
7+
# something else is importing this,
8+
import toolz.compatibility
9+
# reload to be sure we warn
10+
importlib.reload(toolz.compatibility)

toolz/tests/test_itertoolz.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -542,8 +542,8 @@ def test_random_sample():
542542

543543
assert rsample1 != rsample2
544544

545-
assert mk_rsample(object) == mk_rsample(object)
546-
assert mk_rsample(object) != mk_rsample(object())
545+
assert mk_rsample(hash(object)) == mk_rsample(hash(object))
546+
assert mk_rsample(hash(object)) != mk_rsample(hash(object()))
547547
assert mk_rsample(b"a") == mk_rsample(u"a")
548548

549549
assert raises(TypeError, lambda: mk_rsample([]))

versioneer.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -339,9 +339,9 @@ def get_config_from_root(root):
339339
# configparser.NoOptionError (if it lacks "VCS="). See the docstring at
340340
# the top of versioneer.py for instructions on writing your setup.cfg .
341341
setup_cfg = os.path.join(root, "setup.cfg")
342-
parser = configparser.SafeConfigParser()
343-
with open(setup_cfg, "r") as f:
344-
parser.readfp(f)
342+
parser = configparser.ConfigParser()
343+
344+
parser.read(setup_cfg)
345345
VCS = parser.get("versioneer", "VCS") # mandatory
346346

347347
def get(parser, name):

0 commit comments

Comments
 (0)