Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

csv.register_dialect()'s dialect arg should accept csv.Dialect subclasses #13293

Open
jacobtylerwalls opened this issue Dec 24, 2024 · 0 comments · May be fixed by #13294
Open

csv.register_dialect()'s dialect arg should accept csv.Dialect subclasses #13293

jacobtylerwalls opened this issue Dec 24, 2024 · 0 comments · May be fixed by #13294

Comments

@jacobtylerwalls
Copy link
Contributor

mypy 1.14 raises this error for this code, bisected to c407a44, presumably for the same reason as #12808 and #3613.

error: Argument 2 to "register_dialect" has incompatible type "type[TestDialect]"; expected "type[Dialect]"  [arg-type]

This diff solves my use case:

diff --git a/mypy/typeshed/stdlib/_csv.pyi b/mypy/typeshed/stdlib/_csv.pyi
index 0e206a63b..21bf52303 100644
--- a/mypy/typeshed/stdlib/_csv.pyi
+++ b/mypy/typeshed/stdlib/_csv.pyi
@@ -85,7 +85,7 @@ def reader(
 ) -> _reader: ...
 def register_dialect(
     name: str,
-    dialect: type[Dialect] = ...,
+    dialect: type[Dialect | csv.Dialect] = ...,
     *,
     delimiter: str = ",",
     quotechar: str | None = '"',
@jacobtylerwalls jacobtylerwalls changed the title csv.register_dialect()'s dialect arg doesn't accept csv.Dialect subclasses csv.register_dialect()'s dialect arg should accept csv.Dialect subclasses Dec 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant