diff options
| author | mike bayer <mike_mp@zzzcomputing.com> | 2022-11-17 14:35:10 +0000 |
|---|---|---|
| committer | Gerrit Code Review <gerrit@ci3.zzzcomputing.com> | 2022-11-17 14:35:10 +0000 |
| commit | 60cc662861232ac40bcfd0461b1b1845b643464a (patch) | |
| tree | 97b8ca4a8e98aa1210bccc6051c60df13585d7c5 /lib/sqlalchemy/dialects/postgresql | |
| parent | 200e70b9745f1f344be4a35bb8f2b5f01b40d467 (diff) | |
| parent | 4eb4ceca36c7ce931ea65ac06d6ed08bf459fc66 (diff) | |
| download | sqlalchemy-60cc662861232ac40bcfd0461b1b1845b643464a.tar.gz | |
Merge "Try running pyupgrade on the code" into main
Diffstat (limited to 'lib/sqlalchemy/dialects/postgresql')
| -rw-r--r-- | lib/sqlalchemy/dialects/postgresql/_psycopg_common.py | 6 | ||||
| -rw-r--r-- | lib/sqlalchemy/dialects/postgresql/array.py | 2 | ||||
| -rw-r--r-- | lib/sqlalchemy/dialects/postgresql/asyncpg.py | 8 | ||||
| -rw-r--r-- | lib/sqlalchemy/dialects/postgresql/base.py | 228 | ||||
| -rw-r--r-- | lib/sqlalchemy/dialects/postgresql/dml.py | 2 | ||||
| -rw-r--r-- | lib/sqlalchemy/dialects/postgresql/ext.py | 2 | ||||
| -rw-r--r-- | lib/sqlalchemy/dialects/postgresql/json.py | 2 | ||||
| -rw-r--r-- | lib/sqlalchemy/dialects/postgresql/named_types.py | 4 | ||||
| -rw-r--r-- | lib/sqlalchemy/dialects/postgresql/psycopg2.py | 2 | ||||
| -rw-r--r-- | lib/sqlalchemy/dialects/postgresql/types.py | 4 |
10 files changed, 125 insertions, 135 deletions
diff --git a/lib/sqlalchemy/dialects/postgresql/_psycopg_common.py b/lib/sqlalchemy/dialects/postgresql/_psycopg_common.py index 92341d2da..4bb1026a5 100644 --- a/lib/sqlalchemy/dialects/postgresql/_psycopg_common.py +++ b/lib/sqlalchemy/dialects/postgresql/_psycopg_common.py @@ -60,15 +60,13 @@ class _PsycopgHStore(HSTORE): if dialect._has_native_hstore: return None else: - return super(_PsycopgHStore, self).bind_processor(dialect) + return super().bind_processor(dialect) def result_processor(self, dialect, coltype): if dialect._has_native_hstore: return None else: - return super(_PsycopgHStore, self).result_processor( - dialect, coltype - ) + return super().result_processor(dialect, coltype) class _PsycopgARRAY(PGARRAY): diff --git a/lib/sqlalchemy/dialects/postgresql/array.py b/lib/sqlalchemy/dialects/postgresql/array.py index 3132e875e..e130eccc2 100644 --- a/lib/sqlalchemy/dialects/postgresql/array.py +++ b/lib/sqlalchemy/dialects/postgresql/array.py @@ -101,7 +101,7 @@ class array(expression.ExpressionClauseList[_T]): def __init__(self, clauses, **kw): type_arg = kw.pop("type_", None) - super(array, self).__init__(operators.comma_op, *clauses, **kw) + super().__init__(operators.comma_op, *clauses, **kw) self._type_tuple = [arg.type for arg in self.clauses] diff --git a/lib/sqlalchemy/dialects/postgresql/asyncpg.py b/lib/sqlalchemy/dialects/postgresql/asyncpg.py index cd161d28e..751dc3dcf 100644 --- a/lib/sqlalchemy/dialects/postgresql/asyncpg.py +++ b/lib/sqlalchemy/dialects/postgresql/asyncpg.py @@ -560,7 +560,7 @@ class AsyncAdapt_asyncpg_ss_cursor(AsyncAdapt_asyncpg_cursor): __slots__ = ("_rowbuffer",) def __init__(self, adapt_connection): - super(AsyncAdapt_asyncpg_ss_cursor, self).__init__(adapt_connection) + super().__init__(adapt_connection) self._rowbuffer = None def close(self): @@ -863,9 +863,7 @@ class AsyncAdapt_asyncpg_dbapi: class InvalidCachedStatementError(NotSupportedError): def __init__(self, message): - super( - AsyncAdapt_asyncpg_dbapi.InvalidCachedStatementError, self - ).__init__( + super().__init__( message + " (SQLAlchemy asyncpg dialect will now invalidate " "all prepared caches in response to this exception)", ) @@ -1095,7 +1093,7 @@ class PGDialect_asyncpg(PGDialect): """ - super_connect = super(PGDialect_asyncpg, self).on_connect() + super_connect = super().on_connect() def connect(conn): conn.await_(self.setup_asyncpg_json_codec(conn)) diff --git a/lib/sqlalchemy/dialects/postgresql/base.py b/lib/sqlalchemy/dialects/postgresql/base.py index 41064de10..99c48fb2f 100644 --- a/lib/sqlalchemy/dialects/postgresql/base.py +++ b/lib/sqlalchemy/dialects/postgresql/base.py @@ -1469,112 +1469,110 @@ from ...util.typing import TypedDict IDX_USING = re.compile(r"^(?:btree|hash|gist|gin|[\w_]+)$", re.I) -RESERVED_WORDS = set( - [ - "all", - "analyse", - "analyze", - "and", - "any", - "array", - "as", - "asc", - "asymmetric", - "both", - "case", - "cast", - "check", - "collate", - "column", - "constraint", - "create", - "current_catalog", - "current_date", - "current_role", - "current_time", - "current_timestamp", - "current_user", - "default", - "deferrable", - "desc", - "distinct", - "do", - "else", - "end", - "except", - "false", - "fetch", - "for", - "foreign", - "from", - "grant", - "group", - "having", - "in", - "initially", - "intersect", - "into", - "leading", - "limit", - "localtime", - "localtimestamp", - "new", - "not", - "null", - "of", - "off", - "offset", - "old", - "on", - "only", - "or", - "order", - "placing", - "primary", - "references", - "returning", - "select", - "session_user", - "some", - "symmetric", - "table", - "then", - "to", - "trailing", - "true", - "union", - "unique", - "user", - "using", - "variadic", - "when", - "where", - "window", - "with", - "authorization", - "between", - "binary", - "cross", - "current_schema", - "freeze", - "full", - "ilike", - "inner", - "is", - "isnull", - "join", - "left", - "like", - "natural", - "notnull", - "outer", - "over", - "overlaps", - "right", - "similar", - "verbose", - ] -) +RESERVED_WORDS = { + "all", + "analyse", + "analyze", + "and", + "any", + "array", + "as", + "asc", + "asymmetric", + "both", + "case", + "cast", + "check", + "collate", + "column", + "constraint", + "create", + "current_catalog", + "current_date", + "current_role", + "current_time", + "current_timestamp", + "current_user", + "default", + "deferrable", + "desc", + "distinct", + "do", + "else", + "end", + "except", + "false", + "fetch", + "for", + "foreign", + "from", + "grant", + "group", + "having", + "in", + "initially", + "intersect", + "into", + "leading", + "limit", + "localtime", + "localtimestamp", + "new", + "not", + "null", + "of", + "off", + "offset", + "old", + "on", + "only", + "or", + "order", + "placing", + "primary", + "references", + "returning", + "select", + "session_user", + "some", + "symmetric", + "table", + "then", + "to", + "trailing", + "true", + "union", + "unique", + "user", + "using", + "variadic", + "when", + "where", + "window", + "with", + "authorization", + "between", + "binary", + "cross", + "current_schema", + "freeze", + "full", + "ilike", + "inner", + "is", + "isnull", + "join", + "left", + "like", + "natural", + "notnull", + "outer", + "over", + "overlaps", + "right", + "similar", + "verbose", +} colspecs = { sqltypes.ARRAY: _array.ARRAY, @@ -1801,7 +1799,7 @@ class PGCompiler(compiler.SQLCompiler): ) def render_literal_value(self, value, type_): - value = super(PGCompiler, self).render_literal_value(value, type_) + value = super().render_literal_value(value, type_) if self.dialect._backslash_escapes: value = value.replace("\\", "\\\\") @@ -2108,14 +2106,12 @@ class PGDDLCompiler(compiler.DDLCompiler): "create_constraint=False on this Enum datatype." ) - text = super(PGDDLCompiler, self).visit_check_constraint(constraint) + text = super().visit_check_constraint(constraint) text += self._define_constraint_validity(constraint) return text def visit_foreign_key_constraint(self, constraint): - text = super(PGDDLCompiler, self).visit_foreign_key_constraint( - constraint - ) + text = super().visit_foreign_key_constraint(constraint) text += self._define_constraint_validity(constraint) return text @@ -2353,9 +2349,7 @@ class PGDDLCompiler(compiler.DDLCompiler): create.element.data_type ) - return super(PGDDLCompiler, self).visit_create_sequence( - create, prefix=prefix, **kw - ) + return super().visit_create_sequence(create, prefix=prefix, **kw) def _can_comment_on_constraint(self, ddl_instance): constraint = ddl_instance.element @@ -2478,7 +2472,7 @@ class PGTypeCompiler(compiler.GenericTypeCompiler): def visit_enum(self, type_, **kw): if not type_.native_enum or not self.dialect.supports_native_enum: - return super(PGTypeCompiler, self).visit_enum(type_, **kw) + return super().visit_enum(type_, **kw) else: return self.visit_ENUM(type_, **kw) @@ -2803,7 +2797,7 @@ class PGExecutionContext(default.DefaultExecutionContext): return self._execute_scalar(exc, column.type) - return super(PGExecutionContext, self).get_insert_default(column) + return super().get_insert_default(column) class PGReadOnlyConnectionCharacteristic( @@ -2945,7 +2939,7 @@ class PGDialect(default.DefaultDialect): self._json_serializer = json_serializer def initialize(self, connection): - super(PGDialect, self).initialize(connection) + super().initialize(connection) # https://www.postgresql.org/docs/9.3/static/release-9-2.html#AEN116689 self.supports_smallserial = self.server_version_info >= (9, 2) diff --git a/lib/sqlalchemy/dialects/postgresql/dml.py b/lib/sqlalchemy/dialects/postgresql/dml.py index b79b4a30e..645bedf17 100644 --- a/lib/sqlalchemy/dialects/postgresql/dml.py +++ b/lib/sqlalchemy/dialects/postgresql/dml.py @@ -266,7 +266,7 @@ class OnConflictDoUpdate(OnConflictClause): set_=None, where=None, ): - super(OnConflictDoUpdate, self).__init__( + super().__init__( constraint=constraint, index_elements=index_elements, index_where=index_where, diff --git a/lib/sqlalchemy/dialects/postgresql/ext.py b/lib/sqlalchemy/dialects/postgresql/ext.py index ebaad2734..b0d8ef345 100644 --- a/lib/sqlalchemy/dialects/postgresql/ext.py +++ b/lib/sqlalchemy/dialects/postgresql/ext.py @@ -243,7 +243,7 @@ class ExcludeConstraint(ColumnCollectionConstraint): self.ops = kw.get("ops", {}) def _set_parent(self, table, **kw): - super(ExcludeConstraint, self)._set_parent(table) + super()._set_parent(table) self._render_exprs = [ ( diff --git a/lib/sqlalchemy/dialects/postgresql/json.py b/lib/sqlalchemy/dialects/postgresql/json.py index a8b03bd48..c68671918 100644 --- a/lib/sqlalchemy/dialects/postgresql/json.py +++ b/lib/sqlalchemy/dialects/postgresql/json.py @@ -221,7 +221,7 @@ class JSON(sqltypes.JSON): .. versionadded:: 1.1 """ - super(JSON, self).__init__(none_as_null=none_as_null) + super().__init__(none_as_null=none_as_null) if astext_type is not None: self.astext_type = astext_type diff --git a/lib/sqlalchemy/dialects/postgresql/named_types.py b/lib/sqlalchemy/dialects/postgresql/named_types.py index f844e9213..79b567f08 100644 --- a/lib/sqlalchemy/dialects/postgresql/named_types.py +++ b/lib/sqlalchemy/dialects/postgresql/named_types.py @@ -31,8 +31,8 @@ class NamedType(sqltypes.TypeEngine): """Base for named types.""" __abstract__ = True - DDLGenerator: Type["NamedTypeGenerator"] - DDLDropper: Type["NamedTypeDropper"] + DDLGenerator: Type[NamedTypeGenerator] + DDLDropper: Type[NamedTypeDropper] create_type: bool def create(self, bind, checkfirst=True, **kw): diff --git a/lib/sqlalchemy/dialects/postgresql/psycopg2.py b/lib/sqlalchemy/dialects/postgresql/psycopg2.py index cb5cab178..5acd50710 100644 --- a/lib/sqlalchemy/dialects/postgresql/psycopg2.py +++ b/lib/sqlalchemy/dialects/postgresql/psycopg2.py @@ -651,7 +651,7 @@ class PGDialect_psycopg2(_PGDialect_common_psycopg): ) def initialize(self, connection): - super(PGDialect_psycopg2, self).initialize(connection) + super().initialize(connection) self._has_native_hstore = ( self.use_native_hstore and self._hstore_oids(connection.connection.dbapi_connection) diff --git a/lib/sqlalchemy/dialects/postgresql/types.py b/lib/sqlalchemy/dialects/postgresql/types.py index 81b677187..72703ff81 100644 --- a/lib/sqlalchemy/dialects/postgresql/types.py +++ b/lib/sqlalchemy/dialects/postgresql/types.py @@ -128,7 +128,7 @@ class TIMESTAMP(sqltypes.TIMESTAMP): .. versionadded:: 1.4 """ - super(TIMESTAMP, self).__init__(timezone=timezone) + super().__init__(timezone=timezone) self.precision = precision @@ -147,7 +147,7 @@ class TIME(sqltypes.TIME): .. versionadded:: 1.4 """ - super(TIME, self).__init__(timezone=timezone) + super().__init__(timezone=timezone) self.precision = precision |
