✨ Make Depends and Security hashable again#14320
Conversation
|
I think
@zmievsa, what use cases do you have in mind? I mean for which it might be breaking change |
|
I am quite comfortable with frozen=true for my use cases. I only worry about frameworks based on fastapi that modify depends/security for some reason. But I don't know any frameworks like this |
Depends and Security hashable again
|
This pull request has a merge conflict that needs to be resolved. |
|
Thank you! I went with the It's now released in 0.121.3 🎉 Just as a note, FastAPI doesn't really have official support for extending its internals in ways that are not documented in the docs. So this is not a long-term commitment to keep some specific behavior, but a quick workaround to make things easier for current tools that interact with FastAPI internals in some way. At some point in the future, I'll refactor the internals of FastAPI to make them more explicitly private, and then also figure out the right ways to expose any points of connection with external components that currently need to interact with the internals in some way, and formalize that better. Before that, I need to handle a few issues, bugs, features, refactors, deprecations, etc. And then I'll be able to come back to this idea of figuring out how and what to expose. 🤓 Given that, I'll now close this one. Thank you! ☕ |
|
Thanks, @tiangolo ! I remember discussing it with you so it's all clear. However, I will compile a list of "here's what I use from fastapi internals" so that it's easier for you to make judgements when you decide to make the refactor and to make some of the internal parts a part of the public interface ❤️ |
This would be great, thank you @zmievsa! 🙌 If you could put your notes on a discussion, that would be super helpful. And @YuriiMotov will surely help me keep track of it so I don't forget. 😅 |
|
Cadwyn is currently broken on new FastAPI versions because
DependsandSecurityhave previously been hashable and we relied on this in our logic.Now they are unhashable dataclasses and I am a little stuck with how could fix it in Cadwyn. So I propose to make them hashable again. We have three options:
frozen=True, eq=Truewhich will work but can be a breaking change for some users of FastAPI (though I don't expect it to be a problem for most) because it will become frozenunsafe_hash=Truewhich will work and shouldn't be a breaking change but having an object with a mutable hash is probably not a great ideadef __hash__(self): return super().__hash__()which should be roughly equivalent to prior behavior where there was a hash but it was the default object hash instead of anything meaningfulAny of these options would fix Cadwyn. Are you open to any of them?