Title: "IndentationError: unexpected indent" when evaluating indented blocks of code · Issue #2837 · microsoft/vscode-python · GitHub
Open Graph Title: "IndentationError: unexpected indent" when evaluating indented blocks of code · Issue #2837 · microsoft/vscode-python
X Title: "IndentationError: unexpected indent" when evaluating indented blocks of code · Issue #2837 · microsoft/vscode-python
Description: Environment data VS Code version: 1.27.2 Extension version: 2018.9.0 OS and version: macOS Sierra 10.12.6 Python version: 3.7.0, installed via pyenv Type of virtual environment used: none Relevant/affected Python packages and their versi...
Open Graph Description: Environment data VS Code version: 1.27.2 Extension version: 2018.9.0 OS and version: macOS Sierra 10.12.6 Python version: 3.7.0, installed via pyenv Type of virtual environment used: none Relevant/...
X Description: Environment data VS Code version: 1.27.2 Extension version: 2018.9.0 OS and version: macOS Sierra 10.12.6 Python version: 3.7.0, installed via pyenv Type of virtual environment used: none Relevant/...
Opengraph URL: https://github.com/microsoft/vscode-python/issues/2837
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"\"IndentationError: unexpected indent\" when evaluating indented blocks of code","articleBody":"## Environment data\r\n\r\n- VS Code version: 1.27.2\r\n- Extension version: 2018.9.0\r\n- OS and version: macOS Sierra 10.12.6\r\n- Python version: 3.7.0, installed via pyenv\r\n- Type of virtual environment used: none \r\n- Relevant/affected Python packages and their versions: none\r\n\r\n## Actual behavior\r\n\r\nSending a selected Python code for evaluation in the Python terminal via _Run Selection/Line in Python Terminal_ results in `\"IndentationError: unexpected indent\"` errors if the block of code is indented.\r\n\r\nExample: evaluating the following selection results in an error because of the indentation of the whole block at 4 spaces:\r\n\r\n\u003cimg width=\"290\" alt=\"image\" src=\"https://user-images.githubusercontent.com/16516593/46737904-0922af80-cc9d-11e8-83cb-de77cad31676.png\">\r\n\r\n\u003cimg width=\"284\" alt=\"image\" src=\"https://user-images.githubusercontent.com/16516593/46737858-eb554a80-cc9c-11e8-8723-bd60aaae75fd.png\">\r\n\r\n\r\n## Expected behavior\r\n\r\nIt would be useful if the evaluation of indented code worked regardless of it's position or level of indentation in the overall code (i.e. should be first deindented to a \"base level\" before sending to the terminal?).\r\n\r\nAs an example, the indented code above should be sent to the terminal as if it was the following (i.e. not indented):\r\n\r\n\u003cimg width=\"252\" alt=\"image\" src=\"https://user-images.githubusercontent.com/16516593/46737924-19d32580-cc9d-11e8-8ab0-edd933c23abb.png\">\r\n\u003cimg width=\"189\" alt=\"image\" src=\"https://user-images.githubusercontent.com/16516593/46737933-1f307000-cc9d-11e8-9ab0-a72d87824192.png\">\r\n\r\n\r\nI tend to work \"bottom-up\", evaluating/debugging smaller pieces of code that form more complex functions, and those individual pieces are obviously indented. This behavior makes this sort of workflow a little difficult.\r\n\r\n## Steps to reproduce\r\n\r\nUse the following example code to test the behavior described above by evaluating the two commented blocks using _Run Selection/Line in Python Terminal_ functionality.\r\n\r\n```\r\ndef fn():\r\n # block indented by 4 spaces -> results in an error\r\n x, y = 10, 2\r\n for i in range(x):\r\n print(i ** y)\r\n\r\n# block not indented -> correctly evaluated\r\nx, y = 10, 2\r\nfor i in range(x):\r\n print(i ** y)\r\n```","author":{"url":"https://github.com/bodkan","@type":"Person","name":"bodkan"},"datePublished":"2018-10-10T13:04:28Z","url":"https://github.com/microsoft/vscode-python/issues/2837"}
| 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:83855444-3dde-50a4-37f7-cdd688c8efee |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | AA5A:247139:70D6D9:99BBF2:6AFE692D |
| html-safe-nonce | 9c0bfdb96dca32cc5ec7f1a88c4995ce267d46bfb4fb41cb7998dd4113bc3027 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBQTVBOjI0NzEzOTo3MEQ2RDk6OTlCQkYyOjZBRkU2OTJEIiwidmlzaXRvcl9pZCI6Ijg4MjMxOTIyMjMyMzYzODUwNjkiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | b1240163dcf3c8eb678929d4e51dadc44f7bf2b1c2fdf259bc2ffcdb183575a2 |
| hovercard-subject-tag | issue:368655662 |
| 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/2837/issue_layout |
| twitter:image | https://opengraph.githubassets.com/8a94000c52752c62be26ba0d65e72da2e878bb1270f3b3cd94b47c2a6795d9de/microsoft/vscode-python/issues/2837 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/8a94000c52752c62be26ba0d65e72da2e878bb1270f3b3cd94b47c2a6795d9de/microsoft/vscode-python/issues/2837 |
| og:image:alt | Environment data VS Code version: 1.27.2 Extension version: 2018.9.0 OS and version: macOS Sierra 10.12.6 Python version: 3.7.0, installed via pyenv Type of virtual environment used: none Relevant/... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | bodkan |
| hostname | github.com |
| expected-hostname | github.com |
| None | b3c0f155eafc27e60db6e254d1ffff0e072e9ab3b4018a5ee518797c19d89f86 |
| 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 | 4a10310af51a1bfffbedc4fd81cb582acf0cb0ff |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width