Skip to content

Default to current directory if no paths are specified - #740

Closed
hugovk wants to merge 1 commit into
psf:masterfrom
hugovk:default-src
Closed

hugovk wants to merge 1 commit into
psf:masterfrom
hugovk:default-src

Conversation

@hugovk

@hugovk hugovk commented Mar 9, 2019

Copy link
Copy Markdown
Contributor

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
Copy Markdown

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

coveralls commented Mar 9, 2019 •

Copy link
Copy Markdown

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
Copy Markdown
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

hugovk commented Mar 27, 2019

Copy link
Copy Markdown
Contributor Author

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

ambv commented May 7, 2019

Copy link
Copy Markdown
Collaborator

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