]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commit
Don't emit warnings on descriptor access
authorMike Bayer <mike_mp@zzzcomputing.com>
Fri, 20 Nov 2020 15:12:18 +0000 (10:12 -0500)
committerMike Bayer <mike_mp@zzzcomputing.com>
Fri, 20 Nov 2020 19:14:30 +0000 (14:14 -0500)
commit3241e3ca728c883adb4f8e859c77168c3361d957
treedf8b0d3a65727877a303cb9dc7f0eb126356fa2a
parent2720413f1ab0953608443b734726922d292b2930
Don't emit warnings on descriptor access

This commit is revising 5162f2bc5fc0ac239f26a76fc9f0c2, which
when I did it felt a little rushed but I couldn't find anything
wrong.  Well here we are :).

Fixed issue where a :class:`.RemovedIn20Warning` would erroneously emit
when the ``.bind`` attribute were accessed internally on objects,
particularly when stringifying a SQL construct.

Alter the deprecated() decorator so that we can use it just to add
docstring warnings but not actually warn when the function is
accessed, adding new argument enable_warnings that can be
set to False.

Added a safety feature to deprecated_20() that will disallow an
":attr:" from proceeding if enable_warnings=False isn't present,
unless there's an extra flag
warn_on_attribute_access, since we want Session.transaction to
emit a deprecation warning.  This is a little hacky but it's essentially
modifying the decorator to require a positive assertion that
a deprecation decorator on a descriptor should actually warn
on access.

Remove the warning filter for session.transaction and get
tests to pass to ensure this is not also being called
internally.

Added tests to ensure that common places .bind can be passed
as a parameter definitely warn as I was not able to find
this otherwise.

Fixes: #5717
Change-Id: Ia586b4f9ee6b212f3a71104b1caf40b5edd399e2
13 files changed:
doc/build/changelog/unreleased_14/5717.rst [new file with mode: 0644]
lib/sqlalchemy/orm/session.py
lib/sqlalchemy/sql/base.py
lib/sqlalchemy/sql/selectable.py
lib/sqlalchemy/testing/warnings.py
lib/sqlalchemy/util/deprecations.py
test/aaa_profiling/test_orm.py
test/orm/test_bind.py
test/orm/test_deprecations.py
test/orm/test_session.py
test/orm/test_transaction.py
test/orm/test_unitofwork.py
test/sql/test_deprecations.py