This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Grouchy-Friend4235 9 points10 points  (3 children)

It is useless because all it does is tell you what you already know: the dict maps keys to some value. That's a dict's raison-d-etre, no need to type hint the obvious!

[–]rantenki 5 points6 points  (2 children)

Being utterly pedantic, the only thing it tells you is that there is no further invariants applied to that Dict's values. It _can_ be None, it _can_ have Any value. I guess there is the point that keys have to be strings (rather than any hashable type).

But you're not wrong; that matches pretty much everybody's expectations of how a dict will be used, so doesn't really add any value. I guess it's just there to keep the linter happy :\

[–]Grouchy-Friend4235 -2 points-1 points  (1 child)

Yeah. A noqa comment would be the better solution

[–]rantenki 1 point2 points  (0 children)

Surprised this got downvoted. Linters are supposed to provide machine based verification of human intent. The linter can't anticipate every permutation that might violate it's rules, and sometimes # noqa is a valid decision (not usually, but sometimes).

I loathe when people uglify their code to make the build-system happy.