Skip to content

Tab complete on if __name__ =="__main__" not working correctly #5158

@lvfrazao

Description

@lvfrazao

Environment data

  • VS Code version: 1.32.3 (user setup)
  • Extension version (available under the Extensions sidebar): Name: 2019.3.6352
  • OS and version: Windows_NT x64 10.0.17134
  • Python version (& distribution if applicable, e.g. Anaconda): Python 3.7.1 64-bit
  • Type of virtual environment used (N/A | venv | virtualenv | conda | ...): N/A
  • Relevant/affected Python packages and their versions: N/A

Expected behaviour

When I use the tab completion on a 'if name == "main"' type statement I expect it to auto complete to:

if name == "main":
pass

Actual behaviour

It actually autocompletes to:

if if name == "main":
pass

What actually happens

Which isn't valid Python

Steps to reproduce:

  1. Type "if __"
  2. When given the option, use tab to autocomplete the statement

Logs

##########Linting Output - mypy##########
upload_zone_files.py:3:6: error: invalid syntax
##########Linting Output - flake8##########
3,5,E,E999:SyntaxError: invalid syntax
##########Linting Output - pylint##########
************* Module upload_zone_files
3,0,error,syntax-error:invalid syntax (<unknown>, line 3)

Output from Console under the Developer Tools panel (toggle Developer Tools on under Help; turn on source maps to make any tracebacks be useful by running Enable source map support for extension debugging)

(did not copy entire output as there was a ton)

[Extension Host] Python Extension: Cached data exists getEnvironmentVariables, c:\Users\Victor Frazao\Documents\test_autocomplete.py
5console.ts:134 [Extension Host] Python Extension: Cached data exists getEnvironmentVariables, c:\Users\Victor Frazao\.vscode\extensions\ms-python.python-2019.3.6352\out\client
console.ts:134 [Extension Host] Python Extension: Interpreters returned by CurrentPathService are of count 6
console.ts:134 [Extension Host] Python Extension: Interpreters returned by WindowsRegistryService are of count 3
console.ts:134 [Extension Host] Python Extension: Checking whether locactors have completed locating, Class name = p, , Return Value: true
console.ts:134 [Extension Host] Python Extension: Hide locator refreshing progress, Class name = p, , Return Value: undefined
console.ts:134 [Extension Host] Python Extension: All locators have completed locating, Class name = p, , Return Value: undefined
console.ts:134 [Extension Host] Python Extension: Cached data exists getEnvironmentVariables, c:\Users\Victor Frazao\.vscode\extensions\ms-python.python-2019.3.6352\out\client
3console.ts:134 [Extension Host] Python Extension: Cached data exists getEnvironmentVariables, c:\Users\Victor Frazao\Documents\test_autocomplete.py
3console.ts:134 [Extension Host] Python Extension: Cached data exists getEnvironmentVariables, c:\Users\Victor Frazao\Documents\test_autocomplete.py

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions