Fixed an internal class that was testing for unexpected attributes to work
correctly under upcoming Python 3.13. Pull request courtesy Edgar
Ramírez-Mondragón.
Fixes: #11334
Closes: #11335
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/11335
Pull-request-sha:
babd703e6e34b93722a54c3adf13aa792d3a03b3
Change-Id: Ia2e7392c9403e25266c7d30b987b577f49d008c0
(cherry picked from commit
eb118e23a29a29469edb4c1927250f4b726de68e)
--- /dev/null
+.. change::
+ :tags: bug, installation
+ :tickets: 11334
+
+ Fixed an internal class that was testing for unexpected attributes to work
+ correctly under upcoming Python 3.13. Pull request courtesy Edgar
+ Ramírez-Mondragón.
return env["set"]
+_dunders = re.compile("^__.+__$")
+
+
class TypingOnly:
"""A mixin class that marks a class as 'typing only', meaning it has
absolutely no methods, attributes, or runtime functionality whatsoever.
def __init_subclass__(cls) -> None:
if TypingOnly in cls.__bases__:
- remaining = set(cls.__dict__).difference(
- {
- "__module__",
- "__doc__",
- "__slots__",
- "__orig_bases__",
- "__annotations__",
- }
- )
+ remaining = {
+ name for name in cls.__dict__ if not _dunders.match(name)
+ }
if remaining:
raise AssertionError(
f"Class {cls} directly inherits TypingOnly but has "