[Tutor] How to type annotate complex dictionary containing lambdas?

Mats Wichmann mats at wichmann.us
Sun Nov 17 17:32:00 EST 2019


On 11/17/19 3:15 PM, David L Neil via Tutor wrote:
> On 18/11/19 11:09 AM, Mats Wichmann wrote:
>> On 11/17/19 12:46 PM, boB Stepp wrote:
>>
>>> Apparently because of the lambda outside of the list, I apparently
>>> must annotate them as "Callable". 
>>
>> yup, you're right, I spaced out that bit when trying to definitively 
>> tell you the value was either a str or a List.  Sigh...
> 
> There's another rule-of-thumb right there: if the parameter list 
> consists of many and/or many different types of data, perhaps consider 
> 'another way'...
> 
> 
> I've never tried an experiment (or, never found the need), but does mypy 
> (or...) actually and effectively, look two- and three-deep into 
> data-structures?

it does if told to, but you're likely right that this indicates 
something is overly complex.



More information about the Tutor mailing list