-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Closed
Labels
C: configurationCLI and configurationCLI and configurationT: bugSomething isn't workingSomething isn't working
Description
Describe the bug
--exclude is supposed to only apply to the recursive discovery of files. Not files explicitly passed to Black through the command line. This is a regression since #1032 was merged.
To Reproduce
- Create a directory for testing
- Create and activate a virtual enviroment
- Install Black on master using
pip install git+git://github.com/psf/black - Create two empty files:
4.1.pyproject.tomlso Black doesn't find a different configuration file up your directory structure
4.2.test.py- this will be our test file - Run
black -v --exclude=test.py test.py - Install Black 19.10b0 using
pip install black==19.10b0 - Run
black -v --exclude=test.py test.py - Observe that on master the file was excluded and on stable the file was formatted.
Expected behavior
Black formats test.py since it was explicitly passed through the command line and --exclude should not touch such files like it.
Environment
- Version: master (b59a524) and stable (
19.10b0) - OS and Python version:
Ubuntu 18.04.04 LTSandPython 3.8.1
Does this bug also happen on master?
Yes and also N/A - This is a regression
Additional context
I haven't looked into this bug that much, but the problem seems to be related to how even files passed via the command line are given to the recursive gen_python_files function as single Path object lists in get_sources.
Lines 605 to 610 in b59a524
| elif p.is_file(): | |
| sources.update( | |
| gen_python_files( | |
| [p], root, None, exclude_regexes, report, get_gitignore(root) | |
| ) | |
| ) |
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
C: configurationCLI and configurationCLI and configurationT: bugSomething isn't workingSomething isn't working