8000 Fix `collections`'s `DeprecationWarning`s (#432) · rjgildea/zarr-python@fb8e6d5 · GitHub
[go: up one dir, main page]

Skip to content

Commit fb8e6d5

Browse files
authored
Fix collections's DeprecationWarnings (zarr-developers#432)
* Import `MutableMapping` in `compat` As `MutableMapping` moves to `collections.abc` in Python 3.3, handle how it is imported using the `compat` module to get the right location. * Use `compat` for `collections.abc`s * Use MutableMapping from compat in zarr.tests.util * Add release note for the fix
1 parent 48aa41d commit fb8e6d5

File tree

7 files changed

+12
-10
lines changed

7 files changed

+12
-10
lines changed

‎docs/release.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ Bug fixes
1212
* Add and use utility functions to simplify reading and writing JSON.
1313
By :user:`John Kirkham <jakirkham>`; :issue:`429`, :issue:`430`
1414

15+
* Fix `collections`'s `DeprecationWarning`s.
16+
By :user:`John Kirkham <jakirkham>`; :issue:`432`
17+
1518

1619
.. _release_2.3.1:
1720

‎zarr/attrs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# -*- coding: utf-8 -*-
22
from __future__ import absolute_import, print_function, division
3-
from collections import MutableMapping
43

54

5+
from zarr.compat import MutableMapping
66
from zarr.errors import PermissionError
77
from zarr.meta import parse_metadata
88
from zarr.util import json_dumps

‎zarr/compat.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class PermissionError(Exception):
2020
def OrderedDict_move_to_end(od, key):
2121
od[key] = od.pop(key)
2222

23-
from collections import Mapping
23+
from collections import Mapping, MutableMapping
2424

2525

2626
else: # pragma: py2 no cover
@@ -34,4 +34,4 @@ def OrderedDict_move_to_end(od, key):
3434
def OrderedDict_move_to_end(od, key):
3535
od.move_to_end(key)
3636

37-
from collections.abc import Mapping
37+
from collections.abc import Mapping, MutableMapping

‎zarr/convenience.py

Lines changed: 1 addition & 2 deletions
8000
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# -*- coding: utf-8 -*-
22
"""Convenience functions for storing and loading data."""
33
from __future__ import absolute_import, print_function, division
4-
from collections import Mapping
54
import io
65
import re
76
import itertools
@@ -14,7 +13,7 @@
1413
from zarr.storage import contains_array, contains_group
1514
from zarr.errors import err_path_not_found, CopyError
1615
from zarr.util import normalize_storage_path, TreeViewer, buffer_size
17-
from zarr.compat import PY2, text_type
16+
from zarr.compat import Mapping, PY2, text_type
1817
from zarr.meta import json_dumps, json_loads
1918

2019

‎zarr/hierarchy.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
# -*- coding: utf-8 -*-
22
from __future__ import absolute_import, print_function, division
3-
from collections import MutableMapping
43
from itertools import islice
54

65
import numpy as np
76

87

9-
from zarr.compat import PY2
8+
from zarr.compat import PY2, MutableMapping
109
from zarr.attrs import Attributes
1110
from zarr.core import Array
1211
from zarr.storage import (contains_array, contains_group, init_group,

‎zarr/storage.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
1717
"""
1818
from __future__ import absolute_import, print_function, division
19-
from collections import MutableMapping, OrderedDict
19+
from collections import OrderedDict
2020
import os
2121
import operator
2222
import tempfile
@@ -37,7 +37,7 @@
3737
normalize_storage_path, buffer_size,
3838
normalize_fill_value, nolock, normalize_dtype)
3939
from zarr.meta import encode_array_metadata, encode_group_metadata
40-
from zarr.compat import PY2, OrderedDict_move_to_end
40+
from zarr.compat import PY2, MutableMapping, OrderedDict_move_to_end
4141
from numcodecs.registry import codec_registry
4242
from numcodecs.compat import ensure_bytes, ensure_contiguous_ndarray
4343
from zarr.errors import (err_contains_group, err_contains_array, err_bad_compressor,

â 87C7 €Žzarr/tests/util.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
# -*- coding: utf-8 -*-
22
from __future__ import absolute_import, print_function, division
33
import collections
4+
from zarr.compat import MutableMapping
45

56

6-
class CountingDict(collections.MutableMapping):
7+
class CountingDict(MutableMapping):
78

89
def __init__(self):
910
self.wrapped = dict()

0 commit comments

Comments
 (0)
0