-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Better error message for incompatible assignment to method #4507
Comments
Well, as my colleagues just pointed,
Closing this as it is not a bug. Thanks to @vmagamedov for explanations. |
Glad you found the problem. Nevertheless, mypy could have given a better
error message.
…On Jan 24, 2018 11:15, "Oleksandr Kovalchuk" ***@***.***> wrote:
Closed #4507 <#4507>.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#4507 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/ACwrMimdCRxxejbpcsKMQquvXmxIYac3ks5tN4FagaJpZM4Rrp1H>
.
|
Agreed. Callable types in base classes should probably have their own special clearer message. |
index
fieldAccording to python/mypy#4507, the issue is that `NamedTuple` inherits from `tuple`, and `tuple` defines a base method `tuple.count`. This causes a problem for mypy, and currently the best solution is to just pick a different name.
(Cross posted from #3950 (comment)) My experience was that I didn't initially understand that the assignment issue was to do with the assignment of the member (in my case Would an error message like the following be possible here (emphasis to show changes):
Maybe even add something like:
If there's scope to change the error code from For comparison, the method override error message is (to me) much clearer:
|
mypy doesn't seem to work well with `NamedTuple`. For more info, checkout python/mypy#9043 python/mypy#4507
Add None to some type annotations in gym.py in order to fix some mypy errors. Rename some fields in the Gym NamedTuple class in order to clarify their meanings and to fix a mypy error. The "count" field specifically causes a mypy error because mypy interprets the field's name as the "count" method that NamedTuple inherits from the base tuple class. According to the mypy devs, this is expected behavior and is not a bug: - python/mypy#4507 - python/mypy#17047
Note
I am not sure whether it should be reported here or to the typeshed repo. Reporting here for now. If this is a typeshed issue, I'll gladly open issue there and close this one.
If there is something special in
index
field inNamedTuple
, please point out to the corresponding documentation as I failed to find anything on topic.Description
Type
bug
Code to check
Actual behavior
Expected behavior
No errors while typechecking
Environment
Behavior is still the same when using mypy from master:
The text was updated successfully, but these errors were encountered: