Comments (2)
If TypeVarTuple
supports list comprehension, that would be great
from typing import Generic
from typing import TypeVar
from typing import TypeVarTuple
_T = TypeVar("_T")
_Ts = TypeVarTuple("_Ts")
class ObjectRef(Generic[_T]): ...
def put(items: tuple[*_Ts]) -> tuple[ObjectRef[_T] for _T in _Ts]: ...
# backport to old python version
# def put(items: tuple[*_Ts]) -> tuple["ObjectRef[_T] for _T in _Ts"]: ...
def get(refs: tuple[*_Ts]) -> tuple[_T for ObjectRef[_T] in _Ts]: ...
We can do more things like.
from typing import Any
from typing import Callable
from typing import Generic
from typing import TypeVar
from typing import TypeVarTuple
_Callable_co = TypeVar("_Callable_co", covariant=True, bound=Callable)
_Ts = TypeVarTuple("_Ts")
_T = TypeVar("_T")
class ObjectRef(Generic[_T]): ...
class RemoteCallable(Generic[_Callable_co]):
def __call__(self: RemoteCallable[Callable[[*_Ts], Any]], *args: *tuple[ObjectRef[_T] for _T in _Ts]): ...
For a more realistic scenario, you can refer to https://github.com/zen-xu/sunray/blob/main/sunray/_internal/callable.py
from typing.
I think this is a duplicate of #1216
from typing.
Related Issues (20)
- Conformance tests: Align automated and manual scoring HOT 1
- Introduce a `Language` type to provide consistent language information of strings. HOT 5
- Spec: Version and platform checking underspecified HOT 6
- Clarify the float/int/complex special case HOT 5
- Clarify the implications of subclassing Any HOT 1
- Allow multiple `TypeVarTuple` in Generic Classes when they are wrapped. HOT 5
- pytype conformance tests crash if no `python3.11` executable is in `PATH` HOT 5
- Conformance test: make dataclass_hash.py not rely on `typing.Hashable`? HOT 1
- Proposal: Add coerced type narrowing similar to 'cast' HOT 1
- Idenity Type HOT 2
- [spec] clarify assert_type behavior as asserting type equivalence
- [spec] better clarify the difference between a runtime type object and a static type HOT 1
- [spec] a protocol type should be assignable to object? HOT 1
- [spec] define or replace the term "concrete type" HOT 1
- [spec] conceptual foundation and glossary entries for variance
- [spec] Overload processing order HOT 2
- Clarify signification of `Annotation` HOT 2
- A generic 'frame' type
- Enable Projects? HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from typing.