supabase-py icon indicating copy to clipboard operation
supabase-py copied to clipboard

Async client: Unresolved attribute reference 'execute' for class 'BaseFilterRequestBuilder'

Open KBeDevel opened this issue 11 months ago • 4 comments

Bug report

  • [x] I confirm this is a bug with Supabase, not with my own application.
  • [x] I confirm I have searched the Docs, GitHub Discussions, and Discord.

Describe the bug

[!NOTE] This report was created having in consideration the instruction made by @silentworks in the thread https://discord.com/channels/839993398554656828/1323676367765897297.

When using the async client and calling the execute method after an eq filter, PyCharm generate an Unresolved attribute reference 'execute' for class 'BaseFilterRequestBuilder' warning.

Exploring the source of the eq method I figured out the class BaseFilterRequestBuilder doesn't have a definition for the execute method and doesn't extend any class which define it. In fact, there is no definition in the whole "base_request_builder.py" file (PyCharm word search).

On the other hand, the select method is currently defined in AsyncRequestBuilder and returns an instance of AsyncSelectRequestBuilder (which extends AsyncQueryRequestBuilder). This dependency chain correctly provide the execute method definition.

To Reproduce

Steps to reproduce the behavior, please provide code snippets or a repository:

  1. Create and async client
from supabase import create_async_client

from app.env import env_vars

supabase = await create_async_client(
  supabase_url=env_vars['SUPABASE_URL'],
  supabase_key=env_vars['SUPABASE_KEY'],
)
  1. Create a select query to any table and schema:
result = await supabase.schema('stuff').table('regs').select().eq('key', key).execute()
  1. PyCharm generate a warning when calling the execute() method

Expected behavior

Call the execute method after eq without a warning.

Screenshots

image

System information

  • OS: GNU/Linux Fedora 41 KDE Workstation
  • Version of supabase: 2.11.0
  • Version of Python: 3.13.0
  • Version of Miniconda: 24.7.1
  • Version of Poetry: 1.8.4 (installed with pipx)

Additional context

Using PyCharm Community 2024.3.1.1 (243.22562.220)

KBeDevel avatar Jan 07 '25 20:01 KBeDevel

Seems to be something about:

# ignoring type checking as a workaround for https://github.com/python/mypy/issues/9319
class AsyncSelectRequestBuilder(BaseSelectRequestBuilder[_ReturnT], AsyncQueryRequestBuilder[_ReturnT]):  # type: ignore

where ~~type checkers~~ PyCharm only pick up on the first parent, and could not find execute() there

This is extremely annoying because my whole repo is drowned by warnings from .execute()/maybe_single()/single() and I can't see actual warnings from a glance. Maybe I should go back to VSCode...

Relevant JetBrains YouTrack issue: https://youtrack.jetbrains.com/issue/PY-52886/Incorrect-Unresolved-attribute-reference-when-using-multiple-inheritance

Glinte avatar Jan 08 '25 06:01 Glinte

Workaround: Install mypy or pyright, use their language server, and disable PyCharm's builtin "unresolved references" inspection image

Glinte avatar Jan 08 '25 07:01 Glinte

Now I'm not sure if this belongs here... I mean, this seems to be an issue with PyCharm itself and not supabase-py. Maybe, we should leave this issue open for tracking purposes.

KBeDevel avatar Jan 14 '25 15:01 KBeDevel

@KBeDevel yeah lets leave this one open for now. I want to investigate it a bit, as the issue did show up in my VS Code at one point too.

silentworks avatar Jan 14 '25 16:01 silentworks

I believe this error has been resolved by #1231, which removes all usages of generics in postgrest (and actually fixes typing). If it happens again, please let me know and I'll try to investigate further.

o-santi avatar Oct 02 '25 17:10 o-santi