Skip to content

2 different Dialect types - one in csv module and other in _csv module #14667

@Dr-Irv

Description

@Dr-Irv

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:

class Dialect:

and
class Dialect:

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions