Supporting __get__ and __set__ on Column object
See original GitHub issueThe old sqlalchemy-stubs from dropbox included an approximation for the behavior of mapped classes using declarative setup, that is
class Foo(Model):
a = Column(DateTime)
Foo.a
# type is Column[DateTime]
Foo().a
# type is datetime
They did so by defining the get method on Column here: https://github.com/dropbox/sqlalchemy-stubs/blob/master/sqlalchemy-stubs/sql/schema.pyi#L131
Maybe the same can be done for set, so that
Foo().a = 3
# wrong type, expected datetime object
Of course the whole thing is supported already when using the mypy plugin, but for example when using pylance (vscode type engine) which does not support plugins, it gets confused when using and assigning object values as mapped columns and complains about mismatching types.
I think the same is done on relationship() property
I’m unsure of the deeper implications of adding such type hints, though
Issue Analytics
- State:
- Created 2 years ago
- Reactions:2
- Comments:108 (87 by maintainers)
Top Results From Across the Web
Column object (ADOX) - Microsoft Learn
Access provider-specific properties with the Properties collection. Note. Not all properties of Column objects may be supported by your data ...
Read more >ResultSet (Java Platform SE 7 ) - Oracle Help Center
Gets the value of the designated column in the current row of this ResultSet object as an Object in the Java programming language....
Read more >Object Tagging - Snowflake Documentation
The following table lists the supported objects for tags, including columns, based on the Snowflake securable object hierarchy. A tag can be set...
Read more >SQL Server Table Valued Parameter column is not supported ...
Have you tried converting the values to object type before you pass them to DataRow item? – Engin. Jul 29, 2015 at 18:15....
Read more >Table (Guava: Google Core Libraries for Java 19.0 API)
When modification isn't supported, those methods will throw an ... Returns a set of column keys that have one or more values in...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
hi can folks here review this proposed new API / syntax? This adds a new import space “m” that has new symbols that handle typing correctly, without any lying and without the need for plugins (plugin still needed for Base class and
__init__
method). this proposal would be a new system that would be soft roll out in 1.4 and then in 2.0 would be much more prominent. Where possible, it determines the python type from the SQL type (yes, that is doable). For relationships, it works the other way around by default since we usually need an annotation like “List[X]” or similar and that can’t be passed as an argument. The gerrit and PR will be updated momentarily with the initial POC for this. it’s an all new thing and would need new tests, new docs , etc, the whole deal. but it doesn’t impact anything currently present whatsoever so has no backwards incompatibility of any kind.sure just apply the same trick to relationship, like this works