为什么pycharm在类或函数之外为None给出“预期类型”警告?

时间:2019-05-17 18:14:36

标签: python python-3.x pycharm

为什么pycharm在此代码的类或函数之外为None发出“预期类型”警告:

def blah():
    hiya = None  # type: dict   # No type warning

class Foo:
    bar = None  # type: dict    # No type warning

asf = None  # type: dict        # Expected type 'dict', got 'None' instead

1 个答案:

答案 0 :(得分:0)

我正在使用Pycharm,对我来说这很好

def blah():
hiya = None  # type: #dict   # No type warning

class Foo:
    bar = None  # type: #dict    # No type warning

asf = None  # type: #dict        # Expected type 'dict', got 'None' instead

也许是您设置中的内容。