]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
Remove unnecessary util.callable usage
authorSteven Loria <sloria1@gmail.com>
Mon, 9 Sep 2019 14:48:29 +0000 (10:48 -0400)
committersqla-tester <sqla-tester@sqlalchemy.org>
Mon, 9 Sep 2019 14:48:29 +0000 (10:48 -0400)
Fixes: #4850
<!-- Provide a general summary of your proposed changes in the Title field above -->

### Description
<!-- Describe your changes in detail -->

Removes usage of `util.callable`.

### Checklist
<!-- go over following points. check them with an `x` if they do apply, (they turn into clickable checkboxes once the PR is submitted, so no need to do everything at once)

-->

This pull request is:

- [ ] A documentation / typographical error fix
- Good to go, no issue or tests are needed
- [x] A short code fix
- please include the issue number, and create an issue if none exists, which
  must include a complete example of the issue.  one line code fixes without an
  issue and demonstration will not be accepted.
- Please include: `Fixes: #<issue number>` in the commit message
- please include tests.   one line code fixes without tests will not be accepted.
- [ ] A new feature implementation
- please include the issue number, and create an issue if none exists, which must
  include a complete example of how the feature would look.
- Please include: `Fixes: #<issue number>` in the commit message
- please include tests.

**Have a nice day!**

Closes: #4851
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/4851
Pull-request-sha: a0ccdff2cb74f5e944d8baccc269c382b591c8e2

Change-Id: I79918f44becbc5dbefdc7ff65128695c1cabed1d

lib/sqlalchemy/ext/associationproxy.py
lib/sqlalchemy/ext/orderinglist.py
lib/sqlalchemy/orm/attributes.py
lib/sqlalchemy/orm/collections.py
lib/sqlalchemy/orm/relationships.py
lib/sqlalchemy/sql/ddl.py
lib/sqlalchemy/sql/schema.py
lib/sqlalchemy/sql/type_api.py
lib/sqlalchemy/testing/assertsql.py
lib/sqlalchemy/testing/exclusions.py
lib/sqlalchemy/util/compat.py

