Title: Auto-Formatting (autopep8, black, yapf) Doesn't Work On Unsaved Files · Issue #2268 · microsoft/vscode-python · GitHub
Open Graph Title: Auto-Formatting (autopep8, black, yapf) Doesn't Work On Unsaved Files · Issue #2268 · microsoft/vscode-python
X Title: Auto-Formatting (autopep8, black, yapf) Doesn't Work On Unsaved Files · Issue #2268 · microsoft/vscode-python
Description: Environment data VS Code version: 1.25.1 Extension version (available under the Extensions sidebar): 2018.7.1 OS and version: Ubuntu 18.04 Python version (& distribution if applicable, e.g. Anaconda): Python 2.7.15rc1 and Python 3.6.5 Ty...
Open Graph Description: Environment data VS Code version: 1.25.1 Extension version (available under the Extensions sidebar): 2018.7.1 OS and version: Ubuntu 18.04 Python version (& distribution if applicable, e.g. Anacond...
X Description: Environment data VS Code version: 1.25.1 Extension version (available under the Extensions sidebar): 2018.7.1 OS and version: Ubuntu 18.04 Python version (& distribution if applicable, e.g. Ana...
Opengraph URL: https://github.com/microsoft/vscode-python/issues/2268
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Auto-Formatting (autopep8, black, yapf) Doesn't Work On Unsaved Files","articleBody":"\u003c!-- \r\nDo you have a question instead of a bug report or enhancement request? Please ask it on https://stackoverflow.com/questions/tagged/visual-studio-code+python. \r\n\r\nUnable to install a linter or formatter? 'No installers available'? \r\nWindows - https://stackoverflow.com/questions/4750806/how-do-i-install-pip-on-windows\r\nLinux - https://www.cyberciti.biz/faq/debian-ubuntu-centos-rhel-linux-install-pipclient/ , https://www.tecmint.com/install-pip-in-linux/\r\n\r\nPython configuration issues? Please check https://code.visualstudio.com/docs/python/python-tutorial#_prerequisites\r\n\r\nOtherwise **please** fill in the requested details below. \"XXX\" markers should not be present in the final bug report.\r\n-->\r\n\r\n## Environment data\r\n\r\n- VS Code version: 1.25.1\r\n- Extension version (available under the Extensions sidebar): 2018.7.1\r\n- OS and version: Ubuntu 18.04\r\n- Python version (& distribution if applicable, e.g. Anaconda): Python 2.7.15rc1 and Python 3.6.5\r\n- Type of virtual environment used (N/A | venv | virtualenv | conda | ...): N/A\r\n- Relevant/affected Python packages and their versions: autopep8 1.3.5 (pycodestyle: 2.4.0), black version 18.6b4, yapf 0.22.0\r\n\r\n## Actual behavior\r\n\r\nWorking with Python code in an unsaved file, executing the command `editor.action.formatDocument` has no effect on the text. The status bar briefly flashes to say that the formatter was run. \r\n\r\nIf you then save the document and run the same command, the formatter runs and edits the text as normal. \r\n\r\n## Expected behavior\r\n\r\nWorking with Python code in an unsaved file, `editor.action.formatDocument` will run the associated Python formatter (yapf, autopep8) and edit the text inline using default style settings. \r\n\r\n## Steps to reproduce:\r\n\r\n1. Open a new file. (`File->New`, or `Ctrl+N` by default.)\r\n2. Paste a large Python dict into the file on a single line. For instance: ```{0: 0, 1: 1, 2: 2, 3: 3, 4: 4, 5: 5, 6: 6, 7: 7, 8: 8, 9: 9, 10: 10, 11: 11, 12: 12, 13: 13, 14: 14, 15: 15, 16: 16, 17: 17, 18: 18, 19: 19, 20: 20, 21: 21, 22: 22, 23: 23, 24: 24, 25: 25, 26: 26, 27: 27, 28: 28, 29: 29, 30: 30, 31: 31, 32: 32, 33: 33, 34: 34, 35: 35, 36: 36, 37: 37, 38: 38, 39: 39, 40: 40, 41: 41, 42: 42, 43: 43, 44: 44, 45: 45, 46: 46, 47: 47, 48: 48, 49: 49, 50: 50, 51: 51, 52: 52, 53: 53, 54: 54, 55: 55, 56: 56, 57: 57, 58: 58, 59: 59, 60: 60, 61: 61, 62: 62, 63: 63, 64: 64, 65: 65, 66: 66, 67: 67, 68: 68, 69: 69, 70: 70, 71: 71, 72: 72, 73: 73, 74: 74, 75: 75, 76: 76, 77: 77, 78: 78, 79: 79, 80: 80, 81: 81, 82: 82, 83: 83, 84: 84, 85: 85, 86: 86, 87: 87, 88: 88, 89: 89, 90: 90, 91: 91, 92: 92, 93: 93, 94: 94, 95: 95, 96: 96, 97: 97, 98: 98, 99: 99}```\r\n3. Open the language picker (`Command Palette->Change Language Mode`, or `Ctrl+K M`* by default) and select Python. \r\n4. Execute the `editor.action.formatDocument` command (`Command Palette->Format Document`, or `Ctrl+Shift+I` by default)\r\n5. Note that the status bar briefly flashes the name of your set code formatter, but the document doesn't change. \r\n6. Save the file. (`File->Save`, or `Ctrl+S` by default.)\r\n7. Repeat step 4. \r\n8. Note that now the document is actually formatted. \r\n9. *(Optional) Change formatter and repeat steps 1-8.*\r\n10. *(Optional) Change Python interpreter and repeat steps 1-9.*\r\n\r\n*: This default keybind doesn't actually work for me, instead launching a search in the Extensions Marketplace for `@recommended:keymaps`.\r\n\r\n## Logs\r\nOutput for `Python` in the `Output` panel (`View`→`Output`, change the drop-down the upper-right of the `Output` panel to `Python`)\r\n\r\n```\r\n \r\n``` \r\n\r\nOutput from `Console` under the `Developer Tools` panel (toggle Developer Tools on under `Help`)\r\n\r\n```\r\n \r\n```\r\n","author":{"url":"https://github.com/CoryOwens","@type":"Person","name":"CoryOwens"},"datePublished":"2018-07-27T17:18:12Z","url":"https://github.com/microsoft/vscode-python/issues/2268"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:2cab1576-b7bd-d99b-2ca7-0e5fcd8068eb |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D394:2BC66C:10E23E:16D954:6AFE45C0 |
| html-safe-nonce | 05b98d323d0101f51ec23177ed719619d278cebdc5232be76de86b7a38d15068 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEMzk0OjJCQzY2QzoxMEUyM0U6MTZEOTU0OjZBRkU0NUMwIiwidmlzaXRvcl9pZCI6IjY0OTcxNDcyNDE2MTYwMzAwOCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 70c3b4b454fe292ef4448638d9c779df9382df2f84d81cbdc73585ad9c36ad6d |
| hovercard-subject-tag | issue:345303718 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/microsoft/vscode-python/2268/issue_layout |
| twitter:image | https://opengraph.githubassets.com/b0fc8aeb9f5bb4923da1274e2c885d4d7d9ac562aedf4e151c0ba03fcc530134/microsoft/vscode-python/issues/2268 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/b0fc8aeb9f5bb4923da1274e2c885d4d7d9ac562aedf4e151c0ba03fcc530134/microsoft/vscode-python/issues/2268 |
| og:image:alt | Environment data VS Code version: 1.25.1 Extension version (available under the Extensions sidebar): 2018.7.1 OS and version: Ubuntu 18.04 Python version (& distribution if applicable, e.g. Anacond... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | CoryOwens |
| hostname | github.com |
| expected-hostname | github.com |
| None | f1a5901e2377b0af2a0b303f9528678f1475d04b9219dca1e993344196eaa07c |
| turbo-cache-control | no-preview |
| go-import | github.com/microsoft/vscode-python git https://github.com/microsoft/vscode-python.git |
| octolytics-dimension-user_id | 6154722 |
| octolytics-dimension-user_login | microsoft |
| octolytics-dimension-repository_id | 106462765 |
| octolytics-dimension-repository_nwo | microsoft/vscode-python |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | true |
| octolytics-dimension-repository_parent_id | 49946255 |
| octolytics-dimension-repository_parent_nwo | DonJayamanne/pythonVSCode |
| octolytics-dimension-repository_network_root_id | 49946255 |
| octolytics-dimension-repository_network_root_nwo | DonJayamanne/pythonVSCode |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | ce393ea11ad276623b946bc9663d3e7d6f564275 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width