Black fails to find python files
See original GitHub issueDescribe the bug Black, when run on a directory, fails to find python files contained in it.
To Reproduce Steps to reproduce the behavior: Directory structure:
tree src/cloudbuild
src/cloudbuild
βββ build
βΒ Β βββ build_args.py
βΒ Β βββ build_result.py
βΒ Β βββ build_tool.py
βΒ Β βββ config
βΒ Β βΒ Β βββ mypy_tool.ini
βΒ Β βΒ Β βββ pycodestyle_tool.ini
βΒ Β βΒ Β βββ pylint_tool.rc
βΒ Β βΒ Β βββ python_toolchain.yaml
βΒ Β βΒ Β βββ test_coverage_tool.rc
βΒ Β βββ __init__.py
βΒ Β βββ tool
βΒ Β βββ compile_tool.py
βΒ Β βββ docstr_coverage_tool.py
βΒ Β βββ __init__.py
βΒ Β βββ mypy_tool.py
βΒ Β βββ pycodestyle_tool.py
βΒ Β βββ pylint_tool.py
βΒ Β βββ python.py
βΒ Β βββ python_report_tool.py
βΒ Β βββ unittest_tool.py
βββ __init__.py
black src/cloudbuild/
All done! β¨ π° β¨
1 file left unchanged.
black src/cloudbuild/build/tool/
No Python files are present to be formatted. Nothing to do π΄
black src/cloudbuild/build/tool/*
reformatted src/cloudbuild/build/tool/python.py
reformatted src/cloudbuild/build/tool/pycodestyle_tool.py
reformatted src/cloudbuild/build/tool/unittest_tool.py
reformatted src/cloudbuild/build/tool/mypy_tool.py
reformatted src/cloudbuild/build/tool/python_report_tool.py
reformatted src/cloudbuild/build/tool/pylint_tool.py
All done! β¨ π° β¨
Expected behavior Running Black on a directory runs it on all python files within that directory and subdirectories.
Environment (please complete the following information):
- Version: both
black-19.10b0
and master - OS and Python version: Arch Linux, Python 3.7.2
Does this bug also happen on master? To answer this, you have two options: Yes
Additional context Add any other context about the problem here.
Issue Analytics
- State:
- Created 4 years ago
- Comments:8
Top Results From Across the Web
The basics - Black 22.12.0 documentation
Black will only ever use one pyproject.toml file during an entire run. It doesn't look for multiple files, and doesn't compose configuration from...
Read more >black's --include option not working in pre-commit to add ...
My assumption had been that pre-commit was supplying a list of files to black but, as a list of files appears to override...
Read more >Setting up python Black on Visual Studio Code | by Marco Belo
Search for βpython formatting providerβ and select βblackβ. Now open/create a python file, write some code and save(Ctrl+s) it to see the magic...
Read more >python-black - Package Control
There is no need to install black , but if you install it, it will not affect this package. ... Find this project...
Read more >When trying to open a Python file, why does a black screen ...
It can also mean your Python's Interpreter Path Variable is not set in your advanced settings. So it attempts to read your .py...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I think this is still a bug: the exclude pattern should not match path components that were given on the command line.
The example given above was
So the user has told it to act on a specifically specified directory. It has then evaluated that directory against the default
--exclude
patterns and concluded it has nothing to do.IMHO when given a directory as a CLI argument, black should consider the paths of items in the directory relative to the directory given when applying the
--exclude
pattern.Would you be willing to re-consider your default exclude patterns? We have several subfolders called
build
in our source code, and it caught me by surprise that these were excluded when I tried to format my source tree.