Andrei Kulakov <andrei....@gmail.com> added the comment:

I haven't looked too much into typing module, so take this with a grain of 
salt, but my understanding is that TypedDict is a special construct (as the 
first sentence in the docs defines it), which can be used as a base. I think 
most users would consider something a kind of a class if it can be inherited 
from by a user-defined class, so this classification in the docs is useful.

Normally functions can't be used as a base of course. There's no "inheritable 
from" abc or anything like that and functions are not inherited from "function 
type". You generally don't care if something is a function, you care if it's a 
callable and test for that with `callable()`.

So in a sense a function is the most inherently duck typed object in Python.

The only way for a specific check of a function type is AFAIK 
type(known_function) == type(myobj), but this type of checking is discouraged.

So static checkers that run into a problem with this are probably assuming too 
much about what a function is or should be in Python.

To sum up, TypedDict is a kind of a construct between a class and a function 
that's more usefully documented as, and used as, a class. The docs make it very 
clear that it's not your usual, run of the mill class.

----------
nosy: +andrei.avk

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue41973>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to