From 37955a52995cdbb66a9d5835c20ee58fb98ddffc Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Wed, 21 Mar 2018 09:59:46 -0400 Subject: Don't warn for mixin-based __table_args__, __mapper_args__ declared_attr Removed a warning that would be emitted when calling upon ``__table_args__``, ``__mapper_args__`` as named with a ``@declared_attr`` method, when called from a non-mapped declarative mixin. Calling these directly is documented as the approach to use when one is overidding one of these methods on a mapped class. The warning still emits for regular attribute names. Change-Id: Iae7ed0bd625a2c163c910aa777cef4779128580a Fixes: #4221 --- lib/sqlalchemy/ext/declarative/api.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'lib/sqlalchemy') diff --git a/lib/sqlalchemy/ext/declarative/api.py b/lib/sqlalchemy/ext/declarative/api.py index 77a03bc4a..b08d3ce30 100644 --- a/lib/sqlalchemy/ext/declarative/api.py +++ b/lib/sqlalchemy/ext/declarative/api.py @@ -17,6 +17,7 @@ from ...util import OrderedDict, hybridmethod, hybridproperty from ... import util from ... import exc import weakref +import re from .base import _as_declarative, \ _declarative_constructor,\ @@ -189,8 +190,8 @@ class declared_attr(interfaces._MappedAttribute, property): def __get__(desc, self, cls): reg = cls.__dict__.get('_sa_declared_attr_reg', None) if reg is None: - manager = attributes.manager_of_class(cls) - if manager is None: + if not re.match(r'^__.+__$', desc.fget.__name__) and \ + attributes.manager_of_class(cls) is None: util.warn( "Unmanaged access of declarative attribute %s from " "non-mapped class %s" % -- cgit v1.2.1