fix: arun() returns CrawlResult directly for proper IDE type support (#1898)#1957
Open
fix: arun() returns CrawlResult directly for proper IDE type support (#1898)#1957
Conversation
…ner (#1898) CrawlResultContainer proxies attributes via __getattr__ which is invisible to type checkers. Since arun() always returns a single result, return CrawlResult directly so Pylance/Pyright can see .markdown, .html, etc. Deep crawl streaming (via DeepCrawlDecorator) still returns an AsyncGenerator — that path is unaffected.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
arun()now returnsCrawlResultdirectly instead of wrapping inCrawlResultContainer. This lets Pylance/Pyright see.markdown,.html, and all otherCrawlResultattributes without errors.CrawlResultContaineruses__getattr__proxy which is invisible to static type checkers — so even though the code worked at runtime, IDEs couldn't autocomplete or validate attribute access.DeepCrawlDecorator) is unaffected — it overrides the return type toAsyncGeneratorregardless.Changes
crawl4ai/async_webcrawler.py: ReturnCrawlResultdirectly from all three return paths inarun()tests/test_type_annotations.py: Updated test to verifyarun()is annotated as-> CrawlResultTest plan
arun()returnsCrawlResultinstance directly (verified withisinstance())result.markdownaccess