Ticket #404 (closed enhancement: fixed)

Opened 6 years ago

Last modified 6 years ago

Generated migrations contain lines with trailing whitespace

Reported by: dpmcgee@… Owned by: andrew
Priority: minor Milestone: 0.7.1
Component: migrations Version: 0.7
Keywords: Cc:


If you have certain commit hooks enabled to check for clean patches, it gets annoying to have to edit the auto-generated migrations every time to fix this. Patch attached; not too complex to fix.


remove-trailing-whitespace.patch (1.1 KB) - added by dpmcgee@… 6 years ago.

Change History

Changed 6 years ago by dpmcgee@…

comment:1 Changed 6 years ago by andrew

  • Status changed from new to assigned
  • Milestone set to 0.7.1

Surely this is a matter of taste? I always leave whitespace there in my code, since I like to keep the indentation, and "making it fit our coding guidelines" is not entirely a good enough reason to apply this.

Can you not just post-process the migrations files with:

"\n".join(line.rstrip() for line in code)


comment:2 Changed 6 years ago by dpmcgee@…

Interesting, I hadn't foreseen any objection to this. :)

Post-processing is not that tough, I've just never had an editor that didn't re-indent the line if it needed it, or left 4 spaces behind on those lines that didn't have actual code. Given that this is auto-generated code and in large part can be left alone, it would seem advantageous to not have whitespace-only lines for those people that use the git pre-commit whitespace hook, for example.

For those not using it, the net effect of this patch is zero unless you are editing the migration. At that point, since an editor has been opened, can't the space issues be left up to the developer? Anything added or changed from there on out will abide by the local preference.

comment:3 Changed 6 years ago by andrew

  • Status changed from assigned to closed
  • Resolution set to fixed

This is python, whitespace is a topic dear to our hearts!

In this case, I see no concrete downsides to removing the spaces there, since there's no checkers that I know of which force you to have whitespace there.

Committed in [a162189b514c].

Note: See TracTickets for help on using tickets.