Skip to content
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

Handle endpoint as callable on HALFor/UrlFor #21

Merged

Conversation

wo0dyn
Copy link
Contributor

@wo0dyn wo0dyn commented Mar 7, 2023

Rationale

The rationale behind this is the ability to refactor the name of an
endpoint without having to grep all HALFor/UrlFor to rename the
endpoint as strings too.

Example

from app.views import foo_endpoint

class FooResponse(HyperModel):
    links = LinkSet(
        {
             "self": HALFor(foo_endpoint)
        }
    )

If I use my IDE1 to rename foo_endpoint()bar_endpoint(), it will replace all occurrences of its reference in the codebase; without having to search for "foo_endpoint" string as well.

I don't know if that makes sense.

Note
Sorry about the refactoring on tests/app.py, but I didn't know any better way to expose a view in tests so I can test the change. Let me know if you have a better idea. 😊

Footnotes

  1. I personally use PyCharm for instance.

The rationale behind this is the ability to refactor the name of an
endpoint without having to grep all HALFor/UrlFor to rename the
endpoint as well.
@wo0dyn wo0dyn force-pushed the feature/use-callable-object-rather-than-str branch from 36535aa to fd600a1 Compare March 7, 2023 16:17
@jtc42
Copy link
Owner

jtc42 commented Mar 7, 2023

I really like this! Thanks so much for taking the time to submit the PR. I'm on the road right now but I'll take a proper look in the next couple of days and hopefully get a release out this weekend.

@jtc42 jtc42 merged commit 97d4105 into jtc42:main Mar 11, 2023
@jtc42
Copy link
Owner

jtc42 commented Mar 11, 2023

This has now been released in v0.5.0. Thanks again for the contribution!

@wo0dyn
Copy link
Contributor Author

wo0dyn commented Mar 13, 2023

Thank you for the new release. 🙏🏼

@wo0dyn wo0dyn deleted the feature/use-callable-object-rather-than-str branch March 13, 2023 08:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants