Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow newlines in function definitions to be ignored #37

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

pferreir
Copy link

This is the companion to djrobstep/migra#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.

@djrobstep
Copy link
Owner

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?

@pferreir
Copy link
Author

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

@djrobstep
Copy link
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants