Open jorenham opened 1 week ago
some of the relevant code:
Perhaps this mypy.types.get_proper_type
function should return the supertype of a @type_check_only
type 🤔?
Or maybe it should use the return type of the overridden __class__
property (which I did in this case as well, but that didn't do much) if present?
Describe the problem
In
scipy.special
there are a lot of "ufuncs", which are callablesnumpy.ufunc
instances that have a bunch of extra attributes, methods, and automatically convert an vectorize the input. But thenumpy.ufunc
annotations are very limited, and not very helpfull when it comes to annotating the ufuncs inscipy.special
. So instead of annotating e.g.beta: np.ufunc
, I created a private@type_check_only
subtype ofnp.ufunc
, and annotated it to match the type-signatures ofscipy.special.beta
. But runningstubtest
on it, gives the following error:(
scipy.special._ufuncs._UFunc21f
is theufunc
subtype)The error message here isn't very helpful, and I don't see why it shouldn't be allowed. Because such a subtype is basically an intersection of
ufunc
and thebeta
-specific annotations (but in a way that pyright and cringe mypy also understand).See jorenham/scipy-stubs#189 for the gory details.
Maybe I'm missing something, but I tried this a bunch of different ways, and none of them seemed to get rid of this error, so this looks like a false positive to me 🤷🏻.
Gist to reproduce
No response
Severity
annoying but workaround is available
Your Environment