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

Update type hints for Twisted 23.8.0 changes #6031

Closed
wRAR opened this issue Aug 30, 2023 · 1 comment · Fixed by #6034
Closed

Update type hints for Twisted 23.8.0 changes #6031

wRAR opened this issue Aug 30, 2023 · 1 comment · Fixed by #6034
Assignees
Labels

Comments

@wRAR
Copy link
Member

wRAR commented Aug 30, 2023

Twisted 23.8.0 has improved and fixed type hints around deferreds so now mypy prints some errors:

scrapy/core/scraper.py:184: error: Argument 1 to "addErrback" of "Deferred" has incompatible type "Callable[[Failure, Request, Response, Spider], None]"; expected "Callable[[Failure, Request, Response, Spider], Deferred[<nothing>]]"  [arg-type]
scrapy/core/scraper.py:184: error: Argument 3 to "addErrback" of "Deferred" has incompatible type "Response | Failure"; expected "Response"  [arg-type]
scrapy/core/scraper.py:185: error: Argument 1 to "addCallback" of "Deferred" has incompatible type "Callable[[Iterable[Any] | AsyncIterable[Any], Request, Response, Spider], Deferred[Any]]"; expected "Callable[[Any, Request, Response, Spider], Failure]"  [arg-type]
scrapy/core/scraper.py:185: error: Argument 3 to "addCallback" of "Deferred" has incompatible type "Response | Failure"; expected "Response"  [arg-type]
scrapy/core/downloader/__init__.py:157: error: Need type annotation for "deferred"  [var-annotated]
scrapy/core/engine.py:223: error: Incompatible return value type (got "None", expected "Failure")  [return-value]
scrapy/core/engine.py:300: error: Argument 1 to "addBoth" of "Deferred" has incompatible type "Callable[[Response | Request, Request], Deferred[Any] | Response]"; expected "Callable[[Any | Failure, Request], Failure]"  [arg-type]

(I omitted some unhelpful mypy tips). This needs reviewing, as it's not clear at the first glance if we have any problems with code and/or type hints.

@wRAR wRAR added the typing label Aug 30, 2023
@wRAR
Copy link
Member Author

wRAR commented Aug 30, 2023

I'm fine with not fixing it when we re-enable that Twisted version in 2.10.2 and letting the test fail for the 2.10 branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant