Skip to content

Commit

Permalink
Import ABC from collections.abc instead of collections
Browse files Browse the repository at this point in the history
For Python 3.9 compatibility.

Comes from #6

Change-Id: Ic34b7bf5857b863cd30371ea475b084c9a00cd65
  • Loading branch information
tirkarthi authored and javierpena committed Feb 6, 2020
1 parent 8a89744 commit 8ff15a9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
9 changes: 7 additions & 2 deletions distroinfo/parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@
import copy
import six

try:
from collections.abc import Iterable
except ImportError:
from collections import Iterable

from distroinfo import exception


Expand Down Expand Up @@ -48,7 +53,7 @@ def parse_releases(info):
releases = info['releases']
except KeyError:
raise exception.MissingRequiredSection(section='releases')
if not isinstance(releases, collections.Iterable):
if not isinstance(releases, Iterable):
raise exception.InvalidInfoFormat(
msg="'releases' section must be iterable")
if isinstance(releases, dict):
Expand Down Expand Up @@ -148,7 +153,7 @@ def parse_packages(info, apply_tag=None):
pkgs = info['packages']
except KeyError:
raise exception.MissingRequiredSection(section='packages')
if not isinstance(pkgs, collections.Iterable):
if not isinstance(pkgs, Iterable):
raise exception.InvalidInfoFormat(
msg="'packages' section must be iterable")
if isinstance(pkgs, dict):
Expand Down
8 changes: 6 additions & 2 deletions distroinfo/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,15 @@
# under the License.

from __future__ import print_function
import collections
from functools import partial
import re
import six

try:
from collections.abc import Iterable
except ImportError:
from collections import Iterable

from distroinfo import exception


Expand Down Expand Up @@ -77,7 +81,7 @@ def _match_pkg(rexen, pkg):
if isinstance(val, six.string_types):
if not re.search(rex, val):
return False
elif isinstance(val, collections.Iterable):
elif isinstance(val, Iterable):
# collection matches if any item of collection matches
found = False
for e in val:
Expand Down

0 comments on commit 8ff15a9

Please sign in to comment.