Skip to content
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

Import ABC from collections.abc instead of collections for Python 3.9 compatibility #6

Closed
wants to merge 1 commit into from
Closed
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
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