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

Replace API functions #677

Open
Dreamsorcerer opened this issue Nov 20, 2023 · 0 comments
Open

Replace API functions #677

Dreamsorcerer opened this issue Nov 20, 2023 · 0 comments

Comments

@Dreamsorcerer
Copy link
Member

Dreamsorcerer commented Nov 20, 2023

Problem

The API functions don't support static typing well. For example:

  • If we want to allow other types for identity (e.g. Why is identity forced to be string? #397), then we can't put types on these public API functions, as we wouldn't know what the correct type is.
  • The context parameter must be typed as Any and default to None to be compatible with the API. However, some implementations may require a specific type for context and won't accept a default (e.g. aiohttp-admin). There's no way to validate this with a type checker.

Solution

I'm thinking the best approach will be to remove the API functions (everything in api.py), and then use the IdentityPolicy and AuthorizationPolicy classes directly.

A few tweaks will need to be made, but this should make it much easier to subclass and implement these with precise types.

Most of these functions are just calling the methods anyway, so there's not really any extra complexity to just call the methods directly.

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

No branches or pull requests

1 participant