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

black and isort incompatible with comments in import #772

Closed
tbicr opened this issue Mar 20, 2019 · 3 comments
Closed

black and isort incompatible with comments in import #772

tbicr opened this issue Mar 20, 2019 · 3 comments
Labels
R: duplicate This issue or pull request already exists T: enhancement New feature or request

Comments

@tbicr
Copy link

tbicr commented Mar 20, 2019

> black --safe -S --diff .

import time
 
 import numpy as np
 import pandas
 import scipy.sparse as sp
+
 # from sklearn.grid_search import GridSearchCV
 from sklearn.linear_model import ElasticNet, ElasticNetCV, enet_path

isort config:

[isort]
multi_line_output = 3
include_trailing_comma = True
force_grid_wrap = 0
use_parentheses = True
line_length = 100
combine_as_imports = True
sections = FUTURE,STDLIB,THIRDPARTY,FIRSTPARTY,LOCALFOLDER
default_section = THIRDPARTY

Howdy! Sorry you're having trouble. To expedite your experience,
provide some basics for me:

Operating system: Ubuntu 16.04.6 LTS
Python version: 3.7.2
Black version: 19.3b0
Does also happen on master: yes

To answer the last question, you have two options:

  1. Use the online formatter at https://black.now.sh/?version=master, which will use the latest master branch.
  2. Or run black on your machine:
    • create a new virtualenv (make sure it's the same Python version);
    • clone this repository;
    • run pip install -e .;
    • make sure it's sane by running python setup.py test; and
    • run black like you did last time.
@zsol zsol added the T: enhancement New feature or request label Mar 21, 2019
@asfaltboy
Copy link

asfaltboy commented Apr 2, 2019

I have the same issue, black adds a space before that commented out import, but isort does not like that space and removes it ... like so:

import time

import numpy as np
import pandas
import scipy.sparse as sp
# from sklearn.grid_search import GridSearchCV
from sklearn.linear_model import ElasticNet, ElasticNetCV, enet_path

@Sharadh
Copy link

Sharadh commented Jun 3, 2019

This seems to be a duplicate of an existing issue: #251

@ambv
Copy link
Collaborator

ambv commented Mar 4, 2020

Sharadh is right. Let's focus on #251 instead.

@ambv ambv closed this as completed Mar 4, 2020
@ambv ambv added the R: duplicate This issue or pull request already exists label Mar 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
R: duplicate This issue or pull request already exists T: enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

5 participants