aio-libs / aio-libs/aiohttp-security

Replace API functions

未關閉
#677 0 則留言 1 個 reaction 已指派 0 人 在 GitHub 檢視
主要語言
Python
星號
240
分支
70
平均合併
10 分鐘
30 天內合併 PR
3

描述

**Problem**

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

- If we want to allow other types for identity (e.g. #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.

貢獻指南

開啟貢獻指南

評估

這個 Issue 還沒有評估資料。

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。