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

Relax DictWriter.fieldnames closer to implementation #5994

Merged
merged 2 commits into from
Sep 2, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions stdlib/csv.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ from _csv import (
unregister_dialect as unregister_dialect,
writer as writer,
)
from typing import Any, Generic, Iterable, Iterator, Mapping, Sequence, Type, TypeVar, overload
from typing import Any, Collection, Generic, Iterable, Iterator, Mapping, Sequence, Type, TypeVar, overload
Copy link
Collaborator

@srittau srittau Sep 2, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One minor thing: We should import Collection, Iterable, Iterator, Mapping, and Sequence from collections.abc instead of typing.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, should that be changed here, or would it be preferable to do that separately? (I'd be happy to put together a subsequent PR which does these all together)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whatever works best for you.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

f8af7bc hopefully fixes this.

Just a thought -- would it be useful to have a flake8 plugin (custom to this repo) which checked for this? I suspect it would be fairly easy to create one and might make this preference more visible. If I recall correctly no-one would need to install anything extra, it would just be a file somewhere in the repo and some configuration in the pyproject.toml and flake8 would do the rest.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


if sys.version_info >= (3, 8):
from typing import Dict as _DictReadMapping
Expand Down Expand Up @@ -78,14 +78,14 @@ class DictReader(Generic[_T], Iterator[_DictReadMapping[_T, str]]):
def __next__(self) -> _DictReadMapping[_T, str]: ...

class DictWriter(Generic[_T]):
fieldnames: Sequence[_T]
fieldnames: Collection[_T]
restval: Any | None
extrasaction: str
writer: _writer
def __init__(
self,
f: Any,
fieldnames: Sequence[_T],
fieldnames: Collection[_T],
restval: Any | None = ...,
extrasaction: str = ...,
dialect: _DialectLike = ...,
Expand Down