跳转到内容
View in the app

A better way to browse. Learn more.

彼岸论坛

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.
欢迎抵达彼岸 彼岸花开 此处谁在 -彼岸论坛

[Python] pycharm 被装饰过的函数参数提示问题

发表于
B = TypeVar("B", bound="Bot")
R = TypeVar("R")
P = ParamSpec("P")

class API(Generic[B, P, R]):
    def __init__(self, func: Callable[Concatenate[B, P], Awaitable[R]]) -> None:
        self.func = func

    def __set_name__(self, owner: Type[B], name: str) -> None:
        self.name = name

    @overload
    def __get__(self, obj: None, objtype: Type[B]) -> "API[B, P, R]": ...

    @overload
    def __get__(
        self, obj: B, objtype: Optional[Type[B]]
    ) -> Callable[P, Awaitable[R]]: ...

    def __get__(
        self, obj: Optional[B], objtype: Optional[Type[B]] = None
    ) -> "API[B, P, R] | Callable[P, Awaitable[R]]":
        if obj is None:
            return self

        return partial(obj.call_api, self.name)  # type: ignore

    async def __call__(self, inst: B, *args: P.args, **kwds: P.kwargs) -> R:
        return await self.func(inst, *args, **kwds)
    

可以参考这个库的代码 https://github.com/nonebot/adapter-dodo/blob/83d55b09a9787c55d06fb01a5bb9c1f2d6a61fde/nonebot/adapters/dodo/utils.py#L39

像下面这个函数 https://github.com/nonebot/adapter-dodo/blob/83d55b09a9787c55d06fb01a5bb9c1f2d6a61fde/nonebot/adapters/dodo/bot.py#L298

被上面这个装饰器装饰过后就没有参数提示了... 在不换 IDE 的情况下该怎么做😭😭😭

Featured Replies

No posts to show

创建帐户或登录来提出意见

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.