Hi everyone! 👋 I've been trying out Claude Code for Python development over the past couple of weeks, and overall, I'm really impressed with its speed and suggestions for boilerplate code. It's been a fun (if a bit nerve-wracking) experience to evaluate.
However, I keep running into a specific issue that's making me second-guess some of its suggestions: the type hints it generates often seem... off. They look correct at a glance, but when I actually run mypy or pyright on the code, I get a bunch of errors.
A few examples from my notes:
* It suggested `-> List[Dict[str, Any]]` for a function that clearly returns a list of strings. The structure was wrong.
* It sometimes uses `Optional[...]` when a value is clearly required based on the function logic.
* For a dataclass, it inferred types from the `__init__` docstring instead of the actual assigned values, leading to mismatches.
I'm still new to evaluating these tools, so I'm wondering:
* Is this a common experience, or am I maybe using it wrong?
* Are there specific patterns or contexts where Claude Code's type inference tends to struggle?
* Do you find yourself having to manually correct the type hints often, or do you just ignore them and run a proper type checker later?
I'd love to hear about others' experiences. I want to trust the suggestions, but these inaccuracies make me double-check everything, which slows down the workflow it's supposed to speed up! 😅
Yeah, I've noticed that too, especially with nested structures. The other day it told me a function returned a `Dict[str, int]` when it was clearly a `Dict[str, List[str]]`. Made mypy yell at me.
I'm still figuring out when to trust it. Do you find it gets worse with decorators or async functions? I feel like that's where mine gets confused.
Containers are magic, but I want to know how the magic works.