]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
Fix Python 3.8 SyntaxWarning: "is not" with a literal
authorAnders Kaseorg <andersk@mit.edu>
Thu, 24 Oct 2019 18:27:57 +0000 (14:27 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Sat, 26 Oct 2019 14:02:26 +0000 (10:02 -0400)
Fixes this warning from Python 3.8 in `Query._set_entities`:

```
lib/sqlalchemy/orm/query.py:179: SyntaxWarning: "is not" with a literal. Did you mean "!="?
  if entities is not ():
```

Fixes #4938.

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: #4939
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/4939
Pull-request-sha: 88167460ced7f576a9aed3d0ff0a6e7e18810004

Change-Id: I21464c3e69b4db6307db99f9ccb9b34bbac4e744
(cherry picked from commit 4b61b81dba8d90165d764050d9466b286c7a80f2)

lib/sqlalchemy/orm/query.py

index 5998f57758dd45f3700411b27d22829d59b820c9..1ee68b7685e6e79851d257fb8864ec1305b8741f 100644 (file)
@@ -189,11 +189,7 @@ class Query(object):
         # 4. can't do "if entities" because users make use of undocumented
         #    to_list() behavior here and they pass clause expressions that
         #    can't be evaluated as boolean.  See issue #4269.
-        # 5. the empty tuple is a singleton in cPython, take advantage of this
-        #    so that we can skip for the empty "*entities" case without using
-        #    any Python overloadable operators.
-        #
-        if entities is not ():
+        if entities != ():
             for ent in util.to_list(entities):
                 entity_wrapper(self, ent)