On 5 September 2016 at 04:13, Ivan Levkivskyi <levkivs...@gmail.com> wrote: > On 4 September 2016 at 19:59, Nick Coghlan <ncogh...@gmail.com> wrote: >> I suspect you'll have an easier time of it on that front if you >> include some examples of dynamically typed code that a well-behaved >> type-checker *must* report as correct Python code, such as: >> >> x: Optional[List[Any]] >> # This is the type of "x" *after* the if statement, not *during* it >> if arg is not None: >> x = list(arg) >> if other_arg is not None: >> # A well-behaved typechecker should allow this due to >> # the more specific initialisation in this particular branch >> x.extend(other_arg) >> else: >> x = None > > There are very similar examples in PEP 484 (section on singletons in > unions), > we could just copy those or use this example, > but I am sure Guido will not agree to word "must" (although "should" maybe > possible :-)
"Should" would be fine by me :) Cheers, Nick. -- Nick Coghlan | ncogh...@gmail.com | Brisbane, Australia _______________________________________________ Python-Dev mailing list Python-Dev@python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com