Repository: scrapy/scrapy

Issue:
Wrong annotations in scrapy.crawler.CrawlProcess.crawl docstrings
<!--

Thanks for taking an interest in Scrapy!

If you have a question that starts with "How to...", please see the Scrapy Community page: https://scrapy.org/community/.
The GitHub issue tracker's purpose is to deal with bug reports and feature requests for the project itself.

Keep in mind that by filing an issue, you are expected to comply with Scrapy's Code of Conduct, including treating everyone with respect: https://github.com/scrapy/scrapy/blob/master/CODE_OF_CONDUCT.md

The following is a suggested template to structure your issue, you can find more guidelines at https://doc.scrapy.org/en/latest/contributing.html#reporting-bugs

-->

### Description
Some [IDEs recognize type annotations](https://www.jetbrains.com/help/pycharm/using-docstrings-to-specify-types.html) within docstring to make suggestions or raise warnings related to your code. In the Scrapy source, there are some annotations in the docstring that are wrong.

[Description of the issue]
This is a minor issue. The `scrapy.crawler.CrawlerProcess.crawl` method expects one mandatory positional argument, `crawler_or_spidercls`, and optional positional and keyword arguments through arbitrary argument lists. The type annotations for the arbitrary argument lists are wrong:
https://github.com/scrapy/scrapy/blob/3989f64baa39f7e42b0f798dec15cd250e0fba21/scrapy/crawler.py#L183-L185

When using `list` for `args` and `dict` for `kwargs`, the docstring suggests that the types of arguments passed through these lists should be `list` and `dict` respectively. According to [PEP 484](https://www.python.org/dev/peps/pep-0484/#arbitrary-argument-lists-and-default-argument-values), the types of `args` and `kwargs` will be automatically deduced as `Tuple[list, ...]` and `Dict[dict, int]`, so the specified types correspond to the values they contain. These annotations don't match the intention you have with this method, do they? BTW, `list` and `dict` weren't generic types for annotations until [Python 3.9](https://docs.python.org/3.9/whatsnew/3.9.html#pep-585-builtin-generic-types).

### Versions
```text
Scrapy       : 2.3.0
lxml         : 4.5.2.0
libxml2      : 2.9.10
cssselect    : 1.1.0
parsel       : 1.6.0
w3lib        : 1.22.0
Twisted      : 20.3.0
Python       : 3.8.5 | packaged by conda-forge | (default, Sep 16 2020, 17:43:11) - [Clang 10.0.1 ]
pyOpenSSL    : 19.1.0 (OpenSSL 1.1.1g  21 Apr 2020)
cryptography : 3.1
Platform     : macOS-10.14.6-x86_64-i386-64bit
```


Discussion:
Makes sense. For the record, we recently added a typing check in the CI process, so annotating the actual function definition is a possibility. Feel free to open a PR if you'd like.
I would like to take this issue up !
It also seems like a good first task, for me to try contributing to scrapy
As far as I am aware, I don't think we need to specify the data types for *args or **kwargs. So, would a fix that completely eliminates the specification of the data types (list and dict) be fine ?
> As far as I am aware, I don't think we need to specify the data types for *args or **kwargs. So, would a fix that completely eliminates the specification of the data types (list and dict) be fine ?

I think so.

Resolving patch:
diff --git a/scrapy/crawler.py b/scrapy/crawler.py
--- a/scrapy/crawler.py
+++ b/scrapy/crawler.py
@@ -180,9 +180,9 @@ def crawl(self, crawler_or_spidercls, *args, **kwargs):
         :type crawler_or_spidercls: :class:`~scrapy.crawler.Crawler` instance,
             :class:`~scrapy.spiders.Spider` subclass or string
 
-        :param list args: arguments to initialize the spider
+        :param args: arguments to initialize the spider
 
-        :param dict kwargs: keyword arguments to initialize the spider
+        :param kwargs: keyword arguments to initialize the spider
         """
         if isinstance(crawler_or_spidercls, Spider):
             raise ValueError(


Test patch: