-
Notifications
You must be signed in to change notification settings - Fork 131
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
feat(DRAFT): DType.__eq__
as a TypeIs[...]
#2050
base: main
Are you sure you want to change the base?
Conversation
Very difficult to get the overloads working
Doesnt work for stable yet, but these are working
@@ -215,7 +215,7 @@ | |||
|
|||
# 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
BASE_DTYPES = { | |
"NumericType", | |
"DType", | |
"TemporalType", | |
"Literal", | |
"OrderedDict", | |
"Mapping", | |
} |
`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 |
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: