feat(DRAFT): DType.__eq__ as a TypeIs[...]#2050
Conversation
Very difficult to get the overloads working
Doesnt work for stable yet, but these are working
| # DTypes | ||
| dtypes = [ | ||
| i for i in nw.dtypes.__dir__() if i[0].isupper() and not i.isupper() and i[0] != "_" | ||
| i for i in nw.dtypes.__all__ if i[0].isupper() and not i.isupper() and i[0] != "_" |
There was a problem hiding this comment.
FIXME
Need some help getting this work again
https://results.pre-commit.ci/run/github/760058710/1739990897.pkejAgUjQ3CdKYXvgIDqPw
I don't understand what the two checks are doing https://narwhals-dev.github.io/narwhals/api-reference/dtypes/#narwhals.dtypes
Or why this seems to include Literal?
narwhals/utils/check_api_reference.py
Lines 42 to 49 in 228e478
`pyright` was yelling in `dtypes_test`
- I've played around with this for quite a while now - I don't think there's a satisfying way to get `__eq__` working the same as `isinstance_or_issubclass` - Generic `Datetime` & `Duration` are achievable
|
@MarcoGorelli I've added a little write-up for what I believe is the blocking issue. Maybe this is a naive question, why was |
|
Closing as not planned |
thanks @dangotbanned for looking into this, sorry i missed it we just mirrored what Polars does with regards to |
@MarcoGorelli All of this is near-identical to Lines 335 to 367 in 2bcc6bb |
What type of PR is this? (check all applicable)
Related issues
ignore[attr-defined]onDatetime#2049 (comment)ignore[attr-defined]onDatetime#2049 (comment)Checklist
If you have comments or can explain your changes, please do so below
Important
Seems that we can't represent this well in the current typing spec AFAICT.
See (dbadb09) message
https://typing.readthedocs.io/en/latest/spec/narrowing.html
So
__eq__currently describes the opposite of the spec: