Conversation
Co-authored-by: m-aciek <9288014+m-aciek@users.noreply.github.com>
Co-authored-by: m-aciek <9288014+m-aciek@users.noreply.github.com>
Co-authored-by: m-aciek <9288014+m-aciek@users.noreply.github.com>
Co-authored-by: m-aciek <9288014+m-aciek@users.noreply.github.com>
Co-authored-by: m-aciek <9288014+m-aciek@users.noreply.github.com>
Co-authored-by: m-aciek <9288014+m-aciek@users.noreply.github.com>
…em redundant Co-authored-by: m-aciek <9288014+m-aciek@users.noreply.github.com>
Co-authored-by: m-aciek <9288014+m-aciek@users.noreply.github.com>
Co-authored-by: m-aciek <9288014+m-aciek@users.noreply.github.com>
for more information, see https://pre-commit.ci
This comment has been minimized.
This comment has been minimized.
sterliakov
left a comment
There was a problem hiding this comment.
Regarding str vs Iterable[str]: are you sure it's actually a good thing to do? I hate pandas decision to prohibit passing a single string as DataFrame columns, it adds unnecessary friction to quickly creating a one-off dataframe (one has to do columns=list('abc')). Is there a reason to reject passing str as Iterable[str] intentionally? Is it a common source of bugs in some codebase you know/work with?
|
Thank you for the review, I will update and benchmark the list/set for this case tomorrow, having an access to the desktop computer.
It was originally suggested by @JukkaL and I thought it was a good idea. I personally at least once in the past experienced or seen a bug that could have been prevented with such a check. But this makes me think that maybe a way to select an unsafe subtyping class may be a good addition, to offer better control for mypy users, to let use only one inheritance pair, instead of covering only all or none. |
Co-authored-by: Stanislav Terliakov <50529348+sterliakov@users.noreply.github.com>
This comment has been minimized.
This comment has been minimized.
|
I'm sorry, it takes me more than I thought to get back to this PR. It looks like #20577 addresses the case of the Iterable[str]/str separately. Probably we can drop this case here. I looked around for another cases of an unsafe subtyping, and the other one would be |
Co-authored-by: m-aciek <9288014+m-aciek@users.noreply.github.com>
for more information, see https://pre-commit.ci
|
As discussed in the parent issue, I've updated the PR to focus only on datetime/date case, using |
This comment has been minimized.
This comment has been minimized.
|
This is just a nit (I haven't reviewed the PR in depth but it seems generally right to me) but the name of the error code should probably be |
Co-authored-by: wyattscarpenter <wyattscarpenter@gmail.com>
|
According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅ |
Fixes #9015.
This PR introduces
safe-datetimeerror code, which makes mypy check fail for unsafe date and datetime classes inheritance, following @JukkaL's comment in the related issue.Before:
After:
This is Copilot agent's work with my prompts' guidance. I reviewed the produced code. The change includes tests and documentation.
Alternatives considered
PR history
usafe-subtypecode for other potential cases like date/datetime