schemainspect icon indicating copy to clipboard operation
schemainspect copied to clipboard

Allow newlines in function definitions to be ignored

Open pferreir opened this issue 5 years ago • 3 comments

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.

pferreir avatar Dec 10 '19 11:12 pferreir

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?

djrobstep avatar Dec 12 '19 00:12 djrobstep

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 😉).

pferreir avatar Dec 13 '19 15:12 pferreir

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.

djrobstep avatar Dec 14 '19 11:12 djrobstep