index 32dee79c6926173caa690d5526c6ed7ec9f430a8..f72b46c25c47804afbeb964bc15146379d6938f8 100644 (file)
@@ -1180,7 +1180,7 @@ class _AssociationList(_AssociationCollection):
 
     for func_name, func in list(locals().items()):
         if (
-            util.callable(func)
+            callable(func)
             and func.__name__ == func_name
             and not func.__doc__
             and hasattr(list, func_name)
@@ -1355,7 +1355,7 @@ class _AssociationDict(_AssociationCollection):
 
     for func_name, func in list(locals().items()):
         if (
-            util.callable(func)
+            callable(func)
             and func.__name__ == func_name
             and not func.__doc__
             and hasattr(dict, func_name)
@@ -1574,7 +1574,7 @@ class _AssociationSet(_AssociationCollection):
 
     for func_name, func in list(locals().items()):
         if (
-            util.callable(func)
+            callable(func)
             and func.__name__ == func_name
             and not func.__doc__
             and hasattr(set, func_name)
index 16e0f1f2a4b772f8280e39177ffe5f9b93256957..5dbe58726ba6c29d748eb63fd192dec5edb06d56 100644 (file)
@@ -119,7 +119,6 @@ start numbering at 1 or some other integer, provide ``count_from=1``.
 
 
 """
-from .. import util
 from ..orm.collections import collection
 from ..orm.collections import collection_adapter
 
@@ -367,7 +366,7 @@ class OrderingList(list):
 
     for func_name, func in list(locals().items()):
         if (
-            util.callable(func)
+            callable(func)
             and func.__name__ == func_name
             and not func.__doc__
             and hasattr(list, func_name)
index d50eab03ecc3ac445fca9c0121eecd5372dd1dcf..9d404e00d43d057b2dd9cddbcbbea52872902b58 100644 (file)
@@ -328,7 +328,7 @@ def create_proxied_attribute(descriptor):
 
         @util.memoized_property
         def comparator(self):
-            if util.callable(self._comparator):
+            if callable(self._comparator):
                 self._comparator = self._comparator()
             if self._adapt_to_entity:
                 self._comparator = self._comparator.adapt_to_entity(
@@ -702,8 +702,10 @@ class AttributeImpl(object):
                 if not passive & CALLABLES_OK:
                     return PASSIVE_NO_RESULT
 
-                if self.accepts_scalar_loader and \
-                        key in state.expired_attributes:
+                if (
+                    self.accepts_scalar_loader
+                    and key in state.expired_attributes
+                ):
                     value = state._load_expired(state, passive)
                 elif key in state.callables:
                     callable_ = state.callables[key]
index ae96a8c4da59f9ecc6892b73beafda1b6172d4b5..4b096c152777668095e315b70d449f81fe0067e7 100644 (file)
@@ -936,7 +936,7 @@ def _locate_roles_and_methods(cls):
 
     for supercls in cls.__mro__:
         for name, method in vars(supercls).items():
-            if not util.callable(method):
+            if not callable(method):
                 continue
 
             # note role declarations
index 46eec75eb94923a0659d28a0fb416bb2ffa753bc..63ec21099a328fdf0484fbc00f9e8238631826d9 100644 (file)
@@ -1824,7 +1824,7 @@ class RelationshipProperty(StrategizedProperty):
         class or aliased class tha is referred towards.
 
         """
-        if util.callable(self.argument) and not isinstance(
+        if callable(self.argument) and not isinstance(
             self.argument, (type, mapperlib.Mapper)
         ):
             argument = self.argument()
@@ -1888,7 +1888,7 @@ class RelationshipProperty(StrategizedProperty):
             "remote_side",
         ):
             attr_value = getattr(self, attr)
-            if util.callable(attr_value):
+            if callable(attr_value):
                 setattr(self, attr, attr_value())
 
         # remove "annotations" which are present if mapped class
index ef6614b6157837f203390b6a5b03da5154da2856..48d4bc9dcb0dde07193bc22e9854cf480811b29e 100644 (file)
@@ -258,7 +258,7 @@ class DDLElement(roles.DDLRole, Executable, _DDLCompiles):
     def _check_ddl_on(self, on):
         if on is not None and (
             not isinstance(on, util.string_types + (tuple, list, set))
-            and not util.callable(on)
+            and not callable(on)
         ):
             raise exc.ArgumentError(
                 "Expected the name of a database dialect, a tuple "
index f0a6977285d30c2236eebf5c33d466e68addebb7..d5ee1057b86c00262baaed8fe9301da4c78aa7f6 100644 (file)
@@ -2222,13 +2222,13 @@ class ColumnDefault(DefaultGenerator):
             raise exc.ArgumentError(
                 "ColumnDefault may not be a server-side default type."
             )
-        if util.callable(arg):
+        if callable(arg):
             arg = self._maybe_wrap_callable(arg)
         self.arg = arg
 
     @util.memoized_property
     def is_callable(self):
-        return util.callable(self.arg)
+        return callable(self.arg)
 
     @util.memoized_property
     def is_clause_element(self):
@@ -4211,7 +4211,7 @@ class MetaData(SchemaItem):
                     for name, schname in zip(available, available_w_schema)
                     if extend_existing or schname not in current
                 ]
-            elif util.callable(only):
+            elif callable(only):
                 load = [
                     name
                     for name, schname in zip(available, available_w_schema)
index 11407ad2e193ea406e5514421f793547218b424f..9c5f5dd475da21b134146a56b2a0eb069c279504 100644 (file)
@@ -1461,7 +1461,7 @@ def to_instance(typeobj, *arg, **kw):
     if typeobj is None:
         return NULLTYPE
 
-    if util.callable(typeobj):
+    if callable(typeobj):
         return typeobj(*arg, **kw)
     else:
         return typeobj
index 55f4dc2abb86c3ca7465f400e1ab5fcf75071368..6a654df1ece3a8d45b12cc3d9c92b435a98e6a78 100644 (file)
@@ -170,7 +170,7 @@ class CompiledSQL(SQLMatchRule):
 
     def _all_params(self, context):
         if self.params:
-            if util.callable(self.params):
+            if callable(self.params):
                 params = self.params(context)
             else:
                 params = self.params
index d205354cfff5a043224d6a653fb0e6d7ff355493..edb9caa168a6333ec18891ab5b0b86b9bac585e6 100644 (file)
@@ -208,7 +208,7 @@ class Predicate(object):
             )
 
             return SpecPredicate(db, op, spec, description=description)
-        elif util.callable(predicate):
+        elif callable(predicate):
             return LambdaPredicate(predicate, description)
         else:
             assert False, "unknown predicate type: %s" % predicate
index b655a55f3c7e3b394b3dd59219c2fe6e620c28f8..8cfaea26e2c8bec9a09bf3bf703a48b0ac04bb8f 100644 (file)
@@ -158,14 +158,8 @@ if py3k:
     def ue(s):
         return s
 
-    if py32:
-        callable = callable  # noqa
-    else:
-
-        def callable(fn):  # noqa
-            return hasattr(fn, "__call__")
-
-
+    # Unused. Kept for backwards compatibility.
+    callable = callable  # noqa
 else:
     import base64
     import ConfigParser as configparser  # noqa