microsoft / vscode-python

Python extension for Visual Studio Code
https://aka.ms/pvsc-marketplace
MIT License
4.33k stars 1.19k forks source link

Syntax highlighting breaks when adding function return type (MPLS/Pylance) #14367

Closed 1kamma closed 4 years ago

1kamma commented 4 years ago

Steps to Reproduce:

Does this issue occur when all extensions are disabled?: Yes/No when I write a function in python, and put arrow to mark that the function returns value (the ->), the arrow is destroying the syntax highlight and the linter (the part that checks if the keywords have been typed correctly) image

image

ghost commented 4 years ago

Which python version are you using?

ghost commented 4 years ago

Type hints were introduced in Python 3.5

1kamma commented 4 years ago

I use python 3.9

ghost commented 4 years ago

The prerelease version?

EDIT: Python 3.9 was released on October 5? I totally missed that!

ghost commented 4 years ago

But I can't see any squiggly lines. Can you elaborate more on your problem?

kimadeline commented 4 years ago

Hi @1kamma, thank you for reaching out.

What is the value of your python.languageServer setting?

I couldn't reproduce that issue with a sample function, would you mind copying your code here as well?

Thanks!

1kamma commented 4 years ago

I use microsoft python.lagnuageserver,

kimadeline commented 4 years ago

Which one is it: Pylance, Jedi, Microsoft or none?

1kamma commented 4 years ago

"python.languageServer": "Microsoft",

kimadeline commented 4 years ago

Hi @1kamma, I couldn't reproduce your issue using sample code with Jedi, the Microsoft Language Server or Pylance.

We have recently released a new and more performant language server called Pylance. You can download it from the marketplace and install it alongside the core Python extension. Because our team's development efforts have shifted to support the new language server, we'd encourage you to try it out as it may solve the issue you're encountering.

I will be closing as not reproducible for now. If your issue persists with Pylance, feel free to leave a comment here and we can reopen it.

Thank you!

1kamma commented 4 years ago

well, the problem is still on those are my settings:

    "editor.suggestSelection": "first",
    "vsintellicode.modify.editor.suggestSelection": "automaticallyOverrodeDefaultValue",
    "files.autoSave": "afterDelay",
    "python.linting.enabled": true,
    "git.ignoreLimitWarning": true,
    "editor.suggest.showEvents": true,
    "editor.acceptSuggestionOnEnter": "off",
    "powershell.codeFormatting.autoCorrectAliases": true,
    "powershell.codeFormatting.useCorrectCasing": true,
    "[powershell]": {

        "editor.suggest.showMethods": true,
        "editor.autoIndent": "full",
        "breadcrumbs.showModules": true,
        "breadcrumbs.showStructs": true
    },
    "xmlTools.enableXmlTreeViewCursorSync": true,
    "html.suggest.html5": true,
    "html.autoClosingTags": true,
    "[html]": {
        "editor.suggest.insertMode": "replace",

    },

    "emmet.showExpandedAbbreviation": "always",
    "emmet.includeLanguages": {"vue-html":"html"},
    "xml.completion.autoCloseTags": true,
    "editor.fontLigatures": true,
    "editor.fontFamily": "Cascadia Code PL, Cascadia Code, Cascadia Mono, Consolas, 'Courier New', monospace",
    "powershell.buttons.showPanelMovementButtons": true,
    "powershell.debugging.createTemporaryIntegratedConsole": true,
    "powershell.enableProfileLoading": true,
    "powershell.scriptAnalysis.enable": true,
    "powershell.scriptAnalysis.settingsPath": "PSScriptAnalyzerSettings.psd1",
    "git.enableSmartCommit": true,
    "python.autoComplete.addBrackets": true,
    "python.autoComplete.showAdvancedMembers": true,
    "python.globalModuleInstallation": true,
    "python.autoUpdateLanguageServer": true,
    "python.analysis.memory.keepLibraryAst": false,
    "python.analysis.autoImportCompletions": true,

    "python.autoComplete.extraPaths": 
    [
        "C:\\Python38\\"
    ],

    "python.languageServer": "Pylance",
    "editor.semanticHighlighting.enabled": true,
    "python.linting.banditEnabled": false,
    "editor.semanticTokenColorCustomizations": {
        "[One Dark Pro]": { // Apply to this theme only
            "enabled": true,
            "rules": {
                "magicFunction:python": "#ee0000",
                "function.declaration:python": "#990000",
                "*.decorator:python": "#0000dd",
                "*.typeHint:python": "#5500aa",
                "*.typeHintComment:python": "#aaaaaa"
            }
        }
    },
    "tabnine.experimentalAutoImports": true,
    "editor.multiCursorModifier": "ctrlCmd",
    "editor.suggest.showFunctions": true,
    "editor.suggest.showFields": true,
    "editor.columnSelection": false,
    "launch": {
    "inputs": [],
        "configurations": [
            {
                "name": "Launch Python",
                "program": "${file}",
                "presentation": {
                    "hidden": false,
                    "group": "",
                    "order": 1
                },
                "console": "integratedTerminal",
                "request": "launch",
                "stopOnEntry": true,
                "type": "python"
            },
            {
                "name": "PowerShell Launch Script",
                "type": "PowerShell",
                "request": "launch",
                "script": "enter path or command to execute e.g.: ${workspaceFolder}/src/foo.ps1 or Invoke-Pester",
                "cwd": "${workspaceFolder}",
                "presentation": {
                    "hidden": false,
                    "group": "",
                    "order": 1,

                }
            },
            {
                "name": "Python: Attach",
                "type": "python",
                "request": "attach",
                "logToFile": true,
                "internalConsoleOptions": "openOnSessionStart",
                "presentation": {
                    "hidden": false,
                    "group": "",
                    "order": 1
                },
                "showReturnValue": true,
                "redirectOutput": true,
                "port": 5678,
                "host": "127.0.0.1",
                "connect": {
                  "host": "localhost",
                  "port": 5678
                }
            },
            {
                "type": "node",
                "request": "launch",
                "name": "Launch Program",
                "program": "${file}"
            }
        ],
        "compounds": []
    },
    "autoDocstring.docstringFormat": "sphinx",
    "autoDocstring.guessTypes": true,
    "autoDocstring.quoteStyle": "'''",
    "git.autofetch": true,
    "[python]": {
        "editor.defaultFormatter": "ms-python.python",
        "editor.formatOnPaste": true,
        "editor.formatOnSave": true,
        "editor.tabCompletion": "on"
    },
    "python.formatting.autopep8Args": ["--max-line-length", "120", "--experimental"],
    "python.formatting.yapfArgs": ["--style", "{based_on_style: chromium, indent_width: 20}"],
    "python.formatting.blackArgs": [
        "--line-length",
        "100"
    ],
    "python.analysis.extraPaths": [
        "C:\\Python38\\"
    ],
    "python.analysis.completeFunctionParens": true,
    "python.pythonPath": "c:\\Python39\\python.exe",
    "python.defaultInterpreterPath": "C:\\Python39\\python.exe",
    "files.associations": {
        "*.html": "html"
    }

}

and my extentions:

abusaidm.html-snippets
Adobe.extendscript-debug
adrianwilczynski.terminal-commands
aeschli.vscode-css-formatter
almenon.arepl
atarabi.ae-script-runner
austin.code-gnu-global
batisteo.vscode-django
bbenoist.QML
christian-kohler.npm-intellisense
clinyong.vscode-css-modules
cschlosser.doxdocgen
cutetee.qml
cweijan.vscode-autohotkey-plus
DavidWang.ini-for-vscode
dongli.python-preview
donjayamanne.githistory
donjayamanne.python-extension-pack
DotJoshJohnson.xml
DougFinke.vscode-PSStackoverflow
ecmel.vscode-html-css
eg2.vscode-npm-script
etmoffat.pip-packages
fabianlauer.vs-code-xml-format
formulahendry.terminal
GitHub.vscode-pull-request-github
hbenl.vscode-test-explorer
Hennamann.cc-extension-builder
himanoa.Python-autopep8
iansan5653.format-python-docstrings
ionutvmi.reg
jingjing.vscode-qml
justin-grote.better-powershell-syntax-highlighting
KevinRose.vsc-python-indent
kopub.pydocstring
lonefy.vscode-JS-CSS-HTML-formatter
magicstack.MagicPython
mansquatch.aem-component-builder
mgesbert.python-path
michelemelluso.code-beautifier
MikeBovenlander.formate
ms-python.python
ms-python.vscode-pylance
ms-vscode-remote.remote-wsl
ms-vscode.cpptools
ms-vscode.notepadplusplus-keybindings
ms-vscode.powershell
njpwerner.autodocstring
njqdev.vscode-python-typehint
patcx.vscode-nuget-gallery
redhat.vscode-xml
renderTom.adobe-script-runner
riteshksriv.github-links
Rubymaniac.vscode-paste-and-indent
seanwu.vscode-qt-for-python
slevesque.vscode-autohotkey
svipas.code-autocomplete
tht13.python
tushortz.python-extended-snippets
vinnyjames.vscode-autohotkey-vj
VisualStudioExptTeam.vscodeintellicode
wayou.vscode-todo-highlight
wholroyd.jinja
Yinkai15.aemsync
Zignd.html-css-class-completion
kimadeline commented 4 years ago

Thank you for sharing your settings and installed extensions.

I can see that you have multiple extensions that perform actions with Python code, does this problem happen if you disable all extensions except for the Python extension (ms-python.python) and Pylance (ms-python.vscode-pylance)?

1kamma commented 4 years ago

Name: Python for VSCode Id: tht13.python Description: Python language extension for vscode Version: 0.2.3 Publisher: Thomas Haakon Townsend VS Marketplace Link: https://marketplace.visualstudio.com/items?itemName=tht13.python that is the problematic extention

stephengineer commented 3 years ago

Disable the "Python for VSCode" extension will fix the issue.

muhammedogz commented 3 years ago

Outdated extensions should be removed from the store automatically. It is easy to trust extensions with high download count.

HermasTV commented 3 years ago

I faced the same problem and I thought that I wouldn't find a thread with the exact same issue , and here we go , thanks github XDD