question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Format selection doesn't use user's choice

See original GitHub issue

Bug: Notebook Editor, Interactive Window, Editor cells

Steps to cause the bug to occur

  1. Select black as formatting provider
  2. Change to autopep8 (or any other provider) (Code->Preferences->“python formatting provider”)
  3. Try auto-formatting a selection

Actual behavior

The extension throws an error saying that black can’t format selections, which is true, except the formatter was explicitly set to autopep8

image image

Expected behavior

The extension should use the selected formatting provider.

Your Jupyter and/or Python environment

VS Code details:

Version: 1.47.1
Commit: 485c41f9460bdb830c4da12c102daff275415b53
Date: 2020-07-13T22:43:02.577Z
Electron: 7.3.2
Chrome: 78.0.3904.130
Node.js: 12.8.1
V8: 7.8.279.23-electron.0
OS: Darwin x64 19.5.0
  • Jupyter server running: Local
  • Extension version: 2020.7.96456
  • VS Code version: 1.47.1
  • Setting python.jediEnabled: N/A
  • Setting python.languageServer: Jedi
  • Python and/or Anaconda version: conda version : 4.8.4 || python version : 3.7.7.final.0
  • OS: Windows | Mac | Linux (distro): Mac 10.15.5 (19F101)
  • Virtual environment: conda

     active environment : CHMO
    active env location : /Users/shaunak.de/opt/anaconda3/envs/CHMO
            shell level : 2
       user config file : /Users/shaunak.de/.condarc
 populated config files : /Users/shaunak.de/.condarc
          conda version : 4.8.2
    conda-build version : 3.18.11
         python version : 3.7.6.final.0
       virtual packages : __osx=10.15.5
       base environment : /Users/shaunak.de/opt/anaconda3  (writable)
           channel URLs : https://repo.anaconda.com/pkgs/main/osx-64
                          https://repo.anaconda.com/pkgs/main/noarch
                          https://repo.anaconda.com/pkgs/r/osx-64
                          https://repo.anaconda.com/pkgs/r/noarch
          package cache : /Users/shaunak.de/opt/anaconda3/pkgs
                          /Users/shaunak.de/.conda/pkgs
       envs directories : /Users/shaunak.de/opt/anaconda3/envs
                          /Users/shaunak.de/.conda/envs
               platform : osx-64
             user-agent : conda/4.8.2 requests/2.22.0 CPython/3.7.6 Darwin/19.5.0 OSX/10.15.5
                UID:GID : 503:20
             netrc file : None
           offline mode : False

Developer Tools Console Output

INFO Setting search error: XHR timeout: 5000ms
workbench.desktop.main.js:sourcemap:1670   ERR TreeError [MarkersView] Tree element not found: [object Object]: Error: TreeError [MarkersView] Tree element not found: [object Object]
    at t.ObjectTreeModel.getElementLocation (file:///Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/workbench.desktop.main.js:114:613)
    at t.ObjectTreeModel.setCollapsed (file:///Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/workbench.desktop.main.js:113:855)
    at H.expand (file:///Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/workbench.desktop.main.js:1106:277)
    at K.autoReveal (file:///Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/workbench.desktop.main.js:7069:818)
    at K.onActiveEditorChanged (file:///Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/workbench.desktop.main.js:7066:842)
    at file:///Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/workbench.desktop.main.js:7065:715
    at file:///Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/workbench.desktop.main.js:92:235
    at c.fire (file:///Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/workbench.desktop.main.js:95:801)
    at F.doHandleActiveEditorChangeEvent (file:///Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/workbench.desktop.main.js:6057:491)
    at F.handleActiveEditorChange (file:///Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/workbench.desktop.main.js:6057:289)
    at file:///Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/workbench.desktop.main.js:6057:601
    at c.fire (file:///Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/workbench.desktop.main.js:95:801)
    at file:///Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/workbench.desktop.main.js:6290:665
    at async e.openEditor (file:///Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/workbench.desktop.main.js:6289:121)
workbench.desktop.main.js:sourcemap:2947 Black does not support the "Format Selection" command

Microsoft Data Science for VS Code Engineering Team: @rchiodo, @IanMatthewHuff, @DavidKutu, @DonJayamanne, @greazer, @joyceerhl

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
Shaunakdecommented, Aug 13, 2020

Dear Eric, Yes, I was able to simply delete that key and it works as expected! Hopefully this page serves as a reference for someone searching! SDe

On Thu, Aug 13, 2020 at 10:25 AM Eric Snow notifications@github.com wrote:

@Shaunakde https://mailtrack.io/trace/link/2aaf6c613b689a34ab2f9cb51c4670a2b785f52c?url=https%3A%2F%2Fgithub.com%2FShaunakde&userId=3142140&signature=e96299fd18414748, yeah, that is very helpful. That “python.formatting.provider” setting will definitely result in black running rather than autopep8. Also, the folder settings take precedence over the workspace settings. So that explains the behavior. If you change the workspace folder setting does everything work as expected?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://mailtrack.io/trace/link/27831bb6656eb02cc7c757eabc252f6ffca68b0b?url=https%3A%2F%2Fgithub.com%2Fmicrosoft%2Fvscode-python%2Fissues%2F13390%23issuecomment-673606523&userId=3142140&signature=acc3a9d1db55105e, or unsubscribe https://mailtrack.io/trace/link/9db551e201deda2913e64cba52cf8b8b340c1851?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAATNL2LO4TAMV7MKDBK2DF3SAQOZJANCNFSM4P3QZP5Q&userId=3142140&signature=2d74dbd59d268520 .

– Shaunak De http://shaunak.de/ https://mailtrack.io/trace/link/c0929390ce7fb688511eb96d9c4a6e3238564567?url=http%3A%2F%2Fshaunak.de%2F&userId=3142140&signature=52a0a69ba6a7701c

0reactions
ericsnowcurrentlycommented, Aug 17, 2020

That’s great to hear. Thanks for following up!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Black does not support "Format Selection" command
In my situation (select black as the Python Formatting Provider in VS Code Settings), I encountered this warning everytime when I pasting ...
Read more >
Basic Editing in Visual Studio Code
Learn about the basic editing features of Visual Studio Code. Search, multiple selection, code formatting.
Read more >
ClangFormat — Clang 16.0.0git documentation
clang-format --help OVERVIEW: A tool to format C/C++/Java/JavaScript/JSON/Objective-C/Protobuf/C# code. If no arguments are specified, it formats the code ...
Read more >
Add a check box or option button (Form controls)
In the Format Control dialog box, on the Control tab, you can modify any of the available options: Checked: Displays an option button...
Read more >
How To Format Code with Prettier in Visual Studio Code
You may then be prompted to choose which format to use. ... Note: If you do not see a prompt for selecting a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found