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

Fix python 3.10 breaking change for collections #22

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
7 changes: 5 additions & 2 deletions snaql/convertors.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
# coding: utf-8
import re
import collections

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

ESCAPE_REGEX = re.compile(r"[\0\n\r\032\'\"\\]")
ESCAPE_MAP = {
Expand Down Expand Up @@ -119,7 +122,7 @@ def guard_case(value, items=None):
return value

items = items or set()
if not isinstance(items, collections.Iterable):
if not isinstance(items, Iterable):
raise SnaqlGuardException('Guard items are not iterable')

items = set(items)
Expand Down
10 changes: 7 additions & 3 deletions snaql/factory.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# coding: utf-8
import os
import copy
import collections
import types
import sys
from collections import namedtuple
Expand All @@ -13,6 +12,11 @@
from jinja2.utils import open_if_exists
from schema import Schema

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

from snaql.convertors import (
guard_bool,
guard_case,
Expand Down Expand Up @@ -175,7 +179,7 @@ def gen_func(self, name, meta_struct, env):

def subrender_cond(owner_name, cond_func, context):
if (
isinstance(cond_func, collections.Callable) and
isinstance(cond_func, Callable) and
cond_func.is_cond
):
cond_struct = meta_struct['funcs'][cond_func.func_name]
Expand Down Expand Up @@ -205,7 +209,7 @@ def fn(**kwargs):
if maybe_cond_sql:
kwargs[point] = maybe_cond_sql
if (
isinstance(val, collections.Iterable) and
isinstance(val, Iterable) and
not isinstance(
val, (str if PY3K else types.StringTypes, dict)
)
Expand Down