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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Compute all routes from FastAPI app once #24
Closed
Closed
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
I've used the tool pyupgrade[^1] to perform this cleanup, using the following command: ```console $ find examples fastapi_hypermodel tests -name "*.py" \ -exec pyupgrade --py37-plus {} \; ``` It could be useful to add this weapon in tox test suite for instance. [^1]: https://github.com/asottile/pyupgrade
I would remove Pydantic as a dependency for this project as it's already a dependency of FastAPI[^1] itself. [^1]: https://github.com/tiangolo/fastapi/blob/master/pyproject.toml#L45
Unless I'm mistaken, these two dependencies are not used in the project. I would remove them as well.
I didn't find any usage of this method in the project. And since it was defined with a protected scope (by convention), I don't think it should be used somewhere else.
wo0dyn
changed the title
refactor/remove bound app in hypermodel
Remove bound app in HyperModel
Mar 15, 2023
wo0dyn
force-pushed
the
refactor/remove-bound-app-in-hypermodel
branch
3 times, most recently
from
March 16, 2023 01:16
7f30819
to
c46ce44
Compare
Instead of keeping a reference to the FastAPI app, I think it's better to keep its routes. This way, on `HALFor()`, it's more convenient to retrieve a given route by its endpoint (aka route.name) rather than iterate on app.routes at every call.
wo0dyn
force-pushed
the
refactor/remove-bound-app-in-hypermodel
branch
from
March 16, 2023 01:21
c46ce44
to
0f58218
Compare
wo0dyn
commented
Mar 16, 2023
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.
A few more comments.
@@ -64,7 +64,7 @@ class UrlFor(UrlType): | |||
At this point, our custom type will behave as a normal Pydantic type, but won't do any hypermedia substitutions. | |||
For this, we must add our "magic" `__build_hypermedia__` method. | |||
|
|||
```python hl_lines="32-38" | |||
```python hl_lines="32-37" |
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.
I hope the range is still correct. 馃槰
wo0dyn
changed the title
Remove bound app in HyperModel
Compute all routes from FastAPI app once
Mar 17, 2023
Co-authored-by: Nicolas Dubois <nicolas.c.dubois@gmail.com>
This reverts commit 08145f9.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Rationale
There were 2 reasons for this PR:
HALFor.__build_hypermedia__()
.ChangeLog
object
I let you check each commit message for more details.