schemainspect
schemainspect copied to clipboard
Allow newlines in function definitions to be ignored
This is the companion to https://github.com/djrobstep/migra/pull/105. I'm not sure whether this is the best approach, I confess I'm not a fan of is_equal
and the awkward it and __eq__
call each other, but I can't think of a better solution.
Awesome, thanks so much for this!
I'm wondering if it might be slightly cleaner to contain the newline-normalization stuff entirely within the inspection objects?
So it would work like:
i = get_inspector(session)
i.normalize_newlines() # this goes through and normalizes the endings on each inspectedfunction object
That way there's no need to change the equality logic at all, or propagate the option further than the Migration
constructor.
The downside is it's changing the inspected definitions which conceptually feels mildly wrong.
What do you think?
Indeed "mutating" the definitions doesn't seem ideal. And you're right that propagating the option is not ideal either. I have no problem in changing approach, but you for sure have a better idea of what the API should look like (and it's your project after all 😉).
Cool cool. After reflecting on it I think multiple definitions of equality is a fraught path to go down.. I think adding a i.normalize_function_definition_newlines()
or similar is the way to go as the downsides of mutating the definitions are minimal.