typing icon indicating copy to clipboard operation
typing copied to clipboard

Spec: Specify how inheriting from Any works

Open gvanrossum opened this issue 1 year ago • 2 comments

I can't find anywhere in the current spec where we specify how inheriting from Any should work. I've heard that it's relied upon in typeshed. (E.g. class pmem(Any) in gevent and psutil, and class _NotImplementedType(Any) in builtins.)

gvanrossum avatar Dec 17 '23 22:12 gvanrossum

An enlightening use case in typeshed we use this for is typing Mock (specifically NonCallableMock)

There was also some discussion a few months back in https://mail.python.org/archives/list/[email protected]/thread/NEUCPDTUHMH77VOLXIG56Y7SDOECAKHB/#NEUCPDTUHMH77VOLXIG56Y7SDOECAKHB (reply from Eric, reply from me)

I'd propose that we treat it the same as subclassing an unknown symbol, although to my knowledge how that should be treated is not really specified either.

hauntsaninja avatar Dec 17 '23 22:12 hauntsaninja

Strong +1 for specifying the semantics for this.

Prior discussion on typing-sig: https://mail.python.org/archives/list/[email protected]/thread/NEUCPDTUHMH77VOLXIG56Y7SDOECAKHB/#NEUCPDTUHMH77VOLXIG56Y7SDOECAKHB.

superbobry avatar Dec 18 '23 10:12 superbobry