You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Run pylint (missing-docstring disabled) over this file (named typed_counter_pylint_check.py, find attached, remove the .txt suffix - typed_counter_pylint_check.py.txt):
$ pylint --disable=missing-docstring typed_counter_pylint_check.py
************* Module typed_counter_pylint_check
typed_counter_pylint_check.py:16:8: E1137: 'word_hist_typed' does not support item assignment (unsupported-assignment-operation)
------------------------------------------------------------------
Your code has been rated at 6.67/10 (...)
Expected behavior
$ pylint --disable=missing-docstring typed_counter_pylint_check.py
Your code has been rated at 10.00/10 (...)
This is caused by our brain plugin for the typing module, which overwrites the classes from the typing module to be easier to understand as generic types. But I don't think your use case is valid though, these classes are not intended to be used as concrete classes but rather as types. I don't think it's worth fixing it on our side.
@PCManticore Although your statement is true for many of the items in typing, some of the classes in typingare meant as a replacement. One (other) example is typing.NamedTuple as a replacement for collections.namedtuple.
The proof of the pudding is whether objects can be instantiated or not. For example you can't instantiate from typing.List, but you can instantiate from typing.NamedTuple. As you run the example above, you can see that one can also instantiate from typing.Counter and the code runs as expected.
After having discussed this on python/typing - Gitter I came to understand that instantiating directly from typing.Counter[str] is 'discouraged'. The preferred way is to import both collections.Counter and typing.Counter and use the typing variant only for the type annotations. Another consequence is that I have to explicitly have to annotate the word_hist_typed variable, as in
Steps to reproduce
typed_counter_pylint_check.py
, find attached, remove the.txt
suffix - typed_counter_pylint_check.py.txt):Current behavior
Expected behavior
pylint --version output
pylint 2.1.1
astroid 2.0.4
Python 3.7.0 (default, Jun 29 2018, 20:13:13)
[Clang 9.1.0 (clang-902.0.39.2)]
Note
This issue might be related to #2420.
The text was updated successfully, but these errors were encountered: