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

not working black formatter #551

Closed
Ravindu121212 opened this issue Dec 22, 2024 · 7 comments
Closed

not working black formatter #551

Ravindu121212 opened this issue Dec 22, 2024 · 7 comments
Labels
triage-needed Issue is not triaged.

Comments

@Ravindu121212
Copy link

Type: Performance Issue

I install black formatter perfectly but it doesn't work for python file.

Extension version: 2024.4.0
VS Code version: Code 1.96.2 (fabdb6a30b49f79a7aba0f2ad9df9b399473380f, 2024-12-19T10:22:47.216Z)
OS version: Windows_NT x64 10.0.19045
Modes:

System Info
Item Value
CPUs Intel(R) Core(TM) i5-6300U CPU @ 2.40GHz (4 x 2496)
GPU Status 2d_canvas: enabled
canvas_oop_rasterization: enabled_on
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_graphite: disabled_off
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: enabled
webnn: disabled_off
Load (avg) undefined
Memory (System) 7.88GB (1.24GB free)
Process Argv --crash-reporter-id 05c210c9-57e4-4205-aa0d-64ccb1f62150
Screen Reader no
VM 0%
Process Info
CPU %	Mem MB	   PID	Process
    0	   130	 18836	code main
    0	    97	  3344	fileWatcher [1]
    1	   316	  8472	window [1] (Settings - python - Visual Studio Code)
    0	   167	 10700	   gpu-process
    0	   125	 12280	shared-process
    0	   444	 12808	extensionHost [1]
    0	    54	 12028	     c:\Users\s\AppData\Local\Programs\Python\Python313\python.exe c:\Users\s\.vscode\extensions\ms-python.black-formatter-2024.4.0\bundled\tool\lsp_server.py --stdio
    0	    11	 12832	       C:\Windows\system32\conhost.exe 0x4
    0	     6	 12064	     c:\Users\s\.vscode\extensions\ms-python.python-2024.22.0-win32-x64\python-env-tools\bin\pet.exe server
    0	    11	  8836	       C:\Windows\system32\conhost.exe 0x4
    0	   177	 12316	     electron-nodejs (bundle.js )
    0	    94	 12712	     electron-nodejs (serverMain.js )
    0	   128	 16216	     "C:\Users\s\AppData\Local\Programs\Microsoft VS Code\Code.exe" "c:\Users\s\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\json-language-features\server\dist\node\jsonServerMain" --node-ipc --clientProcessId=12808
    0	    48	 12820	   utility-network-service
    0	   137	 16272	ptyHost
    0	    71	  1144	     C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
    0	    71	  4604	     C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
    0	     7	  4828	     conpty-agent
    0	    72	  7780	     C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -noexit -command "try { . \"c:\Users\s\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\contrib\terminal\common\scripts\shellIntegration.ps1\" } catch {}"
    0	    71	 10212	     C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
    0	     7	 12052	     conpty-agent
    0	     6	 12396	     conpty-agent
    0	     7	 12836	     conpty-agent
    0	    72	 14028	     C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -noexit -command "try { . \"c:\Users\s\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\contrib\terminal\common\scripts\shellIntegration.ps1\" } catch {}"
    0	    71	 14188	     C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
    0	     7	 16164	     conpty-agent
    0	    74	 16744	     C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -noexit -command "try { . \"c:\Users\s\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\contrib\terminal\common\scripts\shellIntegration.ps1\" } catch {}"
    0	     6	 18616	     conpty-agent
    0	     6	 18820	     conpty-agent
    0	    29	 18452	   crashpad-handler
Workspace Info
|  Window (Settings - python - Visual Studio Code)
|    Folder (python): 3 files
|      File types: py(1) js(1)
|      Conf files:;
A/B Experiments
vsliv368:30146709
vspor879:30202332
vspor708:30202333
vspor363:30204092
vswsl492cf:30256860
vscod805:30301674
binariesv615:30325510
vsaa593cf:30376535
py29gd2263:31024239
c4g48928:30535728
azure-dev_surveyone:30548225
2i9eh265:30646982
962ge761:30959799
pythonnoceb:30805159
pythonmypyd1:30879173
2e7ec940:31000449
pythontbext0:30879054
cppperfnew:31000557
dsvsc020:30976470
pythonait:31006305
dsvsc021:30996838
dvdeprecation:31068756
dwnewjupytercf:31046870
newcmakeconfigv2:31071590
nativerepl1:31139838
pythonrstrctxt:31112756
nativeloc1:31192215
cf971741:31144450
iacca1:31171482
notype1cf:31157160
5fd0e150:31155592
dwcopilot:31170013
stablechunks:31184530
6074i472:31201624

@github-actions github-actions bot added the triage-needed Issue is not triaged. label Dec 22, 2024
@karthiknadig
Copy link
Member

@Ravindu121212 when you say it does not work, do you see any errors in Output> Black formatter logs?

@Ravindu121212
Copy link
Author

@Ravindu121212 when you say it does not work, do you see any errors in Output> Black formatter logs?

2024-12-22 10:19:29.519 [info] [Warn - 10:19:29 AM] Skipping non python code or code with syntax errors: c:\coding\python.vscode\hello.py

@Ravindu121212
Copy link
Author

@Ravindu121212 when you say it does not work, do you see any errors in Output> Black formatter logs?

2024-12-22 10:19:29.519 [info] [Warn - 10:19:29 AM] Skipping non python code or code with syntax errors: c:\coding\python.vscode\hello.py

format gonna work for js file

@karthiknadig
Copy link
Member

karthiknadig commented Dec 22, 2024

Black formatter can only format Python files and if there are no syntax errors. Can you share the content of your file?

@Ravindu121212
Copy link
Author

Ravindu121212 commented Dec 22, 2024

Black formatter can only format Python files and if there are no syntax errors. Can you share the content of your file?

def greet(name: str) -> str:
    """Greet the user with a friendly message."""
    return f"Hello, {name}! Welcome to the world of Python."


def add_numbers(a: int, b: int) -> int:
    """Add two numbers and return the result."""
    return a + b


if __name__ == "__main__":
    # Greet the user
                     name = input("Enter your name: ")
    print(greet(name))

    # Add two numbers
    num1 = int(input("Enter the first number: "))
    num2 = int(input("Enter the second number: "))
    result = add_numbers(num1, num2)
    print(f"The sum of {num1} and {num2} is {result}.")

@Ravindu121212
Copy link
Author

Black formatter can only format Python files and if there are no syntax errors. Can you share the content of your file?

give me a solution

@karthiknadig
Copy link
Member

karthiknadig commented Dec 22, 2024

Your code has Syntax errors, because it is not indented correctly. Black formatter does not fix these:
Image

Image

@karthiknadig karthiknadig closed this as not planned Won't fix, can't repro, duplicate, stale Dec 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
triage-needed Issue is not triaged.
Projects
None yet
Development

No branches or pull requests

2 participants