-
Notifications
You must be signed in to change notification settings - Fork 9
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
Rename to phantom-types? #20
Comments
Hi, @antonagestam! I am a big fan of your work! This package looks amazing. So, I am really looking forward to having something like this in our So, maybe you want to:
We also have a chat where we can discuss this: https://t.me/drypython |
Hi @sobolevn! First of all, thanks for reaching out! As you know, a lot of your work inspires me as well. At this point I don't feel like giving up control of the library. I have a few ideas for types that I want to implement, and I want to see how working with the library as is works when used in a larger application. I might make some drastic API changes for things that aren't as well polished as they could be yet. That said, I am very open to collaborating on this project and warmly welcome thoughts, concrete feedback, ideas and other forms of contribution. As for using this library for validation, I would look at the dacite example. We've been using dacite (without phantom types) in production for about 6 months for a large e-commerce project. It greatly helps in moving towards domain-driven/type-driven validation. I just finished work on implementing a wrapper around the phonenumbers lib which I think is interesting because it shows that it's possible to inject normalization into the types themselves (while seemingly obvious in hindsight, it took some thinking for me to figure out how well that would work). I still have a few unanswered questions when it comes to validation, I think mostly about how to deal with composite types in a nice way. For instance how to type a model where the phone numbers validity depends on a country code field. This should mostly be about how to pipe values to the correct places in instantiation though, and shouldn't necessarily affect the phantom type implementation. |
@sobolevn Ps. I hope my answer doesn't sound discouraging, it would be awesome to find a way to collaborate! |
Of course not! I know how fun it is to work on your own stuff when you can make all the decisions, take any steps, etc. So, in this case I will experiment on my own implementation of Here's an example of a phantom type: # some.py
def NotEmpty(i):
assert len(i) > 0 # or what-ever
return i
# some.pyi
class NotEmpty(Container[T]):
... This way we can truly remove types from runtime. Or |
@sobolevn That's an interesting solution! However, I don't think I would be satisfied with it for a few reasons:
Looking forward to inspecting the prototype! :) |
@sobolevn I experimented a bit with binding parsers to a dataclass field using |
https://kataskeue.com/gdp.pdf
The text was updated successfully, but these errors were encountered: