KotlinIsland / KotlinIsland/basedmypy
Specialcase known `dict` constructors
- Dominant language
- Python
- Stars
- 202
- Forks
- 6
- PR merge metrics
- No merged PRs in 30d
Description
```py
from typing import TypedDict
from collections import defaultdict, OrderedDict, UserDict
class Movie(TypedDict):
name: str
year: int
movie_literal: Movie = {"name": "asdf", "year": 2}
movie_dict_kw: Movie = dict(name="asdf", year=2)
movie_dict_literal: Movie = dict({"name":"asdf", "year":2}) # expression has type "Dict[str, object]"
movie_defaultdict_kw: Movie = defaultdict(name="asdf", year=2) # expression has type "defaultdict[, object]"
movie_defaultdict_literal: Movie = defaultdict(str, {"name": "asdf", "year": 2}) # expression has type "defaultdict[str, object]"
movie_defaultdict_dict_kw: Movie = defaultdict(str, dict(name="asdf", year=2)) # expression has type "defaultdict[str, object]"
movie_userdict_literal: Movie = UserDict({"name": "asdf", "year": 2}) # expression has type "UserDict[str, object]"
movie_ordereddict_literal: Movie = OrderedDict({"name": "asdf", "year": 2}) # expression has type "OrderedDict[str, object]"
```
Contributor guide
Research direction
Use the TypedDict examples in the issue as the starting point, and inspect how the checker currently infers types for dict, defaultdict, OrderedDict, and UserDict constructors. The work is done when the shown constructor forms are treated consistently with the TypedDict assignments and their inferred types no longer produce the indicated mismatches.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- devtools
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100