...

ocamoss

160

Karma

2025-09-24

Created

Recent Activity

  • 4 points0 commentspyrefly.org

    We tell the story of how we helped make pandas' public API type-complete, and how to prevent it from regressing

  • It's acknowledged at the end of the "infer any" strategy, but perhaps worded poorly.

    > To improve type safety in these situations, type checkers that infer Any for empty containers can choose to generate extra type errors that warn the user about the insertion of an Any type. While this can reduce false negatives, it burdens developers by forcing them to explicitly annotate every empty container in order to silence the warnings.

    ie: "type checkers that don't infer container types can emit an error and require users to annotate"

  • If you're referring to the `first_three_lines` example in strategy 3, Mypy would give the same error even if we changed the return value to something unrelated like `return ["something"]`.

  • Requiring the annotations on empty containers is the only way to have type safety if the type checker cannot infer the type of the container, like Pyright.

    If the type checker can infer a type then the annotation would only be required if the inferred type doesn't match the user's intent, which means one would need to add fewer annotations to an arbitrary working-but-unannotated program to satisfy the type checker.

HackerNews