Thanks to visit codestin.com
Credit goes to github.com

Skip to content

refactor: remove __getattr__ reflection in keyword_factory#35983

Open
Ruthwik-Data wants to merge 2 commits into
langgenius:mainfrom
Ruthwik-Data:main
Open

refactor: remove __getattr__ reflection in keyword_factory#35983
Ruthwik-Data wants to merge 2 commits into
langgenius:mainfrom
Ruthwik-Data:main

Conversation

@Ruthwik-Data
Copy link
Copy Markdown

@Ruthwik-Data Ruthwik-Data commented May 9, 2026

Removes the __getattr__ magic method from the Keyword class in keyword_factory.py.

All methods (create, add_texts, text_exists, delete_by_ids, delete, search) are already explicitly defined on the class, making the dynamic reflection via getattr unnecessary. Removing it improves type safety and makes bugs easier to catch.

Closes #24487
Closes #34278

Removed dynamic attribute access for keyword processor.
@Ruthwik-Data Ruthwik-Data requested a review from JohnJyong as a code owner May 9, 2026 16:57
@dosubot dosubot Bot added size:XS This PR changes 0-9 lines, ignoring generated files. refactor labels May 9, 2026
Add feature file for creating knowledge base datasets with scenarios for dataset creation and navigation.
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 9, 2026

Pyrefly Diff

base → PR
--- /tmp/pyrefly_base.txt	2026-05-09 17:26:59.144129294 +0000
+++ /tmp/pyrefly_pr.txt	2026-05-09 17:26:47.032073332 +0000
@@ -4443,8 +4443,14 @@
   --> tests/unit_tests/core/rag/datasource/keyword/test_keyword_factory.py:37:23
 ERROR `test_keyword_getattr_returns_callable_and_raises_for_invalid_attributes.Processor` is not assignable to attribute `_keyword_processor` with type `BaseKeyword` [bad-assignment]
   --> tests/unit_tests/core/rag/datasource/keyword/test_keyword_factory.py:75:34
+ERROR Object of class `Keyword` has no attribute `custom` [missing-attribute]
+  --> tests/unit_tests/core/rag/datasource/keyword/test_keyword_factory.py:77:12
+ERROR Object of class `Keyword` has no attribute `value` [missing-attribute]
+  --> tests/unit_tests/core/rag/datasource/keyword/test_keyword_factory.py:80:13
 ERROR `None` is not assignable to attribute `_keyword_processor` with type `BaseKeyword` [bad-assignment]
   --> tests/unit_tests/core/rag/datasource/keyword/test_keyword_factory.py:82:34
+ERROR Object of class `Keyword` has no attribute `missing_method` [missing-attribute]
+  --> tests/unit_tests/core/rag/datasource/keyword/test_keyword_factory.py:84:13
 ERROR Class member `_DummyVector.add_texts` overrides parent class `BaseVector` in an inconsistent manner [bad-override]
   --> tests/unit_tests/core/rag/datasource/vdb/test_vector_base.py:20:9
 ERROR Argument `list[Document | SimpleNamespace]` is not assignable to parameter `texts` with type `list[Document]` in function `core.rag.datasource.vdb.vector_base.BaseVector._filter_duplicate_texts` [bad-argument-type]

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 9, 2026

Pyrefly Type Coverage

Metric Base PR Delta
Type coverage 0.00% 43.68% +43.68%
Strict coverage 0.00% 43.20% +43.20%
Typed symbols 0 21,962 +21,962
Untyped symbols 0 28,630 +28,630
Modules 0 2547 +2,547

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

refactor size:XS This PR changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Refactor/Chore] More e2e test [Chore/Refactor] remove some reflection by dict

1 participant