-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Incorrect handling of property overriding in subclasses. #844
Comments
True, but this seems like an edge right now. We might improve it though with Pylint / astroid 2.0. |
This seems to suddenly have started affecting my Tornado RequestHandler subclass since installing pylint-1.5.5. I get a slew of no-member errors from field accesses to objects returned by self.current_user (which is a property). Downgrading to pylint-1.5.4 and astroid-1.4.4 fixes this. Since the OP reports this as affecting pylint-1.5.4 and astroid-1.4.4, I wonder if I am experiencing a separate unrelated issue, or if the two are connected. |
Can you show me an example of how the RequestHandler subclass looks with respect to the current_user property? I'm trying to see if it is the same issue as this one. |
An example of this: from tornado.web import RequestHandler
class User(object):
def __init__(self):
self.foo = 'foo'
self.bar = 'bar'
self.qux = 'qux'
class MyRequestHandlerSubclass(RequestHandler):
def get_current_user(self):
return User()
class TestRequestHandler(MyRequestHandlerSubclass):
def get(self):
print(self.current_user.foo) The method The following is displayed by
|
With Tornado 6, calling methods like |
A workaround for Tornado 6 is the following astroid brain: # astroid/brain/brain_tornado.py
"""
Astroid hooks for tornado.
"""
import astroid
def requesthandler_funcs():
return astroid.parse(
"""
from tornado.web import RequestHandler
class RequestHandlerMock(RequestHandler):
def get_argument(name, default=None, strip=True):
return object()
"""
)
astroid.register_module_extender(astroid.MANAGER, 'tornado.web', requesthandler_funcs) |
pylint: 1.5.4
astroid 1.4.4
python: 2.7.11, 3.3.6, 3.5.1
If a class wants to override the getter or setter of a property in the parent class, then pylint incorrectly marks it as a "no-member" error, the code runs and works as expected.
I believe that the corollary to this case is that the following case is invalid, but marked as valid by pylint:
The text was updated successfully, but these errors were encountered: