March 1, 2026

When empty lists spark a flame war

Python Type Checker Comparison: Empty Container Inference

Empty lists, big fights: Python devs split on just guess it vs write it down

TLDR: Python tools disagree on empty lists and dicts: either assume “anything” or make you write the type. Commenters are split between “type hints are goofy” and “strict is best,” with TypeScript comparisons—important because the wrong choice can hide real bugs.

Python’s latest kerfuffle isn’t about AI or frameworks—it’s about… empty lists. The article pits two camps: tools that shrug and say “anything goes” when you write x = [] (fast and easy but risk missing bugs), and tools that either peek at how you later use it or make you spell out the type up front. Stakes? Real. One example even hints at Instagram bugs slipping through when the “anything” path hides mistakes like mixing up add-one vs add-many.

The comments turned into a vibe check on Python’s soul. curiousgal sighed that type hints feel “goofy,” complaining about C++-style complexity creeping into a language known for chill vibes. Meanwhile IshKebab rides for Pyright’s “strict mode,” basically saying: yes, you have to write the types, yes it’s mildly annoying, but it works—and catches the bad stuff. jez added a world tour, noting JavaScript’s cousin TypeScript and Ruby have it worse, while loevborg flexed that TypeScript already does the “look at how you use it” trick (proof).

Then Boxxed dropped the spicy meta take: type hints limit Python in a good way, pushing you into a “sane subset.” Translation: less chaos, more clarity. The meme of the day? “Your empty list is a mystery box—label it or live dangerously.”

Key Points

  • Empty containers without annotations force type checkers to choose an inference strategy for element types.
  • Strategy 1 infers Any for elements (e.g., list[Any]), used mostly by Pyre, Ty, and Pyright, favoring simplicity and fewer errors but reducing type safety.
  • A real-world-inspired example shows the append vs extend bug going undetected when list[Any] is inferred.
  • Type checkers using Any can add warnings about Any insertions, encouraging explicit annotations but increasing developer burden.
  • Strategy 2 infers types from subsequent usage (e.g., list[int] after appending 1), offering precision but complicating cases with conflicting uses.

Hottest takes

“this can’t be the way..” — curiousgal
“Occasionally mildly annoying but IMO it’s clearly the best option.” — IshKebab
“steers you into a sane subset of the language.” — Boxxed
Made with <3 by @siedrix and @shesho from CDMX. Powered by Forge&Hive.