sqlalchemy2-stubs icon indicating copy to clipboard operation
sqlalchemy2-stubs copied to clipboard

Try to improve hybrid property

Open CaselIT opened this issue 4 years ago • 2 comments

This is a try of using the mikes provided code in hybrids but it does not work propertly. Can you take a look @zzzeek ?

Description

Fixes: #171

Checklist

This pull request is:

  • [ ] A documentation / typographical 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!

CaselIT avatar Sep 01 '21 21:09 CaselIT

it doesnt work, my other recipe must have relied upon the way sqlalchemy-stubs works. feel free to close if theres no other ideas

zzzeek avatar Sep 01 '21 22:09 zzzeek

There is an issue also with the current version in master. Like if you try the master branch, with the example in hybrid.py you get this:

obj = SomeModel()
reveal_type(obj.hp)
note: Revealed type is "def (*Any, **Any) -> Any"

this is clearly not correct. I think this may be a mypy issue, since pylance (on vscode) does correctly infer the type (to any in master, to the correct return value with this branch)

I'm not sure if the plugin has something to with this tough. Edit: no, removing the plugin definition from setup.cfg does not seem to make any difference

CaselIT avatar Sep 02 '21 07:09 CaselIT