You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It would be nice if Tuple and TypeVarTuple supported default arguments (particularly for use with Unpack).
Pitch
As a motivating example, I work with several 3rd-party C++ libraries with python bindings (e.g. PySide6). These bindings often have methods that do not support keyword arguments (C++ doesn't support keyword arguments natively). Sometimes, they have wrappers that forward *args to the particular binding. e.g.
that has default positional arguments for pos and delay.
Currently, AFAIK, there is no way to specify default arguments to either Tuple or TypeVarTuple. Without specifying default values, @overloads would be required (which one may argue is a sensible alternative, but is tedious when having to be performed for multiple methods in a large codebase):
Argument missing for parameter "args[n]"
Syntax Idea
I'm not sure how it would be implemented, but intuitively I am trying to achieve something like
MouseMoveArgs=tuple[
qt_api.QtWidgets.QWidget|qt_api.QtGui.QWindow,
qt_api.QtCore.QPoint=qt_api.QtCore.QPoint(),
int=-1, # c int
]
I'm not sure I fully understand your proposal here, but it sounds like you're proposing a change to the spec for tuple/TypeVarTuple. Discussions like that should happen over at https://github.com/python/typing rather than the mypy issue tracker, since they affect all users of Python typing, not just mypy users.
Uh oh!
There was an error while loading. Please reload this page.
Feature
It would be nice if
Tuple
andTypeVarTuple
supported default arguments (particularly for use withUnpack
).Pitch
As a motivating example, I work with several 3rd-party C++ libraries with python bindings (e.g.
PySide6
). These bindings often have methods that do not support keyword arguments (C++ doesn't support keyword arguments natively). Sometimes, they have wrappers that forward*args
to the particular binding. e.g.has C++ signatures
that has default positional arguments for
pos
anddelay
.Currently, AFAIK, there is no way to specify default arguments to either
Tuple
orTypeVarTuple
. Without specifying default values,@overloads
would be required (which one may argue is a sensible alternative, but is tedious when having to be performed for multiple methods in a large codebase):Syntax Idea
I'm not sure how it would be implemented, but intuitively I am trying to achieve something like
that I can then unpack
The text was updated successfully, but these errors were encountered: