#2628: types.Variant() has a __repr__ usable by Alembic#9
#2628: types.Variant() has a __repr__ usable by Alembic#9ijl wants to merge 1 commit intozzzeek:masterfrom ijl:master
Conversation
|
This isn't correct. A migration script needs to be just as database agnostic as anything else using SQL constructs, so it is wrong for Ideally, in a migration script, we'd see this: Which kind of means that Alembic itself should really have a hand in doing the reproduction of a Variant, because you'll note it needs to have those dialect namespaces like If the |
|
I see. I misunderstood. Thanks. |
This pull request is meant to fix Trac ticket #2628 'need a working repr for Variant".
Note that generic_repr() now builds kwargs into the repr by looking for a kwargs_signature attribute in the to_inspect object. This complements inspect.getargspec() in building the list of all arguments and whether they are non-default. So any type that accepts kwargs will need to define this attribute in order to have a comprehensive repr. That's something to keep up to date in the future, but the only alternative I saw was to refactor any type using an _arg or *_kwargs into named arguments, which meant backwards-incompatibility for those Enums at the least.
Please see the tests in test_repr().