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

Default to current directory if no paths are specified #740

Closed
wants to merge 1 commit into from
Closed

Default to current directory if no paths are specified #740

wants to merge 1 commit into from

Conversation

hugovk
Copy link
Contributor

@hugovk hugovk commented Mar 9, 2019

I usually run Black on the current directory:

black .

Similarly for Flake8, the other Python CLI tool I often run:

flake8 .

And Flake8 defaults to search in the current directory. This is the same:

flake8

I'd like to ask for Black to do the same:

black

Benefits:

  • Less typing
  • Consistency

@coveralls
Copy link

Pull Request Test Coverage Report for Build 939

  • 4 of 4 (100.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.03%) to 96.066%

Totals Coverage Status
Change from base Build 938: -0.03%
Covered Lines: 2979
Relevant Lines: 3101

💛 - Coveralls

1 similar comment
@coveralls
Copy link

coveralls commented Mar 9, 2019

Pull Request Test Coverage Report for Build 939

  • 4 of 4 (100.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.03%) to 96.066%

Totals Coverage Status
Change from base Build 938: -0.03%
Covered Lines: 2979
Relevant Lines: 3101

💛 - Coveralls

@uranusjr
Copy link
Contributor

Passerby here, I want to voice that I wouldn’t like this change as a user. Unlikely flake8, Black actively modifies the checked code base (unless --check is passed). This makes the operation much more dangerous, and allowing omittion of the target directory makes it much easier to make mistakes. The path argument should be mandatory IMO.

@hugovk
Copy link
Contributor Author

hugovk commented Mar 27, 2019

Thanks, that's a fair point.

I'm trying to think of any Unix-like commands that modify without a path argument but coming up blank.

At least black . is much easier than the situation with pyupgrade :)

pyupgrade `find . -name "*.py" -type f`

@ambv
Copy link
Collaborator

ambv commented May 7, 2019

I think at this point the tool is popular enough that @uranusjr has a point: existing users might be surprised. Another small point: invalid editor integration that uses a variable as the filename might cause unexpected files to be formatted that way. Consider:

os.system(f"black {file}")

If {file} is an empty string for any reason, currently we will just error out. If we change the behavior, it would reformat stuff in the current directory which will be unexpected.

Thanks for your contribution @hugovk but we will have to pass on this change.

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.

4 participants