]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commit
Update orderinglist annotations, list compatibity
authorMartijn Pieters <mj@zopatista.com>
Mon, 15 Jan 2024 16:10:30 +0000 (16:10 +0000)
committerMartijn Pieters <mj@zopatista.com>
Sun, 24 Nov 2024 20:24:37 +0000 (20:24 +0000)
commit716fbfa7856148b00056c395560debd7061382f1
tree19f3e205985036839f8c49dad7759310ea0c5bd0
parentc3097458d95448d11a6a6bf80add2f933c0c1907
Update orderinglist annotations, list compatibity

- Don't omit the `_T` typevar in `ordering_list` and
  `OrderingList.ordering_func``; type checkers need to understand the
  relationship between the `OrderingList` instance and the ordering
  function connected to it.
- The ordering function can return _any_ value, not just integers
- The `ordering_attr` argument to `OrderingList` is not optional
- Update list methods to accept the same signature as the overridden
  methods, including `SupportsIndex` instead of `int`, an iterable of
  `_T` when using `__setitem__` with a slice (and not just sequences)
  and converting the index value to an integer before passing it to the
  `ordering_func` callable.
- Update `__setitem__` to _not_ attempt to handle slice objects as
  handling all edge cases of slice length and iterable length is very
  tricky and most use of `OrderingList` and slices is handled by
  the SQLAlchemy collections instrumentation anyway.
- Remove the `__setslice__` and `__delslice__` methods, which were
  deprecated in Python 2.6 and removed in Python 3.0.

Fixes #10888
lib/sqlalchemy/ext/orderinglist.py
test/ext/test_orderinglist.py