Replies: 1 comment
-
|
As a follow up to this, when using the following code _T0 = TypeVar("_T0", bound=PType, contravariant=True)
_T1 = TypeVar("_T1", bound=PType, contravariant=True)
_T2 = TypeVar("_T2", bound=PType, contravariant=True)
_T3 = TypeVar("_T3", bound=PType, contravariant=True)
_T4 = TypeVar("_T4", bound=PType, contravariant=True)
_T5 = TypeVar("_T5", bound=PType, contravariant=True)
_T6 = TypeVar("_T6", bound=PType, contravariant=True)
_T7 = TypeVar("_T7", bound=PType, contravariant=True)
_T8 = TypeVar("_T8", bound=PType, contravariant=True)
_T9 = TypeVar("_T9", bound=PType, contravariant=True)
_T10 = TypeVar("_T10", bound=PType, contravariant=True)
_T11 = TypeVar("_T11", bound=PType, contravariant=True)
WorkerFunction = (
Callable[[], PType]
| Callable[[_T0], PType]
| Callable[[_T0, _T1], PType]
| Callable[[_T0, _T1, _T2], PType]
| Callable[[_T0, _T1, _T2, _T3], PType]
| Callable[[_T0, _T1, _T2, _T3, _T4], PType]
| Callable[[_T0, _T1, _T2, _T3, _T4, _T5], PType]
| Callable[[_T0, _T1, _T2, _T3, _T4, _T5, _T6], PType]
| Callable[[_T0, _T1, _T2, _T3, _T4, _T5, _T6, _T7], PType]
| Callable[[_T0, _T1, _T2, _T3, _T4, _T5, _T6, _T7, _T8], PType]
| Callable[[_T0, _T1, _T2, _T3, _T4, _T5, _T6, _T7, _T8, _T9], PType]
| Callable[[_T0, _T1, _T2, _T3, _T4, _T5, _T6, _T7, _T8, _T9, _T10], PType]
| Callable[[_T0, _T1, _T2, _T3, _T4, _T5, _T6, _T7, _T8, _T9, _T10, _T11], PType]
)pyright (pylance) becomes much slower whenever a file importing this code is opened. (I haven't taken benchmarks but things that were ostensibly instant are now taking two or three seconds.) |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hello, what is the best way to type check the following situation?
Let's say I want to write a library that takes function definitions from the end-user. However we want the user to get a type error if they pass a function that uses any types apart from those in a specific
Union. The solution I have working is:Now I could carry on in this direction and fix a large but finite upper bound to the number of arguments a function can take.... but is there a better way?
I've tried
but get the error
I thought about using a
TypeVarTuplebut couldn't figure out how to put a bound on it. Also I tried recursively creating theAllowedFuncdefinition but don't know how to perform the conversionA->(B ->C)toAxB -> C.Any help or hints would be much appreciated!
Beta Was this translation helpful? Give feedback.
All reactions