haystack icon indicating copy to clipboard operation
haystack copied to clipboard

Component protocol not correctly recognized by PyCharm anymore

Open mathislucka opened this issue 6 months ago • 1 comments

Describe the bug This PR leads to type errors with the PyCharm linter (2024.3.5 Professional Edition).

When using Pipeline.add_component PyCharm flags a typing issue (Expected type 'Component', got 'ChatPromptBuilder' instead).

When I change the component protocol back to the state before the PR it works without issues.

The property getter suggested by @denisw works for original Haystack components but not for custom component (not sure why).

Expected behavior The protocol should be recognized correctly. PyCharm is a major IDE.

Additional context Add any other context about the problem here, like document types / preprocessing steps / settings of reader etc.

To Reproduce Steps to reproduce the behavior

FAQ Check

System:

  • OS:
  • GPU/CPU:
  • Haystack version (commit or version number):
  • DocumentStore:
  • Reader:
  • Retriever:

mathislucka avatar Jun 03 '25 12:06 mathislucka

Seems related to this issue in PyCharm https://youtrack.jetbrains.com/issue/PY-61357/PyCharm-wrongly-flags-attributes-as-bad-implementations-of-Protocol-properties where their linter has issues with type checking against Protocols

sjrl avatar Jun 03 '25 14:06 sjrl