PyDev displays undefined variable from import for 1 out of 2 vars

戏子无情 提交于 2019-12-11 04:38:32

问题


Issue

I have the following structure:

home.py
logic/brains/databeam.py

Inside databeam.py I have:

engine  = create_engine(databaseSettings(), pool_size = 20, max_overflow = 0)
Session = sessionmaker(bind = engine)
session = Session()

boom = 'boom'

And in home.py:

from logic.brains.databeam import session, boom

print session
print session.query()
print boom

Everything works as intended, but PyDev on eclipse shows me this:

This works when...

Instead of using from logic.brains.databeam import session as session, boom as boom, I do this:

import logic.brains.databeam
session = logic.brains.databeam.session
boom    = logic.brains.databeam.boom

But this seems untidy, is there a better way to show PyDev that the import works?


回答1:


A solution that I found to be reasonable is to suppress this type of error in PyDev altogether. I know this is not perfect, but far and away the best one I've come across.

How to change this setting:




回答2:


@Lars, I can not comment on previous post, so i will put my comment here. If you have an error "Undefined variable from import" like @Morgan Wilde had with query, you should put Warning on that option under tab Undefined not Imports.




回答3:


As a way to circumvent the issue, I used:

then a bunch of

and

will appear. To hide them:



来源:https://stackoverflow.com/questions/15523728/pydev-displays-undefined-variable-from-import-for-1-out-of-2-vars

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!