2 different `Dialect` types - one in `csv` module and other in `_csv` module
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 5.1k
- Forks
- 2.1k
- Avg merge
- 1d 19h
- Merged PRs (30d)
- 82
Description
Consider this code:
from csv import get_dialect
def foo(s: str):
dialect = get_dialect(s)
reveal_type(dialect)
mypy reports
dialects.py:6: note: Revealed type is "_csv.Dialect"
One would expect the result would be csv.Dialect.
There are 2 classes called Dialect in typeshed:
https://github.com/python/typeshed/blob/2480d7e7c74493a024eaf254c5d2c6f452c80ee2/stdlib/_csv.pyi#L28
and
https://github.com/python/typeshed/blob/2480d7e7c74493a024eaf254c5d2c6f452c80ee2/stdlib/csv.pyi#L61
get_dialect() is imported in csv.pyi from _csv.pyi, so the declaration in _csv.pyi is returning _csv.Dialect instead of csv.Dialect, so the type checkers see that as 2 separate classes.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by comparing stdlib/_csv.pyi with stdlib/csv.pyi, focusing on the imported get_dialect declaration and the two Dialect classes. Run the reproducing mypy snippet and confirm that reveal_type reports csv.Dialect rather than _csv.Dialect.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 52/100