You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've encountered an issue where the Black formatter does not format Python files in git folders. The formatter works as expected on Python files in non-Git folders, but once a folder is initialized as a Git repository, newly created Python files within that folder are not formatted. Deleting the .git folder restores Black's functionality.
Steps to Reproduce
Create a new folder and place a Python file inside. Confirm that Black formats this file correctly in VS Code.
Initialize the folder as a Git repository using git init.
Create another Python file in the Git-initialized folder. Observe that Black does not format this new file.
Delete the .git folder from the project directory.
Create another Python file and observe that Black now formats it correctly.
Expected Behavior
Black should format Python files regardless of the presence of a Git repository in the project folder.
Actual Behavior
Black does not format Python files in folders that have been initialized as Git repositories.
Error Messages
Upon initializing a Git repository and attempting to format a Python file, there are no explicit error messages from Black indicating a failure to format. The functionality silently fails. The problem is that no Python files are found.
2024-02-08 15:41:41.341 [info] [Trace - 3:41:41 PM] Sending request 'textDocument/formatting - (8)'.
2024-02-08 15:41:41.344 [info] [Trace - 3:41:41 PM] Received notification 'window/logMessage'.
2024-02-08 15:41:41.344 [info] c:\Users\yilma\AppData\Local\Programs\Python\Python311\python.exe -m black --skip-string-normalization --stdin-filename c:\Files\Coding\Python\Neuro\testing\testing_new.py -
2024-02-08 15:41:41.345 [info] [Trace - 3:41:41 PM] Received notification 'window/logMessage'.
2024-02-08 15:41:41.345 [info] CWD formatter: c:\Files\Coding\Python\Neuro\testing
2024-02-08 15:41:41.348 [info] [Trace - 3:41:41 PM] Received notification 'window/logMessage'.
2024-02-08 15:41:41.348 [info] No Python files are present to be formatted. Nothing to do 😴
2024-02-08 15:41:41.348 [info] [Trace - 3:41:41 PM] Received response 'textDocument/formatting - (8)' in 8ms.
Troubleshooting Steps Attempted
Checked workspace and user settings in VS Code to ensure there were no conflicts or misconfigurations specifically affecting files in Git repositories.
Confirmed that the issue persists across different projects and is reproducible following the steps above.
Tested Black's functionality in folders both before and after initializing them as Git repositories to confirm the behavior is consistent with the presence of the .git directory.
Reviewed VS Code and Black formatter logs for any warnings or errors that might indicate the cause of the issue, but found nothing directly relevant.
System Configuration
VS Code Version: 1.86.1
Black Version: v2024.0.0
Operating System: Windows 11
Python Version: 3.11.3
Git Version: 2.40.0.windows.1
I would appreciate any insights or suggestions on resolving this issue. If further information or testing is required, I'm happy to provide it.
Edit: Switching to Black v2023.6.0 solved my issue.
The text was updated successfully, but these errors were encountered:
Description
I've encountered an issue where the Black formatter does not format Python files in git folders. The formatter works as expected on Python files in non-Git folders, but once a folder is initialized as a Git repository, newly created Python files within that folder are not formatted. Deleting the
.git
folder restores Black's functionality.Steps to Reproduce
git init
..git
folder from the project directory.Expected Behavior
Black should format Python files regardless of the presence of a Git repository in the project folder.
Actual Behavior
Black does not format Python files in folders that have been initialized as Git repositories.
Error Messages
2024-02-08 15:41:41.341 [info] [Trace - 3:41:41 PM] Sending request 'textDocument/formatting - (8)'.
2024-02-08 15:41:41.344 [info] [Trace - 3:41:41 PM] Received notification 'window/logMessage'.
2024-02-08 15:41:41.344 [info] c:\Users\yilma\AppData\Local\Programs\Python\Python311\python.exe -m black --skip-string-normalization --stdin-filename c:\Files\Coding\Python\Neuro\testing\testing_new.py -
2024-02-08 15:41:41.345 [info] [Trace - 3:41:41 PM] Received notification 'window/logMessage'.
2024-02-08 15:41:41.345 [info] CWD formatter: c:\Files\Coding\Python\Neuro\testing
2024-02-08 15:41:41.348 [info] [Trace - 3:41:41 PM] Received notification 'window/logMessage'.
2024-02-08 15:41:41.348 [info] No Python files are present to be formatted. Nothing to do 😴
2024-02-08 15:41:41.348 [info] [Trace - 3:41:41 PM] Received response 'textDocument/formatting - (8)' in 8ms.
Troubleshooting Steps Attempted
.git
directory.System Configuration
I would appreciate any insights or suggestions on resolving this issue. If further information or testing is required, I'm happy to provide it.
Edit: Switching to Black v2023.6.0 solved my issue.
The text was updated successfully, but these errors were encountered: