-
Notifications
You must be signed in to change notification settings - Fork 10.4k
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
type hints wanted! #5845
Comments
You can already use pydantic (or other libraries) via ItemAdapter. |
Thank you very much. However, i am curious that why need scrapy.Item? It seems that use pydantic.BaseModel directly is totally fine, then there is no need to use ItemAdapter. |
I don't think changing |
Oh ,i see. That's to say it is feasible to declare pydantic model in And I would suggest that :
class XxxxSpider(Spider):
def parse(self,response: Response)->Generator:
pass |
Adding typing hints to Scrapy is an on-going effort. |
@xdewx may not be the best solution, but I have done a little of work using Pydantic on Scrapy to validate this idea scrapy-pydantic-loader-poc it isn't perfect but I have used this here and there |
Summary
scrapy.Item
is just like a placeholder, neitheritem.field=value
norv=item.field
is supported.It would be nice if scrapy.Item is based on pydantic.BaseModel.
Motivation
For nice coding experience.
The text was updated successfully, but these errors were encountered: