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
However what if the argument list of parent is much longer, or there is function further_upstream which has its own argument list and must call upstream? Are you required to enumerate the arguments and their types from all the downstream functions? Or is there a graceful way to handle the "per-key" typing of **kwargs that I'm not seeing?
This problem is further compounded when dealing with overwritten methods in subclasses because MyPy will complain that the signature of the overwritten method is incompatible with the signature from the supertype.
The text was updated successfully, but these errors were encountered:
@ilevkivskyi using TypedDict was actually my first guess at how to solve this, however being able to specify the functions this "wraps" via decorator would be much preferred.
Uh oh!
There was an error while loading. Please reload this page.
Consider the following attempt at adding type hints to the functions
downstream
andupstream
:MyPy complains that
kwargs
has the typeDict[str, Any]
but that the argumentsa
andb
ofdownstream
requireType1
andType2
respectively.I understand that the solution to this error is to rewrite
upstream
in the following way:However what if the argument list of parent is much longer, or there is function
further_upstream
which has its own argument list and must callupstream
? Are you required to enumerate the arguments and their types from all the downstream functions? Or is there a graceful way to handle the "per-key" typing of**kwargs
that I'm not seeing?This problem is further compounded when dealing with overwritten methods in subclasses because MyPy will complain that the signature of the overwritten method is incompatible with the signature from the supertype.
The text was updated successfully, but these errors were encountered: