Skip to content

support no-member and type inference for attrs classes? #724

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

Open
belm0 opened this issue Nov 19, 2019 · 3 comments
Open

support no-member and type inference for attrs classes? #724

belm0 opened this issue Nov 19, 2019 · 3 comments
Labels
Enhancement ✨ Improvement to a component Help wanted 🙏 Outside help would be appreciated, good for new contributors

Comments

@belm0
Copy link
Contributor

belm0 commented Nov 19, 2019

Currently it seems that the attrs plugin only aims to avoid false warnings.

I'd like it to also support detection of nonexistent members (no-member), and be able to use available member type information.

I don't observe that astroid does either of these currently, and the plugin tests are limited to "does a Factory dict attribute infer as Unknown".

@PCManticore
Copy link
Contributor

Would you be able to submit a patch? While I agree that makes sense, it's not something we can prioritize now, but having a PR from a contributor would definitely improve the attrs support.

@PCManticore PCManticore added Enhancement ✨ Improvement to a component Help wanted 🙏 Outside help would be appreciated, good for new contributors labels Nov 19, 2019
@belm0
Copy link
Contributor Author

belm0 commented Nov 19, 2019

correction: no-member works (it's no different than plain class attributes)

and I guess before wanting type annotations to work for attrs classes, it should work on plain classes:

class Test:
    def foo(self): pass

class AttribClass:
    x: int
    o = Test()
    o2: Test

obj = AttribClass()
assert obj.x
assert obj.y  # "Instance of 'AttribClass' has no 'y' member"
assert obj.o.foo2()  # "Instance of 'Test' has no 'foo2' member"
assert obj.o2.foo2()  # expected error

@webknjaz
Copy link

webknjaz commented Feb 10, 2020

Here's a test case for this issue that demonstrates the problem: #750

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement ✨ Improvement to a component Help wanted 🙏 Outside help would be appreciated, good for new contributors
Projects
None yet
Development

No branches or pull requests

3 participants