Skip to content

python3本地调试会报错 #206

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
jlhxxxx opened this issue Mar 13, 2019 · 4 comments
Closed

python3本地调试会报错 #206

jlhxxxx opened this issue Mar 13, 2019 · 4 comments

Comments

@jlhxxxx
Copy link

jlhxxxx commented Mar 13, 2019

🐛 Bug Report

设置python3为默认语言,使用leetcode默认定义在本地调试会报错:undefined name name,这可能应该算python调试插件的问题

To Reproduce

提交代码至leetcode没有问题。
就是本地debug报错。屏蔽flake8(F821)也不行。

class Solution:
    def twoSum(self, nums: List[int], target: int) -> List[int]:

报错信息:

{
	"resource": "/d:/work/Workspaces/MYGitHub/leetcode/1.两数之和.py",
	"owner": "python",
	"code": "F821",
	"severity": 8,
	"message": "undefined name 'List'",
	"source": "flake8",
	"startLineNumber": 30,
	"startColumn": 28,
	"endLineNumber": 30,
	"endColumn": 28
}

Expected behavior

可以正常调试,不报错。

Your Environment

  • os: win7_x64
  • python version: 3.7.2
  • extension settings: ms-python.python-2019.2.5558
  • nodejs version: 10.15.3
  • vscode version: 1.32.1
  • extension version: ms-python.python-2019.2.5558
@Vigilans
Copy link
Contributor

Vigilans commented Mar 13, 2019

"message": "undefined name 'List'"

add from typing import List

@jdneo
Copy link
Member

jdneo commented Mar 14, 2019

You can have a try as @Vigilans said.

For now, the leetcode extension does not have the syntax highlighting feature there. So if users want to have this feature, they need to install some language-specific extensions, also there are some additional works to do to make them work together.

@jlhxxxx
Copy link
Author

jlhxxxx commented Mar 14, 2019

"message": "undefined name 'List'"

add from typing import List

Thank you, it works.

@jdneo jdneo closed this as completed Mar 15, 2019
@illuca
Copy link

illuca commented Dec 11, 2019

def twoSum(self, nums: 'List[int]', target: int) -> 'List[int]':
add '' to List

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants