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

[BUG] IDE fails with autocompletion when working with opensearchpy.helpers #426

Closed
aimran-adroll opened this issue Jul 3, 2023 · 12 comments
Assignees
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@aimran-adroll
Copy link

aimran-adroll commented Jul 3, 2023

What is the bug?

Trying to debug why a standard editor like intellij/pycharm complains about the opensearch implemented functions, more specifically it thinks functions like Bool do not take any arguments!

Nothing major but with many lines of codes, the noise become grating.

Screenshot 2023-07-03 at 2 22 20 PM

How can one reproduce the bug?

Open a up to date intellij and open up the following snippets

def test_foo():
    from elasticsearch_dsl.query import Bool as EBool
    from opensearchpy.helpers.query import Bool as OBool

    # OpenSearch DSL. Notice the error
    OBool(must=[])

    # Elasticsearch DSL. Notice no errors
    EBool(must=[])

What is the expected behavior?

At the least, intellisense should be able to pick up on docs enough to provide intelligent completions etc.

What is your host/environment?

opensearch-py==2.2.0
elasticsearch-dsl==7.4.1

Intellij IDEA 2023.1.3/ OSX 13.4

Do you have any screenshots?

See above

Do you have any additional context?

Add any other context about the problem.

@aimran-adroll aimran-adroll added bug Something isn't working untriaged Need triage labels Jul 3, 2023
@saimedhi saimedhi removed the untriaged Need triage label Jul 3, 2023
@dblock
Copy link
Member

dblock commented Jul 5, 2023

@aimran-adroll propose a fix?

@saimedhi
Copy link
Collaborator

saimedhi commented Jul 6, 2023

I notice the same in pycharm
issue_426

@dannosaur
Copy link
Contributor

The .pyi files are wildly outdated, hence the intellisense errors. Deleting the .pyi files from your venv (while unorthodox) solves the issue. The proper solution requires a lot more work though - to go through every .pyi file and update them to match the API.

@aimran-adroll
Copy link
Author

@dblock Without knowing too much about opensearchpy internals, I am leaning towards @dannosaur's assessment. There isn't much there in those stub files from what I can tell.

@saimedhi saimedhi added the good first issue Good for newcomers label Sep 7, 2023
@saimedhi
Copy link
Collaborator

saimedhi commented Sep 7, 2023

Contributors, please feel free to address this issue and submit a PR with enhanced pyi files. Multiple PRs are welcome to achieve this. Your contributions are greatly appreciated!

@tannerjones4075
Copy link

I would like to work on this issue.

@tannerjones4075
Copy link

Could you officially assign me to this issue?

@marcosox
Copy link

The proper solution requires a lot more work though - to go through every .pyi file and update them to match the API.

There are tools to do this automatically:

@saimedhi
Copy link
Collaborator

Hello @marcosox, I've used mypy/stubgen for writing pyi files for the existing opensearch-py helpers in this repo, but we're still facing this issue.

@tannerjones4075
Copy link

tannerjones4075 commented Oct 24, 2023

@saimedhi
Copy link
Collaborator

Hello @tannerjones4075, I wanted to mention that for #287 , which introduced most of the helpers to opensearch-py, I used mypy/stubgen to create the pyi files.

@dblock
Copy link
Member

dblock commented Nov 10, 2023

I believe this should be resolved in #536 and #564, closing. If you see another type problem, open a new issue.

@dblock dblock closed this as completed Nov 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

6 participants