ryananguiano / async_property

Python decorator for async properties.
MIT License
81 stars 8 forks source link

pyright says it is not awaitable #17

Open irux opened 11 months ago

irux commented 11 months ago

Description

I am having problems with pyright because of the types. when I try to await an async_cached_property I get the following hint:

  C:\bakdata\kpops\kpops\component_handlers\topic\proxy_wrapper.py:87:39 - error: "AsyncCachedPropertyDescriptor" is not awaitable (reportGeneralTypeIssues)
  C:\bakdata\kpops\kpops\component_handlers\topic\proxy_wrapper.py:87:39 - error: "AwaitableOnly" is not awaitable (reportGeneralTypeIssues)

What I Did

https://github.com/bakdata/kpops/blob/2f7212fa00660b4219cb4532c734ac220b330bdd/kpops/component_handlers/topic/proxy_wrapper.py#L106

https://github.com/bakdata/kpops/blob/2f7212fa00660b4219cb4532c734ac220b330bdd/kpops/component_handlers/topic/proxy_wrapper.py#L37

ryananguiano commented 10 months ago

@irux I have a draft PR here to fix it: https://github.com/ryananguiano/async_property/pull/15/files

haven't tested it yet. maybe you can install from this branch and test it out?

felipetavares commented 7 months ago

@ryananguiano Just tried out the branch, it doesn't solve the issue:

  <REDACTED>:19:22 - error: "AsyncCachedPropertyDescriptor" is not awaitable
    "AsyncCachedPropertyDescriptor" is incompatible with protocol "Awaitable[_T_co@Awaitable]"
      "__await__" is not present (reportGeneralTypeIssues)
  <REDACTED>:19:22 - error: "AwaitableProxy" is not awaitable
    "AwaitableProxy" is incompatible with protocol "Awaitable[_T_co@Awaitable]"
      "__await__" is an incompatible type
        Type "() -> T@__await__" cannot be assigned to type "() -> Generator[Any, None, _T_co@Awaitable]"
          Function return type "T@__await__" is incompatible with type "Generator[Any, None, _T_co@Awaitable]"
            "object*" is incompatible with "Generator[Any, None, _T_co@Awaitable]" (reportGeneralTypeIssues)