summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/sql/schema.py
diff options
context:
space:
mode:
authorFederico Caselli <cfederico87@gmail.com>2021-12-27 21:04:54 +0000
committerGerrit Code Review <gerrit@ci3.zzzcomputing.com>2021-12-27 21:04:54 +0000
commitc5b8f2f88bb487ce9bd4aac6173c445fa307ae07 (patch)
treee28194a1edb222b7de87126933c579db53e14bd0 /lib/sqlalchemy/sql/schema.py
parent9eb5e153c93b6a01f16453bd45b4bda9411fb414 (diff)
parent13e6e5608898a2c85751372ba88d357e5b80fe3f (diff)
downloadsqlalchemy-c5b8f2f88bb487ce9bd4aac6173c445fa307ae07.tar.gz
Merge "Replace raise_ with raise from" into main
Diffstat (limited to 'lib/sqlalchemy/sql/schema.py')
-rw-r--r--lib/sqlalchemy/sql/schema.py41
1 files changed, 16 insertions, 25 deletions
diff --git a/lib/sqlalchemy/sql/schema.py b/lib/sqlalchemy/sql/schema.py
index cdd17f2c0..9b5005b5d 100644
--- a/lib/sqlalchemy/sql/schema.py
+++ b/lib/sqlalchemy/sql/schema.py
@@ -120,13 +120,10 @@ class SchemaItem(SchemaEventTarget, visitors.Visitable):
try:
spwd = item._set_parent_with_dispatch
except AttributeError as err:
- util.raise_(
- exc.ArgumentError(
- "'SchemaItem' object, such as a 'Column' or a "
- "'Constraint' expected, got %r" % item
- ),
- replace_context=err,
- )
+ raise exc.ArgumentError(
+ "'SchemaItem' object, such as a 'Column' or a "
+ "'Constraint' expected, got %r" % item
+ ) from err
else:
spwd(self, **kw)
@@ -1932,16 +1929,13 @@ class Column(DialectKWArgs, SchemaItem, ColumnClause):
*fk
)
except TypeError as err:
- util.raise_(
- TypeError(
- "Could not create a copy of this %r object. "
- "Ensure the class includes a _constructor() "
- "attribute or method which accepts the "
- "standard Column constructor arguments, or "
- "references the Column class itself." % self.__class__
- ),
- from_=err,
- )
+ raise TypeError(
+ "Could not create a copy of this %r object. "
+ "Ensure the class includes a _constructor() "
+ "attribute or method which accepts the "
+ "standard Column constructor arguments, or "
+ "references the Column class itself." % self.__class__
+ ) from err
c.table = selectable
c._propagate_attrs = selectable._propagate_attrs
@@ -3647,14 +3641,11 @@ class ForeignKeyConstraint(ColumnCollectionConstraint):
try:
ColumnCollectionConstraint._set_parent(self, table)
except KeyError as ke:
- util.raise_(
- exc.ArgumentError(
- "Can't create ForeignKeyConstraint "
- "on table '%s': no column "
- "named '%s' is present." % (table.description, ke.args[0])
- ),
- from_=ke,
- )
+ raise exc.ArgumentError(
+ "Can't create ForeignKeyConstraint "
+ "on table '%s': no column "
+ "named '%s' is present." % (table.description, ke.args[0])
+ ) from ke
for col, fk in zip(self.columns, self.elements):
if not hasattr(fk, "parent") or fk.parent is not col: