Title: Variable used before definition · Issue #475 · microsoft/python-language-server · GitHub
Open Graph Title: Variable used before definition · Issue #475 · microsoft/python-language-server
X Title: Variable used before definition · Issue #475 · microsoft/python-language-server
Description: @azdanov commented on Sat Dec 08 2018 Environment data VS Code version: 1.29.1 (1.29.1) Extension version (available under the Extensions sidebar): 2018.11.0 OS and version: macOS Mojave 10.14.1 (18B75) Python version (& distribution if ...
Open Graph Description: @azdanov commented on Sat Dec 08 2018 Environment data VS Code version: 1.29.1 (1.29.1) Extension version (available under the Extensions sidebar): 2018.11.0 OS and version: macOS Mojave 10.14.1 (1...
X Description: @azdanov commented on Sat Dec 08 2018 Environment data VS Code version: 1.29.1 (1.29.1) Extension version (available under the Extensions sidebar): 2018.11.0 OS and version: macOS Mojave 10.14.1 (1...
Opengraph URL: https://github.com/microsoft/python-language-server/issues/475
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Variable used before definition","articleBody":"@azdanov commented on [Sat Dec 08 2018](https://github.com/Microsoft/vscode-python/issues/3598)\n\n\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\nIf you think a GIF of what is happening would be helpful, consider tools like https://www.cockos.com/licecap/, https://github.com/phw/peek or https://www.screentogif.com/ .\r\n--\u003e\r\n\r\n## Environment data\r\n\r\n- VS Code version: 1.29.1 (1.29.1)\r\n- Extension version (available under the Extensions sidebar): 2018.11.0\r\n- OS and version: macOS Mojave 10.14.1 (18B75)\r\n- Python version (\u0026 distribution if applicable, e.g. Anaconda): Python 3.7.1 64-bit\r\n- Type of virtual environment used (N/A | venv | virtualenv | conda | ...): venv \r\n- Relevant/affected Python packages and their versions: -\r\n\r\n## Expected behaviour\r\n\r\nWhen running provided code snippet there should be no warning.\r\n\r\n```python\r\nfrom typing import Dict\r\n\r\nfallbackName: Dict[str, str] = {\"firstName\": \"First\", \"lastName\": \"Last\"}\r\n\r\nNAME = \" \".join(str(x) for x in fallbackName.values())\r\n\r\nprint(f\"Hi, {NAME}!\")\r\n```\r\n\r\n## Actual behaviour\r\n\r\nA warning is generated: `'fallbackName' used before definition`\r\n```json\r\n{\r\n\t\"resource\": \"/Users/_____/Projects/python/sandbox/index.py\",\r\n\t\"owner\": \"_generated_diagnostic_collection_name_#0\",\r\n\t\"code\": \"use-before-def\",\r\n\t\"severity\": 4,\r\n\t\"message\": \"'fallbackName' used before definition\",\r\n\t\"source\": \"Python\",\r\n\t\"startLineNumber\": 5,\r\n\t\"startColumn\": 33,\r\n\t\"endLineNumber\": 5,\r\n\t\"endColumn\": 45\r\n}\r\n```\r\n\r\n## Additional Info\r\n\r\nThis does not happen when type hinting is removed:\r\n\r\n```python\r\nFALLBACK_NAME = {\"first_name\": \"First\", \"last_name\": \"Last\"}\r\n\r\nNAME = \" \".join(str(x) for x in FALLBACK_NAME.values())\r\n\r\nprint(f\"Hi, {NAME}!\")\r\n```\r\n\r\n## Steps to reproduce:\r\n1. Create a new project, `python3 -m venv new/venv`.\r\n2. Insert code into `new/index.py`.\r\n3. Lint.\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\nStarting Microsoft Python language server.\r\nMicrosoft Python Language Server version 0.1.66.0\r\nInitializing for /Users/_____/Projects/python/sandbox/venv/bin/python\r\n##########Linting Output - prospector##########\r\n{\r\n \"summary\": {\r\n \"started\": \"2018-12-08 12:13:01.666245\",\r\n \"libraries\": [],\r\n \"strictness\": \"from profile\",\r\n \"profiles\": \".prospector.yaml, full_pep8, doc_warnings, strictness_veryhigh, no_member_warnings\",\r\n \"tools\": [\r\n \"dodgy\",\r\n \"mccabe\",\r\n \"mypy\",\r\n \"pep257\",\r\n \"pep8\",\r\n \"profile-validator\",\r\n \"pyflakes\",\r\n \"pylint\"\r\n ],\r\n \"message_count\": 0,\r\n \"completed\": \"2018-12-08 12:13:02.171521\",\r\n \"time_taken\": \"0.51\",\r\n \"formatter\": \"json\"\r\n },\r\n \"messages\": []\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 INFO no standard startup: not a new window\r\nconsole.ts:134 [Extension Host] Python Extension: Display locator refreshing progress, , Return Value: \r\nconsole.ts:134 [Extension Host] Python Extension: Notify locators are locating, , Return Value: \r\nconsole.ts:134 [Extension Host] Python Extension: Checking whether locactors have completed locating, , Return Value: \r\nconsole.ts:134 [Extension Host] Python Extension: Detected refreshing of Interpreters, Arg 1: {}, Return Value: \r\nconsole.ts:134 [Extension Host] Python Extension: Display locator refreshing progress, , Return Value: \r\nconsole.ts:134 [Extension Host] Python Extension: Notify locators are locating, , Return Value: \r\nconsole.ts:134 [Extension Host] Python Extension: Checking whether locactors have completed locating, , Return Value: \r\nconsole.ts:134 [Extension Host] Python Extension: Detected refreshing of Interpreters, Arg 1: {}, Return Value: \r\nconsole.ts:134 [Extension Host] Python Extension: Display locator refreshing progress, , Return Value: \r\nconsole.ts:134 [Extension Host] Python Extension: Notify locators are locating, , Return Value: \r\nconsole.ts:134 [Extension Host] Python Extension: Checking whether locactors have completed locating, , Return Value: \r\nconsole.ts:134 [Extension Host] Python Extension: Detected refreshing of Interpreters, Arg 1: {}, Return Value: \r\nconsole.ts:134 [Extension Host] Python Extension: Display locator refreshing progress, , Return Value: \r\nconsole.ts:134 [Extension Host] Python Extension: Notify locators are locating, , Return Value: \r\nconsole.ts:134 [Extension Host] Python Extension: Checking whether locactors have completed locating, , Return Value: \r\nconsole.ts:134 [Extension Host] Python Extension: Detected refreshing of Interpreters, Arg 1: {}, Return Value: \r\nconsole.ts:134 [Extension Host] Python Extension: Create file systemwatcher with pattern */python\r\nconsole.ts:134 [Extension Host] Python Extension: Create file systemwatcher with pattern */*/python\r\nconsole.ts:134 [Extension Host] Python Extension: Display locator refreshing progress, , Return Value: \r\nconsole.ts:134 [Extension Host] Python Extension: Notify locators are locating, , Return Value: \r\nconsole.ts:134 [Extension Host] Python Extension: Checking whether locactors have completed locating, , Return Value: \r\nconsole.ts:134 [Extension Host] Python Extension: Detected refreshing of Interpreters, Arg 1: {}, Return Value: \r\nconsole.ts:134 [Extension Host] Python Extension: Display locator refreshing progress, , Return Value: \r\nconsole.ts:134 [Extension Host] Python Extension: Notify locators are locating, , Return Value: \r\nconsole.ts:134 [Extension Host] Python Extension: Checking whether locactors have completed locating, , Return Value: \r\nconsole.ts:134 [Extension Host] Python Extension: Detected refreshing of Interpreters, Arg 1: {}, Return Value: \r\nconsole.ts:134 [Extension Host] Python Extension: Display locator refreshing progress, , Return Value: \r\nconsole.ts:134 [Extension Host] Python Extension: Notify locators are locating, , Return Value: \r\nconsole.ts:134 [Extension Host] Python Extension: Checking whether locactors have completed locating, , Return Value: \r\nconsole.ts:134 [Extension Host] Python Extension: Detected refreshing of Interpreters, Arg 1: {}, Return Value: \r\nconsole.ts:134 [Extension Host] Python Extension: Register Intepreter Watcher, Arg 1: {\"$mid\":1,\"fsPath\":\"/Users/_____/Projects/python/sandbox\",\"external\":\"file:///Users/_____/Projects/python/sandbox\",\"path\":\"/Users/_____/Projects/python/sandbox\",\"scheme\":\"file\"}, Return Value: \r\nconsole.ts:134 [Extension Host] Python Extension: Create file systemwatcher with pattern */python\r\nconsole.ts:134 [Extension Host] Python Extension: Create file systemwatcher with pattern */*/python\r\nconsole.ts:134 [Extension Host] Python Extension: Display locator refreshing progress, , Return Value: \r\nconsole.ts:134 [Extension Host] Python Extension: Notify locators are locating, , Return Value: \r\nconsole.ts:134 [Extension Host] Python Extension: Checking whether locactors have completed locating, , Return Value: \r\nconsole.ts:134 [Extension Host] Python Extension: Detected refreshing of Interpreters, Arg 1: {}, Return Value: \r\nconsole.ts:134 [Extension Host] Python Extension: Build the workspace interpreter watcher, Arg 1: {\"$mid\":1,\"fsPath\":\"/Users/_____/Projects/python/sandbox\",\"external\":\"file:///Users/_____/Projects/python/sandbox\",\"path\":\"/Users/_____/Projects/python/sandbox\",\"scheme\":\"file\"}, Return Value: UNABLE TO DETERMINE VALUE\r\nconsole.ts:134 [Extension Host] Python Extension: Register Intepreter Watcher, Arg 1: undefined, Return Value: \r\nconsole.ts:134 [Extension Host] Python Extension: Build the workspace interpreter watcher, Arg 1: undefined, Return Value: UNABLE TO DETERMINE VALUE\r\nconsole.ts:134 [Extension Host] Python Extension: Get language server folder name, , Return Value: \"languageServer.0.1.66\"\r\n6console.ts:134 [Extension Host] Python Extension: Checking whether locactors have completed locating, , Return Value: \r\nconsole.ts:134 [Extension Host] Python Extension: Hide locator refreshing progress, , Return Value: \r\nconsole.ts:134 [Extension Host] Python Extension: All locators have completed locating, , Return Value: \r\nconsole.ts:134 [Extension Host] Python Extension: Checking whether locactors have completed locating, , Return Value: \r\nconsole.ts:134 [Extension Host] Python Extension: Hide locator refreshing progress, , Return Value: \r\nconsole.ts:134 [Extension Host] Python Extension: All locators have completed locating, , Return Value: \r\nconsole.ts:134 [Extension Host] Python Extension: Checking whether locactors have completed locating, , Return Value: \r\nconsole.ts:134 [Extension Host] Python Extension: Hide locator refreshing progress, , Return Value: \r\nconsole.ts:134 [Extension Host] Python Extension: All locators have completed locating, , Return Value: \r\nconsole.ts:134 [Extension Host] Python Extension: Checking whether locactors have completed locating, , Return Value: \r\nconsole.ts:134 [Extension Host] Python Extension: Hide locator refreshing progress, , Return Value: \r\nconsole.ts:134 [Extension Host] Python Extension: All locators have completed locating, , Return Value: \r\nconsole.ts:134 [Extension Host] Python Extension: Checking whether locactors have completed locating, , Return Value: \r\nconsole.ts:134 [Extension Host] Python Extension: Hide locator refreshing progress, , Return Value: \r\nconsole.ts:134 [Extension Host] Python Extension: All locators have completed locating, , Return Value: \r\nconsole.ts:134 [Extension Host] Python Extension: Checking whether locactors have completed locating, , Return Value: \r\nconsole.ts:134 [Extension Host] Python Extension: Hide locator refreshing progress, , Return Value: \r\nconsole.ts:134 [Extension Host] Python Extension: All locators have completed locating, , Return Value: \r\nconsole.ts:134 [Extension Host] Python Extension: Checking whether locactors have completed locating, , Return Value: \r\nconsole.ts:134 [Extension Host] Python Extension: Hide locator refreshing progress, , Return Value: \r\nconsole.ts:134 [Extension Host] Python Extension: All locators have completed locating, , Return Value: \r\nconsole.ts:134 [Extension Host] Python Extension: Checking whether locactors have completed locating, , Return Value: \r\nconsole.ts:134 [Extension Host] Python Extension: Hide locator refreshing progress, , Return Value: \r\nconsole.ts:134 [Extension Host] Python Extension: All locators have completed locating, , Return Value: \r\nconsole.ts:134 [Extension Host] Python Extension: Checking whether locactors have completed locating, , Return Value: \r\n```\n\n---\n\n@yehorb commented on [Sat Dec 08 2018](https://github.com/Microsoft/vscode-python/issues/3598#issuecomment-445496364)\n\nI have a similar issue with my Python.\r\nVS Code version: 1.29.1 (1.29.1)\r\nExtension version (available under the Extensions sidebar): 2018.11.0\r\nOS and version: Ubuntu 18.04.1 LTS\r\nPython version (\u0026 distribution if applicable, e.g. Anaconda): Python 3.6.7 64-bit\r\nType of virtual environment used (N/A | venv | virtualenv | conda | ...): conda\r\nRelevant/affected Python packages and their versions: not relevant\r\n\r\nIssues disappear if you reload window, but reappear if I make even the slightest edit to the code written. Sometimes they appear as I type (e.g. I type \"return True\" and issues are \" 're' used before definition\", \" 'ret' used before definition\" and so on).\r\n\r\nIssue appears to occur more in longer files.\r\n\r\n\r\n\r\n\n\n---\n\n@azdanov commented on [Sat Dec 08 2018](https://github.com/Microsoft/vscode-python/issues/3598#issuecomment-445517763)\n\n@yehorb Could you create a minimal Github repo with a reproducible error? It will help a lot in fixing this issue.\r\n\r\nIn my case, this happens because of `typing`.\n\n---\n\n@yehorb commented on [Mon Dec 10 2018](https://github.com/Microsoft/vscode-python/issues/3598#issuecomment-445784058)\n\nHere:\r\nhttps://github.com/yehorb/VSCode-use-before-def-bug\r\n\r\nThis is the output I get:\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\n\n---\n\n@azdanov commented on [Mon Dec 10 2018](https://github.com/Microsoft/vscode-python/issues/3598#issuecomment-445798647)\n\n@yehorb Awesome, thanks! Now it's just waiting for a maintainer to triage this issue. 🤷♂️ \n\n","author":{"url":"https://github.com/brettcannon","@type":"Person","name":"brettcannon"},"datePublished":"2018-12-10T20:16:11.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/475/python-language-server/issues/475"}
| 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:f1f82340-2f9a-b6f2-444c-9d0fec970d31 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B13C:2B78D3:2258F04:2E88B73:6A5388FB |
| html-safe-nonce | 22bef803ef301f4ab9dcaab36dfc5e6439ee3a8b86f906540da2bdaa66dadaef |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCMTNDOjJCNzhEMzoyMjU4RjA0OjJFODhCNzM6NkE1Mzg4RkIiLCJ2aXNpdG9yX2lkIjoiNDA0OTEzMDQyNjM5MjA4Njc4MCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | a66e38188ce0a02ccbf4b5d619bb217d10164bf6886cd1f8fd1d1ceb37bf4c93 |
| hovercard-subject-tag | issue:389468657 |
| 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/python-language-server/475/issue_layout |
| twitter:image | https://opengraph.githubassets.com/c69be5728db82364ecf67ffe76859e5598095ff31eda7f96b29c95324e5d64b2/microsoft/python-language-server/issues/475 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/c69be5728db82364ecf67ffe76859e5598095ff31eda7f96b29c95324e5d64b2/microsoft/python-language-server/issues/475 |
| og:image:alt | @azdanov commented on Sat Dec 08 2018 Environment data VS Code version: 1.29.1 (1.29.1) Extension version (available under the Extensions sidebar): 2018.11.0 OS and version: macOS Mojave 10.14.1 (1... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | brettcannon |
| hostname | github.com |
| expected-hostname | github.com |
| None | b9a586c06a05a7a86fc7e3f4dbd03e42f6869085879aa184aa6369456dbd50fb |
| turbo-cache-control | no-preview |
| go-import | github.com/microsoft/python-language-server git https://github.com/microsoft/python-language-server.git |
| octolytics-dimension-user_id | 6154722 |
| octolytics-dimension-user_login | microsoft |
| octolytics-dimension-repository_id | 145901977 |
| octolytics-dimension-repository_nwo | microsoft/python-language-server |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 145901977 |
| octolytics-dimension-repository_network_root_nwo | microsoft/python-language-server |
| 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 | 07a982c1d40157c619b364352b704c3ce66bb332 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width