Skip to content
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

Wrong warning with OrderedSet #1657

Closed
nicoulaj opened this issue Sep 13, 2017 · 2 comments
Closed

Wrong warning with OrderedSet #1657

nicoulaj opened this issue Sep 13, 2017 · 2 comments

Comments

@nicoulaj
Copy link

Steps to reproduce

  1. Use OrderedSet 2.0.2
  2. Declare a variable such as self.children: OrderedSet[Context] = OrderedSet()

Current behavior

pylint emits a warning:

context/_context_impl.py:26: [E1136(unsubscriptable-object), Context.__init__] Value 'OrderedSet' is unsubscriptable

Expected behavior

No warning should be emitted, and my IDE (pycharm 2017.2.1) seems to be inferring the types correctly.
The OrderedSet class extends collections.MutableSet, so I would expect it to work out of the box.

pylint --version output

pylint 1.7.2, 
astroid 1.5.3
Python 3.6.2 (default, Aug 11 2017, 11:59:59) 
[GCC 7.1.1 20170622 (Red Hat 7.1.1-3)]
@nicoulaj
Copy link
Author

I was wrong, pycharm does emit a warning: Class 'type' does not define '__getitem__', so the '[]' operator cannot be used on its instances.
So I guess this must be fixed in OrderedSet ?

@PCManticore
Copy link
Contributor

Pylint is correct here, OrderedSet does not implement __getitem__ for classes, so that code will in fact raise an error when evaluated. This does not happen currently since annotations are not evaluated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants