]> git.ipfire.org Git - thirdparty/sqlalchemy/alembic.git/commitdiff
Use collections.Callable ABC instead of callable() predicate
authorHong Minhee <minhee@dahlia.kr>
Fri, 12 Apr 2013 22:03:25 +0000 (07:03 +0900)
committerHong Minhee <minhee@dahlia.kr>
Fri, 12 Apr 2013 22:03:25 +0000 (07:03 +0900)
alembic/ddl/impl.py
alembic/migration.py
alembic/util.py

index ab67e0c713f475e91b9cbb6452f6aa9c4b34770f..fbcec939045f15270264db5152fc7e4092d770d2 100644 (file)
@@ -2,6 +2,7 @@ try:
     import builtins
 except ImportError:
     import __builtin__ as builtins
+import collections
 
 from sqlalchemy.sql.expression import _BindParamClause
 from sqlalchemy.ext.compiler import compiles
@@ -57,7 +58,8 @@ class DefaultImpl(with_metaclass(ImplMeta)):
     def static_output(self, text):
         text_ = text_type(text + '\n\n')
         self.output_buffer.write(text_)
-        if callable(getattr(self.output_buffer, 'flush', None)):
+        if isinstance(getattr(self.output_buffer, 'flush', None),
+                collections.Callable):
             self.output_buffer.flush()
 
     @property
index bf8e9380826e25da2db08fdd615958e40eeaf1f6..fa28053bac80aab1f1b305385851cf0c60dab5fc 100644 (file)
@@ -1,3 +1,4 @@
+import collections
 import io
 import logging
 import sys
@@ -274,7 +275,7 @@ class MigrationContext(object):
         if self._user_compare_type is False:
             return False
 
-        if callable(self._user_compare_type):
+        if isinstance(self._user_compare_type, collections.Callable):
             user_value = self._user_compare_type(
                 self,
                 inspector_column,
@@ -296,7 +297,7 @@ class MigrationContext(object):
         if self._user_compare_server_default is False:
             return False
 
-        if callable(self._user_compare_server_default):
+        if isinstance(self._user_compare_server_default, collections.Callable):
             user_value = self._user_compare_server_default(
                     self,
                     inspector_column,
index 6111d20203b7b32ba3d97747d9f06b6a5f6481fe..4f223f762f0a72e796c40b92be8b4a1de3cf7d5c 100644 (file)
@@ -4,6 +4,7 @@ try:
     import builtins
 except ImportError:
     import __builtin__ as builtins
+import collections
 import sys
 import os
 import textwrap
@@ -129,7 +130,7 @@ def create_module_class_proxy(cls, globals_, locals_):
 
     for methname in dir(cls):
         if not methname.startswith('_'):
-            if callable(getattr(cls, methname)):
+            if isinstance(getattr(cls, methname), collections.Callable):
                 locals_[methname] = _create_op_proxy(methname)
             else:
                 attr_names.add(methname)