]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
PEP8 and docstring fix 4505/head
authorsanjana <sanjana0796@gmail.com>
Tue, 19 Feb 2019 06:38:40 +0000 (12:08 +0530)
committersanjana <sanjana0796@gmail.com>
Tue, 19 Feb 2019 06:38:40 +0000 (12:08 +0530)
lib/sqlalchemy/orm/query.py
test/orm/test_query.py

index a7f0f5948ac5e2d44aa6811d1eb27cf062bc3ee3..5fe416eed5adb4503650debbd7f630aa93cc4ec9 100644 (file)
@@ -918,9 +918,15 @@ class Query(object):
         before querying the database.  See :doc:`/orm/loading_relationships`
         for further details on relationship loading.
 
-        :param ident: A scalar or tuple value representing
+        :param ident: A scalar or tuple value or dictionary representing
          the primary key.   For a composite primary key,
-         a dictionary with keys being primary key column names.
+         a dictionary with keys being primary key column names or tuple
+         in which the order of identifiers corresponds in most cases
+         to that of the mapped :class:`.Table` object's
+         primary key columns.  For a :func:`.mapper` that
+         was given the ``primary key`` argument during
+         construction, the order of identifiers corresponds
+         to the elements present in this collection.
 
         :return: The object instance, or ``None``.
 
@@ -1002,14 +1008,18 @@ class Query(object):
         if is_dict:
             try:
                 primary_key_identity = list(
-                                             primary_key_identity[prop.key]
-                                             for prop in mapper._identity_key_props
-                                        )
+                    primary_key_identity[prop.key]
+                    for prop in mapper._identity_key_props
+                )
+
             except KeyError:
                 raise sa_exc.InvalidRequestError(
                     "Incorrect names of values in identifier to formulate "
-                    "primary key for query.get(); primary key attribute names are %s"
-                    % ",".join("'%s'" % prop.key for prop in mapper._identity_key_props)
+                    "primary key for query.get(); primary key attribute names"
+                    " are %s" % ",".join(
+                        "'%s'" % prop.key
+                        for prop in mapper._identity_key_props
+                    )
                 )
 
         if (
index 3c642582180975bee6d7479e2b17cb93d4be1e04..935e3e31c43ad77e0b7094c5ba61a9bb7074aa10 100644 (file)
@@ -667,7 +667,11 @@ class GetTest(QueryTest):
 
         s = Session()
         q = s.query(CompositePk)
-        assert_raises(sa_exc.InvalidRequestError, q.get, {"i": 1,"j": '2',"k": 3})
+        assert_raises(
+            sa_exc.InvalidRequestError,
+            q.get,
+            {"i": 1, "j": '2', "k": 3}
+        )
 
     def test_get(self):
         User = self.classes.User