Skip to content

Commit

Permalink
get_section: check ABCs instead of list/dict subclass
Browse files Browse the repository at this point in the history
  • Loading branch information
djsutherland committed Aug 10, 2018
1 parent dc7755b commit 66445be
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions conda_smithy/lint_recipe.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,26 @@

from __future__ import unicode_literals

import datetime
try:
from collections.abc import Sequence, Mapping
except ImportError: # python 2
from collections import Sequence, Mapping
import copy
import io
import itertools
import os
import re
import time

import github
import jinja2
import ruamel.yaml

from conda_build.metadata import (ensure_valid_license_family,
FIELDS as cbfields)
import conda_build.conda_interface

from collections import defaultdict

import copy

from .utils import render_meta_yaml


FIELDS = copy.deepcopy(cbfields)

# Just in case 'extra' moves into conda_build
Expand Down Expand Up @@ -50,7 +49,7 @@ def get_section(parent, name, lints):
return get_list_section(parent, name, lints)

section = parent.get(name, {})
if not isinstance(section, dict):
if not isinstance(section, Mapping):
lints.append('The "{}" section was expected to be a dictionary, but '
'got a {}.'.format(name, type(section).__name__))
section = {}
Expand All @@ -59,9 +58,9 @@ def get_section(parent, name, lints):

def get_list_section(parent, name, lints, allow_single=False):
section = parent.get(name, [])
if allow_single and isinstance(section, dict):
if allow_single and isinstance(section, Mapping):
return [section]
elif isinstance(section, list):
elif isinstance(section, Sequence):
return section
else:
msg = ('The "{}" section was expected to be a {}list, but got a {}.{}.'
Expand Down

0 comments on commit 66445be

Please sign in to comment.