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

Route.methods nesting artifact #4

Closed
ahopkins opened this issue Mar 4, 2021 · 2 comments · Fixed by #8
Closed

Route.methods nesting artifact #4

ahopkins opened this issue Mar 4, 2021 · 2 comments · Fixed by #8

Comments

@ahopkins
Copy link
Member

ahopkins commented Mar 4, 2021

The Route.methods property is generally nested as follows:

{
    "/some/path": set("GET", "POST")
}

However, this level of nesting is not only a breaking change, it is not necessary. It is the result of an earlier iteration of the router that was since abandoned. It seems this artifact has remained, and is no longer necessary.


Can be solved:

    def _finalize_methods(self):
        self.methods = set()
        for handlers in self.handlers.values():
            self.methods.update(set(key.upper() for key in handlers.keys()))
@ahopkins
Copy link
Member Author

ahopkins commented Mar 4, 2021

In actuality, I believe the root cause of this is that Route.handlers no longer needs to be nested:

Change:

self.handlers = defaultdict(lambda: defaultdict(list))

To:

self.handlers = defaultdict(list)

However, much more edge case testing would need to be done before making that change.

@ahopkins
Copy link
Member Author

ahopkins commented Mar 4, 2021

#7 fixes the method issue, but leaving this open for further investigation regarding the handler nesting.

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 a pull request may close this issue.

1 participant