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

Insert an empty line after __future__ imports (Prop#216979) #24

Open
rsaim opened this issue Jul 4, 2019 · 2 comments
Open

Insert an empty line after __future__ imports (Prop#216979) #24

rsaim opened this issue Jul 4, 2019 · 2 comments
Assignees
Labels
Harder Issue will require a lot of work to fix

Comments

@rsaim
Copy link
Collaborator

rsaim commented Jul 4, 2019

$ cat -n /var/tmp/test.py
     1  from __future__ import absolute_import
     2
     3  os
     4  sys


$ tidy-imports -r /var/tmp/test.py
[PYFLYBY] /var/tmp/test.py: added 'import os'
[PYFLYBY] /var/tmp/test.py: added 'import sys'
[PYFLYBY] /var/tmp/test.py: added mandatory 'from __future__ import division'
[PYFLYBY] /var/tmp/test.py: *** modified ***


$ cat -n /var/tmp/test.py
     1  from __future__ import absolute_import, division
     2  import os
     3  import sys
     4
     5  os
     6  sys

I guess we should insert an empty line in-between line 1 and 2.

-Saim

@quarl quarl added this to the M1 milestone Aug 15, 2019
@asmeurer
Copy link
Collaborator

It does the right thing if the __future__ import isn't there yet and it adds it as part of mandatory imports. The reason is when it tries to find an existing block to add the import to in https://github.com/pyflyby/pyflyby/blob/8f83d2f2335419512a8f3d72f21186d4a4a975e0/lib/python/pyflyby/_imports2s.py#L143 it adds a new block if the importing being added is __future__ but it doesn't filter out existing imports that are __future__.

I think it would be easiest to fix this as part of #13. Though we could add a quick fix to filter out __future__ imports in that function completely, if this is a high priority thing to fix (#13 will take longer to fix).

@asmeurer asmeurer added the Harder Issue will require a lot of work to fix label Jan 13, 2020
@sac111gp
Copy link
Collaborator

Internal ticket: Prop#216979

@sac111gp sac111gp changed the title Insert an empty line after __future__ imports. Insert an empty line after __future__ imports (Prop#216979) Feb 16, 2022
@Carreau Carreau self-assigned this Nov 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Harder Issue will require a lot of work to fix
Projects
None yet
Development

No branches or pull requests

5 participants