From: Federico Caselli Date: Fri, 30 May 2025 20:53:59 +0000 (+0200) Subject: Fix type errors surfaced by mypy 1.16 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=68cd3e8ec7098d4bb4b2102ad247f84cd89dfd8c;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git Fix type errors surfaced by mypy 1.16 Change-Id: I50bbd760577ff7c865c81153041e82bba068e5d8 --- diff --git a/lib/sqlalchemy/dialects/mysql/aiomysql.py b/lib/sqlalchemy/dialects/mysql/aiomysql.py index d9828d0a27..26b1424db2 100644 --- a/lib/sqlalchemy/dialects/mysql/aiomysql.py +++ b/lib/sqlalchemy/dialects/mysql/aiomysql.py @@ -166,7 +166,7 @@ class MySQLDialect_aiomysql(MySQLDialect_pymysql): driver = "aiomysql" supports_statement_cache = True - supports_server_side_cursors = True # type: ignore[assignment] + supports_server_side_cursors = True _sscursor = AsyncAdapt_aiomysql_ss_cursor is_async = True diff --git a/lib/sqlalchemy/dialects/mysql/asyncmy.py b/lib/sqlalchemy/dialects/mysql/asyncmy.py index a2e1fffec6..061f48da73 100644 --- a/lib/sqlalchemy/dialects/mysql/asyncmy.py +++ b/lib/sqlalchemy/dialects/mysql/asyncmy.py @@ -153,7 +153,7 @@ class MySQLDialect_asyncmy(MySQLDialect_pymysql): driver = "asyncmy" supports_statement_cache = True - supports_server_side_cursors = True # type: ignore[assignment] + supports_server_side_cursors = True _sscursor = AsyncAdapt_asyncmy_ss_cursor is_async = True diff --git a/lib/sqlalchemy/dialects/mysql/mysqlconnector.py b/lib/sqlalchemy/dialects/mysql/mysqlconnector.py index d36c8924ec..02a961f548 100644 --- a/lib/sqlalchemy/dialects/mysql/mysqlconnector.py +++ b/lib/sqlalchemy/dialects/mysql/mysqlconnector.py @@ -117,13 +117,13 @@ class IdentifierPreparerCommon_mysqlconnector: return value -class MySQLIdentifierPreparer_mysqlconnector( # type:ignore[misc] +class MySQLIdentifierPreparer_mysqlconnector( IdentifierPreparerCommon_mysqlconnector, MySQLIdentifierPreparer ): pass -class MariaDBIdentifierPreparer_mysqlconnector( # type:ignore[misc] +class MariaDBIdentifierPreparer_mysqlconnector( IdentifierPreparerCommon_mysqlconnector, MariaDBIdentifierPreparer ): pass diff --git a/lib/sqlalchemy/dialects/mysql/mysqldb.py b/lib/sqlalchemy/dialects/mysql/mysqldb.py index 14a4c00e4c..8621158823 100644 --- a/lib/sqlalchemy/dialects/mysql/mysqldb.py +++ b/lib/sqlalchemy/dialects/mysql/mysqldb.py @@ -152,7 +152,7 @@ class MySQLDialect_mysqldb(MySQLDialect): return (0, 0, 0) @util.langhelpers.memoized_property - def supports_server_side_cursors(self) -> bool: # type: ignore[override] + def supports_server_side_cursors(self) -> bool: try: cursors = __import__("MySQLdb.cursors").cursors self._sscursor = cursors.SSCursor diff --git a/lib/sqlalchemy/dialects/mysql/pymysql.py b/lib/sqlalchemy/dialects/mysql/pymysql.py index e754bb6fcf..badb431238 100644 --- a/lib/sqlalchemy/dialects/mysql/pymysql.py +++ b/lib/sqlalchemy/dialects/mysql/pymysql.py @@ -75,7 +75,7 @@ class MySQLDialect_pymysql(MySQLDialect_mysqldb): description_encoding = None @langhelpers.memoized_property - def supports_server_side_cursors(self) -> bool: # type: ignore[override] + def supports_server_side_cursors(self) -> bool: try: cursors = __import__("pymysql.cursors").cursors self._sscursor = cursors.SSCursor @@ -115,7 +115,7 @@ class MySQLDialect_pymysql(MySQLDialect_mysqldb): not insp.defaults or insp.defaults[0] is not False ) - def do_ping(self, dbapi_connection: DBAPIConnection) -> Literal[True]: # type: ignore # noqa: E501 + def do_ping(self, dbapi_connection: DBAPIConnection) -> Literal[True]: if self._send_false_to_ping: dbapi_connection.ping(False) else: diff --git a/lib/sqlalchemy/dialects/postgresql/array.py b/lib/sqlalchemy/dialects/postgresql/array.py index cc06d25447..62042c6695 100644 --- a/lib/sqlalchemy/dialects/postgresql/array.py +++ b/lib/sqlalchemy/dialects/postgresql/array.py @@ -396,7 +396,7 @@ class ARRAY(sqltypes.ARRAY[_T]): def _against_native_enum(self) -> bool: return ( isinstance(self.item_type, sqltypes.Enum) - and self.item_type.native_enum # type: ignore[attr-defined] + and self.item_type.native_enum ) def literal_processor( diff --git a/lib/sqlalchemy/dialects/postgresql/ranges.py b/lib/sqlalchemy/dialects/postgresql/ranges.py index 93253570c1..0ce4ea2913 100644 --- a/lib/sqlalchemy/dialects/postgresql/ranges.py +++ b/lib/sqlalchemy/dialects/postgresql/ranges.py @@ -271,9 +271,9 @@ class Range(Generic[_T]): value2 += step value2_inc = False - if value1 < value2: # type: ignore + if value1 < value2: return -1 - elif value1 > value2: # type: ignore + elif value1 > value2: return 1 elif only_values: return 0 diff --git a/lib/sqlalchemy/engine/_processors_cy.py b/lib/sqlalchemy/engine/_processors_cy.py index 16a44841ac..2d9cbab0bc 100644 --- a/lib/sqlalchemy/engine/_processors_cy.py +++ b/lib/sqlalchemy/engine/_processors_cy.py @@ -26,7 +26,7 @@ except ModuleNotFoundError: def _is_compiled() -> bool: """Utility function to indicate if this module is compiled or not.""" - return cython.compiled # type: ignore[no-any-return] + return cython.compiled # type: ignore[no-any-return,unused-ignore] # END GENERATED CYTHON IMPORT diff --git a/lib/sqlalchemy/engine/_row_cy.py b/lib/sqlalchemy/engine/_row_cy.py index 76659e1933..87cf5bfa39 100644 --- a/lib/sqlalchemy/engine/_row_cy.py +++ b/lib/sqlalchemy/engine/_row_cy.py @@ -35,7 +35,7 @@ except ModuleNotFoundError: def _is_compiled() -> bool: """Utility function to indicate if this module is compiled or not.""" - return cython.compiled # type: ignore[no-any-return] + return cython.compiled # type: ignore[no-any-return,unused-ignore] # END GENERATED CYTHON IMPORT diff --git a/lib/sqlalchemy/engine/_util_cy.py b/lib/sqlalchemy/engine/_util_cy.py index 218fcd2b7b..6c45b22ef6 100644 --- a/lib/sqlalchemy/engine/_util_cy.py +++ b/lib/sqlalchemy/engine/_util_cy.py @@ -37,7 +37,7 @@ except ModuleNotFoundError: def _is_compiled() -> bool: """Utility function to indicate if this module is compiled or not.""" - return cython.compiled # type: ignore[no-any-return] + return cython.compiled # type: ignore[no-any-return,unused-ignore] # END GENERATED CYTHON IMPORT diff --git a/lib/sqlalchemy/engine/cursor.py b/lib/sqlalchemy/engine/cursor.py index bff473ac5a..351ccda4c3 100644 --- a/lib/sqlalchemy/engine/cursor.py +++ b/lib/sqlalchemy/engine/cursor.py @@ -1448,15 +1448,15 @@ class _NoResultMetaData(ResultMetaData): self._we_dont_return_rows() @property - def _keymap(self): + def _keymap(self): # type: ignore[override] self._we_dont_return_rows() @property - def _key_to_index(self): + def _key_to_index(self): # type: ignore[override] self._we_dont_return_rows() @property - def _processors(self): + def _processors(self): # type: ignore[override] self._we_dont_return_rows() @property diff --git a/lib/sqlalchemy/engine/default.py b/lib/sqlalchemy/engine/default.py index af087a9eb8..4eb45c1d59 100644 --- a/lib/sqlalchemy/engine/default.py +++ b/lib/sqlalchemy/engine/default.py @@ -481,7 +481,7 @@ class DefaultDialect(Dialect): return weakref.WeakKeyDictionary() @property - def dialect_description(self): + def dialect_description(self): # type: ignore[override] return self.name + "+" + self.driver @property @@ -1632,7 +1632,7 @@ class DefaultExecutionContext(ExecutionContext): return "unknown" @property - def executemany(self): + def executemany(self): # type: ignore[override] return self.execute_style in ( ExecuteStyle.EXECUTEMANY, ExecuteStyle.INSERTMANYVALUES, @@ -1846,6 +1846,7 @@ class DefaultExecutionContext(ExecutionContext): if self._rowcount is None and exec_opt.get("preserve_rowcount", False): self._rowcount = self.cursor.rowcount + yp: Optional[Union[int, bool]] if self.is_crud or self.is_text: result = self._setup_dml_or_text_result() yp = False diff --git a/lib/sqlalchemy/ext/mutable.py b/lib/sqlalchemy/ext/mutable.py index 4e69a548d7..7ba1c0bf1a 100644 --- a/lib/sqlalchemy/ext/mutable.py +++ b/lib/sqlalchemy/ext/mutable.py @@ -524,6 +524,7 @@ class MutableBase: if val is not None: if coerce: val = cls.coerce(key, val) + assert val is not None state.dict[key] = val val._parents[state] = key diff --git a/lib/sqlalchemy/orm/attributes.py b/lib/sqlalchemy/orm/attributes.py index 952140575d..e8886a1181 100644 --- a/lib/sqlalchemy/orm/attributes.py +++ b/lib/sqlalchemy/orm/attributes.py @@ -631,11 +631,11 @@ def _create_proxied_attribute( self._doc = self.__doc__ = doc @property - def _parententity(self): + def _parententity(self): # type: ignore[override] return inspection.inspect(self.class_, raiseerr=False) @property - def parent(self): + def parent(self): # type: ignore[override] return inspection.inspect(self.class_, raiseerr=False) _is_internal_proxy = True diff --git a/lib/sqlalchemy/orm/decl_base.py b/lib/sqlalchemy/orm/decl_base.py index d1b6e74b03..ea01312d3c 100644 --- a/lib/sqlalchemy/orm/decl_base.py +++ b/lib/sqlalchemy/orm/decl_base.py @@ -1998,8 +1998,7 @@ class _DeferredMapperConfig(_ClassScanMapperConfig): def _early_mapping(self, mapper_kw: _MapperKwArgs) -> None: pass - # mypy disallows plain property override of variable - @property # type: ignore + @property def cls(self) -> Type[Any]: return self._cls() # type: ignore diff --git a/lib/sqlalchemy/orm/mapper.py b/lib/sqlalchemy/orm/mapper.py index 64368af7c9..2f8bebee51 100644 --- a/lib/sqlalchemy/orm/mapper.py +++ b/lib/sqlalchemy/orm/mapper.py @@ -1032,7 +1032,7 @@ class Mapper( """ - primary_key: Tuple[Column[Any], ...] + primary_key: Tuple[ColumnElement[Any], ...] """An iterable containing the collection of :class:`_schema.Column` objects which comprise the 'primary key' of the mapped table, from the @@ -2487,7 +2487,7 @@ class Mapper( if spec == "*": mappers = list(self.self_and_descendants) elif spec: - mapper_set = set() + mapper_set: Set[Mapper[Any]] = set() for m in util.to_list(spec): m = _class_to_mapper(m) if not m.isa(self): @@ -3371,9 +3371,11 @@ class Mapper( return self.class_manager.mapper.base_mapper def _result_has_identity_key(self, result, adapter=None): - pk_cols: Sequence[ColumnClause[Any]] = self.primary_key - if adapter: - pk_cols = [adapter.columns[c] for c in pk_cols] + pk_cols: Sequence[ColumnElement[Any]] + if adapter is not None: + pk_cols = [adapter.columns[c] for c in self.primary_key] + else: + pk_cols = self.primary_key rk = result.keys() for col in pk_cols: if col not in rk: @@ -3398,9 +3400,11 @@ class Mapper( for the "row" argument """ - pk_cols: Sequence[ColumnClause[Any]] = self.primary_key - if adapter: - pk_cols = [adapter.columns[c] for c in pk_cols] + pk_cols: Sequence[ColumnElement[Any]] + if adapter is not None: + pk_cols = [adapter.columns[c] for c in self.primary_key] + else: + pk_cols = self.primary_key mapping: RowMapping if hasattr(row, "_mapping"): diff --git a/lib/sqlalchemy/orm/properties.py b/lib/sqlalchemy/orm/properties.py index 81d6d8fd12..3afb6e140a 100644 --- a/lib/sqlalchemy/orm/properties.py +++ b/lib/sqlalchemy/orm/properties.py @@ -239,7 +239,7 @@ class ColumnProperty( return self.strategy._have_default_expression # type: ignore return ("deferred", True) not in self.strategy_key or ( - self not in self.parent._readonly_props # type: ignore + self not in self.parent._readonly_props ) @util.preload_module("sqlalchemy.orm.state", "sqlalchemy.orm.strategies") diff --git a/lib/sqlalchemy/orm/relationships.py b/lib/sqlalchemy/orm/relationships.py index b6c4cc5772..481af4f360 100644 --- a/lib/sqlalchemy/orm/relationships.py +++ b/lib/sqlalchemy/orm/relationships.py @@ -533,8 +533,7 @@ class RelationshipProperty( else: self._overlaps = () - # mypy ignoring the @property setter - self.cascade = cascade # type: ignore + self.cascade = cascade if back_populates: if backref: diff --git a/lib/sqlalchemy/orm/util.py b/lib/sqlalchemy/orm/util.py index cf3d8772cc..eb8472993a 100644 --- a/lib/sqlalchemy/orm/util.py +++ b/lib/sqlalchemy/orm/util.py @@ -1561,7 +1561,7 @@ class Bundle( _propagate_attrs: _PropagateAttrsType = util.immutabledict() - proxy_set = util.EMPTY_SET # type: ignore + proxy_set = util.EMPTY_SET exprs: List[_ColumnsClauseElement] diff --git a/lib/sqlalchemy/orm/writeonly.py b/lib/sqlalchemy/orm/writeonly.py index 9a0193e9fa..347d0d92da 100644 --- a/lib/sqlalchemy/orm/writeonly.py +++ b/lib/sqlalchemy/orm/writeonly.py @@ -237,15 +237,11 @@ class _WriteOnlyAttributeImpl( return _DynamicCollectionAdapter(data) # type: ignore[return-value] @util.memoized_property - def _append_token( # type:ignore[override] - self, - ) -> attributes.AttributeEventToken: + def _append_token(self) -> attributes.AttributeEventToken: return attributes.AttributeEventToken(self, attributes.OP_APPEND) @util.memoized_property - def _remove_token( # type:ignore[override] - self, - ) -> attributes.AttributeEventToken: + def _remove_token(self) -> attributes.AttributeEventToken: return attributes.AttributeEventToken(self, attributes.OP_REMOVE) def fire_append_event( diff --git a/lib/sqlalchemy/pool/impl.py b/lib/sqlalchemy/pool/impl.py index 0bfcb6e7d3..d57a2dee46 100644 --- a/lib/sqlalchemy/pool/impl.py +++ b/lib/sqlalchemy/pool/impl.py @@ -60,7 +60,7 @@ class QueuePool(Pool): """ - _is_asyncio = False # type: ignore[assignment] + _is_asyncio = False _queue_class: Type[sqla_queue.QueueCommon[ConnectionPoolEntry]] = ( sqla_queue.Queue @@ -267,7 +267,7 @@ class AsyncAdaptedQueuePool(QueuePool): """ - _is_asyncio = True # type: ignore[assignment] + _is_asyncio = True _queue_class: Type[sqla_queue.QueueCommon[ConnectionPoolEntry]] = ( sqla_queue.AsyncAdaptedQueue ) @@ -350,7 +350,7 @@ class SingletonThreadPool(Pool): """ - _is_asyncio = False # type: ignore[assignment] + _is_asyncio = False def __init__( self, diff --git a/lib/sqlalchemy/sql/_util_cy.py b/lib/sqlalchemy/sql/_util_cy.py index 101d1d102e..c8d303d359 100644 --- a/lib/sqlalchemy/sql/_util_cy.py +++ b/lib/sqlalchemy/sql/_util_cy.py @@ -30,7 +30,7 @@ except ModuleNotFoundError: def _is_compiled() -> bool: """Utility function to indicate if this module is compiled or not.""" - return cython.compiled # type: ignore[no-any-return] + return cython.compiled # type: ignore[no-any-return,unused-ignore] # END GENERATED CYTHON IMPORT diff --git a/lib/sqlalchemy/sql/coercions.py b/lib/sqlalchemy/sql/coercions.py index 057d7a0a2d..5cb74948bd 100644 --- a/lib/sqlalchemy/sql/coercions.py +++ b/lib/sqlalchemy/sql/coercions.py @@ -852,7 +852,7 @@ class InElementImpl(RoleImpl): ) @util.preload_module("sqlalchemy.sql.elements") - def _literal_coercion(self, element, *, expr, operator, **kw): + def _literal_coercion(self, element, *, expr, operator, **kw): # type: ignore[override] # noqa: E501 if util.is_non_string_iterable(element): non_literal_expressions: Dict[ Optional[_ColumnExpressionArgument[Any]], diff --git a/lib/sqlalchemy/sql/compiler.py b/lib/sqlalchemy/sql/compiler.py index 1961623ab5..c0de5f4300 100644 --- a/lib/sqlalchemy/sql/compiler.py +++ b/lib/sqlalchemy/sql/compiler.py @@ -4205,7 +4205,7 @@ class SQLCompiler(Compiled): if self.preparer._requires_quotes(cte_name): cte_name = self.preparer.quote(cte_name) text += self.get_render_as_alias_suffix(cte_name) - return text + return text # type: ignore[no-any-return] else: return self.preparer.format_alias(cte, cte_name) @@ -6363,7 +6363,7 @@ class SQLCompiler(Compiled): self.stack.pop(-1) - return text + return text # type: ignore[no-any-return] def delete_extra_from_clause( self, delete_stmt, from_table, extra_froms, from_hints, **kw diff --git a/lib/sqlalchemy/sql/ddl.py b/lib/sqlalchemy/sql/ddl.py index 5487a170ea..d6bd57d1b7 100644 --- a/lib/sqlalchemy/sql/ddl.py +++ b/lib/sqlalchemy/sql/ddl.py @@ -439,7 +439,7 @@ class _CreateDropBase(ExecutableDDLElement, Generic[_SI]): self._ddl_if = getattr(element, "_ddl_if", None) @property - def stringify_dialect(self): + def stringify_dialect(self): # type: ignore[override] assert not isinstance(self.element, str) return self.element.create_drop_stringify_dialect diff --git a/lib/sqlalchemy/sql/elements.py b/lib/sqlalchemy/sql/elements.py index 50afac284b..4c75936b58 100644 --- a/lib/sqlalchemy/sql/elements.py +++ b/lib/sqlalchemy/sql/elements.py @@ -463,7 +463,7 @@ class ClauseElement( return self @property - def _constructor(self): + def _constructor(self): # type: ignore[override] """return the 'constructor' for this ClauseElement. This is for the purposes for creating a new object of @@ -698,6 +698,7 @@ class ClauseElement( else: elem_cache_key = None + extracted_params: Optional[Sequence[BindParameter[Any]]] if elem_cache_key is not None: if TYPE_CHECKING: assert compiled_cache is not None @@ -2327,7 +2328,7 @@ class TextClause( _allow_label_resolve = False @property - def _is_star(self): + def _is_star(self): # type: ignore[override] return self.text == "*" def __init__(self, text: str): @@ -4867,11 +4868,11 @@ class Label(roles.LabeledColumnExprRole[_T], NamedColumn[_T]): return self @property - def primary_key(self): + def primary_key(self): # type: ignore[override] return self.element.primary_key @property - def foreign_keys(self): + def foreign_keys(self): # type: ignore[override] return self.element.foreign_keys def _copy_internals( @@ -5004,7 +5005,7 @@ class ColumnClause( _is_multiparam_column = False @property - def _is_star(self): + def _is_star(self): # type: ignore[override] return self.is_literal and self.name == "*" def __init__( diff --git a/lib/sqlalchemy/sql/lambdas.py b/lib/sqlalchemy/sql/lambdas.py index ce755c1f83..21c69fed5a 100644 --- a/lib/sqlalchemy/sql/lambdas.py +++ b/lib/sqlalchemy/sql/lambdas.py @@ -300,7 +300,9 @@ class LambdaElement(elements.ClauseElement): while lambda_element is not None: rec = lambda_element._rec if rec.bindparam_trackers: - tracker_instrumented_fn = rec.tracker_instrumented_fn + tracker_instrumented_fn = ( + rec.tracker_instrumented_fn # type:ignore [union-attr] # noqa: E501 + ) for tracker in rec.bindparam_trackers: tracker( lambda_element.fn, @@ -602,7 +604,7 @@ class StatementLambdaElement( return self._rec_expected_expr @property - def _with_options(self): + def _with_options(self): # type: ignore[override] return self._proxied._with_options @property @@ -610,7 +612,7 @@ class StatementLambdaElement( return self._proxied._effective_plugin_target @property - def _execution_options(self): + def _execution_options(self): # type: ignore[override] return self._proxied._execution_options @property @@ -618,27 +620,27 @@ class StatementLambdaElement( return self._proxied._all_selected_columns @property - def is_select(self): + def is_select(self): # type: ignore[override] return self._proxied.is_select @property - def is_update(self): + def is_update(self): # type: ignore[override] return self._proxied.is_update @property - def is_insert(self): + def is_insert(self): # type: ignore[override] return self._proxied.is_insert @property - def is_text(self): + def is_text(self): # type: ignore[override] return self._proxied.is_text @property - def is_delete(self): + def is_delete(self): # type: ignore[override] return self._proxied.is_delete @property - def is_dml(self): + def is_dml(self): # type: ignore[override] return self._proxied.is_dml def spoil(self) -> NullLambdaStatement: diff --git a/lib/sqlalchemy/sql/schema.py b/lib/sqlalchemy/sql/schema.py index 7f5f5e346e..079fac98cc 100644 --- a/lib/sqlalchemy/sql/schema.py +++ b/lib/sqlalchemy/sql/schema.py @@ -477,7 +477,7 @@ class Table( table.dispatch.before_parent_attach(table, metadata) metadata._add_table(name, schema, table) try: - table.__init__(name, metadata, *args, _no_init=False, **kw) + table.__init__(name, metadata, *args, _no_init=False, **kw) # type: ignore[misc] # noqa: E501 table.dispatch.after_parent_attach(table, metadata) return table except Exception: @@ -2239,7 +2239,7 @@ class Column(DialectKWArgs, SchemaItem, ColumnClause[_T]): return _DefaultDescriptionTuple._from_column_default(self.onupdate) @util.memoized_property - def _gen_static_annotations_cache_key(self) -> bool: # type: ignore + def _gen_static_annotations_cache_key(self) -> bool: """special attribute used by cache key gen, if true, we will use a static cache key for the annotations dictionary, else we will generate a new cache key for annotations each time. diff --git a/lib/sqlalchemy/sql/sqltypes.py b/lib/sqlalchemy/sql/sqltypes.py index 7582df72f9..37b124dae7 100644 --- a/lib/sqlalchemy/sql/sqltypes.py +++ b/lib/sqlalchemy/sql/sqltypes.py @@ -1678,14 +1678,14 @@ class Enum(String, SchemaType, Emulated, TypeEngine[Union[str, enum.Enum]]): ) @property - def sort_key_function(self): + def sort_key_function(self): # type: ignore[override] if self._sort_key_function is NO_ARG: return self._db_value_for_elem else: return self._sort_key_function @property - def native(self): + def native(self): # type: ignore[override] return self.native_enum def _db_value_for_elem(self, elem): @@ -2762,7 +2762,7 @@ class JSON(Indexable, TypeEngine[Any]): comparator_factory = Comparator - @property # type: ignore # mypy property bug + @property def should_evaluate_none(self): """Alias of :attr:`_types.JSON.none_as_null`""" return not self.none_as_null @@ -3709,7 +3709,7 @@ class Uuid(Emulated, TypeEngine[_UUID_RETURN]): return _python_UUID if self.as_uuid else str @property - def native(self): + def native(self): # type: ignore[override] return self.native_uuid def coerce_compared_value(self, op, value): diff --git a/lib/sqlalchemy/util/_collections_cy.py b/lib/sqlalchemy/util/_collections_cy.py index 9708402d39..77cea0bb3b 100644 --- a/lib/sqlalchemy/util/_collections_cy.py +++ b/lib/sqlalchemy/util/_collections_cy.py @@ -37,7 +37,7 @@ except ModuleNotFoundError: def _is_compiled() -> bool: """Utility function to indicate if this module is compiled or not.""" - return cython.compiled # type: ignore[no-any-return] + return cython.compiled # type: ignore[no-any-return,unused-ignore] # END GENERATED CYTHON IMPORT diff --git a/lib/sqlalchemy/util/_immutabledict_cy.py b/lib/sqlalchemy/util/_immutabledict_cy.py index efc477b321..5eb018fbdb 100644 --- a/lib/sqlalchemy/util/_immutabledict_cy.py +++ b/lib/sqlalchemy/util/_immutabledict_cy.py @@ -30,7 +30,7 @@ except ModuleNotFoundError: def _is_compiled() -> bool: """Utility function to indicate if this module is compiled or not.""" - return cython.compiled # type: ignore[no-any-return] + return cython.compiled # type: ignore[no-any-return,unused-ignore] # END GENERATED CYTHON IMPORT diff --git a/test/typing/plain_files/orm/mapped_covariant.py b/test/typing/plain_files/orm/mapped_covariant.py index 0b65073fde..9eca6e9593 100644 --- a/test/typing/plain_files/orm/mapped_covariant.py +++ b/test/typing/plain_files/orm/mapped_covariant.py @@ -21,7 +21,10 @@ from sqlalchemy.sql.elements import SQLCoreOperations class ParentProtocol(Protocol): - name: Mapped[str] + # Read-only for simplicity, mutable protocol members are complicated, + # see https://mypy.readthedocs.io/en/latest/common_issues.html#covariant-subtyping-of-mutable-protocol-members-is-rejected + @property + def name(self) -> Mapped[str]: ... class ChildProtocol(Protocol): diff --git a/tools/cython_imports.py b/tools/cython_imports.py index c1b1a8c9c1..81778d6b5a 100644 --- a/tools/cython_imports.py +++ b/tools/cython_imports.py @@ -27,7 +27,7 @@ except ModuleNotFoundError: def _is_compiled() -> bool: """Utility function to indicate if this module is compiled or not.""" - return cython.compiled # type: ignore[no-any-return] + return cython.compiled # type: ignore[no-any-return,unused-ignore] # END GENERATED CYTHON IMPORT\