Repository navigation
|
The Python what a neat pattern! so neat that when I saw this, I obviously assumed it was a standard Python idiom and it's what you see in SQLAlchemy's hybrid documentation, it works great and everybody uses it. However, when those of us outside of batteries included land try to use this pattern with tools like Mypy or Pyright, they give us the There's obviously several workarounds here, including This is sort of ugly, but if that's the state of things, it is what it is. If that's the best that can be done, I will proceed to be rewriting all my documentation examples to use a form more like the above that is type-checker friendly. questions:
thanks as always for all the great help I'm getting on these questions! |
Replies: 2 comments 10 replies
I don't like this, because making a property read-only will no longer be simple as deleting the setter. It would be much better to get this fixed in mypy. But in my experience, mypy issues don't get fixed unless you're willing to fix things yourself :) If mypy isn't getting fixed any time soon, I would probably use |
|
If your property is very very similar to |
@propertyis hard-coded in the tools. It's unfortunate and creates several different kinds of issues for custom property classes and property-like classes. There have been attempts to reduce the special-casing, such as python/typeshed#5987.@propertyis problematic, and making your own to replace it is fine.baris decorated with@bar.something, without checking whether the first defini…