Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I'm curious what you mean by "iterating variables have to be predeclared". In my experience mypy's type inference works with bog standard python constructs like a for loop that appends into a list that gets declared before the loop, aka:

  output = []
  for x in range(1):
      output.append(x)
      
  reveal_type(output)
  
  # note: Revealed type is 'builtins.list[builtins.int*]'


Maybe they're referring to the fact that if you do `for x in y` and y isn't properly annotated, then you will need to write

  x: MyType
  
  for x in y:
      ...
for x to be annotated properly.




Consider applying for YC's Summer 2026 batch! Applications are open till May 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: