I'm working on a Google AppEngine project and I recently upgraded my pylint version to:
No config file found, using default configuration
pylint 1.5.6,
astroid 1.4.6
Python 2.7.10 (default, Oct 23 2015, 19:19:21)
This seems to have broken some type inferencing. Specifically, GAE's ndb
uses a decorator and a generator function to return a "Future" object like this:
@ndb.tasklet
def coroutine_like(item_id):
# do something here...
item = yield EntityType.get_by_id_async(item_id)
raise ndb.Return(item)
I might call it something like this:
future = coroutine_like('12345')
# Do other stuff
entity = future.get_result()
Previously, I didn't have any problems with the linter here. Now I'm getting:
E: 42,17: Generator 'generator' has no 'get_result' member (no-member)
E: 48,17: Generator 'generator' has no 'get_result' member (no-member)
E: 60,25: Generator 'generator' has no 'get_result' member (no-member)
E: 74, 8: Generator 'generator' has no 'wait' member (no-member)
E: 88, 8: Generator 'generator' has no 'wait' member (no-member)
E: 95,17: Generator 'generator' has no 'get_result' member (no-member)
I realize that I can # pylint: disable=no-member
those lines individually but that would be cumbersome. I also realize that I can suppress that warning at the module level by adding the suppression code at the module level and I can globally suppress the warning by modifying my pylintrc file. I don't really want to do those things. I would much rather (somehow) tell pylint that things decorated with the @ndb.tasklet
decorator return ndb.Future
instances. I've seen that there are ways to register type-inferencing helpers1 for pylint, but I'm not sure how to make them work with my decorator of a generator function.
1Note that is a pretty old blog post... I think that logilab.astng
is no longer in use and now you would use astroid
instead, but that doesn't get me too much closer to the answer that I'm looking for...