On Mon, Aug 3, 2015 at 1:58 AM, Jean-Michel Pichavant
<jeanmic...@sequans.com> wrote:
> But if I get things right, with python 3.5 type hint checker, I'd be screwed, 
> as it is spefificaly designed to track this kind of "problem".
> What's the use of None then ? Any method returning None can only return None 
> or suffer the type checker retribution.
>
> I don't get it.

This is where you would use optional types. Optional[List[X]] is a
shorthand for the type Union[List[X], None].

In fact static type checking can be quite useful in this sort of case.
If you return Optional[List[X]] in one place, and you have some other
method that takes in the value but simply indicates that it takes
List[X], then the static checker will flag that as an error, and
you'll know that a part of your code likely isn't handling the None
case correctly.
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to