python - PyCharm Community 2017.2 中 undefined variable 没有警告

标签 python pycharm code-inspection

我在 PyCharm Community Edition 2017.2 中打开的 Python 模块中有这段代码。

class Sample(object):
    def __init__(self):
        self.prop1 = 5
        self.prop2 = 10

    def method1(self):
        return foo

    def do_work(self):
        not_defined_func()


s = Sample()
s.method1()

bar = call_func

IDE 不会对一些相当严重的问题发出任何警告:

  1. 返回的变量foo尚未定义。
  2. 我分配 undefined variable call_func到变量bar .
  3. 我调用未定义的函数not_defined_func方法内部do_work

如何让 PyC​​harm 突出显示这些内容?我全新安装了 PyCharm,并拥有所有 InspectionsFile > Settings > Editor > Inspections > Python 中启用.

最佳答案

查看启用了哪个 python 解释器,请转至首选项 > 项目 > 项目解释器。设置python解释器然后应用它。 另请检查是否启用了检查。

关于python - PyCharm Community 2017.2 中 undefined variable 没有警告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46582924/

相关文章:

python - 获取行之间的杰卡德距离,无需在 python 中的列上执行一种热编码

python - Django 嵌套查询集

python - Flask 应用程序仅在计算机重新启动后才加载 css 更改

pycharm - graphlab.SFrame.show()错误: Requested port is unavailable: None

java - IdeaIC 检查 cli 失败,带有 '-changes' 选项

python - Python 内置对象的 __enter__() 和 __exit__() 定义在哪里?

python - 无法在 Centos 上安装 PyGreSql

python - 根据另一个日期列将日期列添加到数据框

github - Pycharm——如何将本地项目推送到远程组织存储库?

c# - 防止 TeamCity 将 ReSharper 代码检查建议(和提示)报告为警告?