]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commit
Make instrumented attribute covariant as well
authorEthan Langevin <ethan.langevin@anthropic.com>
Mon, 11 Mar 2024 11:41:58 +0000 (07:41 -0400)
committerFederico Caselli <cfederico87@gmail.com>
Tue, 12 Mar 2024 22:14:56 +0000 (23:14 +0100)
commit058e10f2b7e5686198dc744107b32952e55dc93c
tree5c56b13298d81a127297c860fc8ec998a94f1e30
parente560794883c5a3259aa4208ee7c5aa0740cb3087
Make instrumented attribute covariant as well

<!-- Provide a general summary of your proposed changes in the Title field above -->

Allows mapped relationships to use covariant types which makes it possible to define methods that operate on relationships in a typesafe way

### Description

See: https://github.com/sqlalchemy/sqlalchemy/issues/11112 for a more in depth explanation.

Just changed the type parameter in `InstrumentedAttribute` from `_T` to `_T_co`.

### Checklist
<!-- go over following points. check them with an `x` if they do apply, (they turn into clickable checkboxes once the PR is submitted, so no need to do everything at once)

-->

This pull request is:

- [ ] A documentation / typographical / small typing error fix
- Good to go, no issue or tests are needed
- [x] A short code fix
- please include the issue number, and create an issue if none exists, which
  must include a complete example of the issue.  one line code fixes without an
  issue and demonstration will not be accepted.
- Please include: `Fixes: #<issue number>` in the commit message
- please include tests.   one line code fixes without tests will not be accepted.
- [ ] A new feature implementation
- please include the issue number, and create an issue if none exists, which must
  include a complete example of how the feature would look.
- Please include: `Fixes: #<issue number>` in the commit message
- please include tests.

**Have a nice day!**

Closes: #11113
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/11113
Pull-request-sha: 3c100f28661f3440769175a17c2763ed25f4b83a

Change-Id: Iff715c24f1556d5604dcd33661a0ee7232b9404b
lib/sqlalchemy/orm/attributes.py
test/typing/plain_files/orm/mapped_covariant.py