Scrapy, a fast high-level web crawling & scraping framework for Python.
Full typing for scrapy/link.py.
Andrey Rakhmatullinb50268c100c6
diff --git a/scrapy/link.py b/scrapy/link.pyindex 704649731..0868ae5ef 100644--- a/scrapy/link.py+++ b/scrapy/link.py@@ -4,6 +4,7 @@ This module defines the Link object used in Link extractors.For actual link extractors implementation see scrapy.linkextractors, orits documentation in: docs/topics/link-extractors.rst"""+from typing import Anyclass Link:@@ -26,16 +27,20 @@ class Link:__slots__ = ["url", "text", "fragment", "nofollow"]- def __init__(self, url, text="", fragment="", nofollow=False):+ def __init__(+ self, url: str, text: str = "", fragment: str = "", nofollow: bool = False+ ):if not isinstance(url, str):got = url.__class__.__name__raise TypeError(f"Link urls must be str objects, got {got}")- self.url = url- self.text = text- self.fragment = fragment- self.nofollow = nofollow-- def __eq__(self, other):+ self.url: str = url+ self.text: str = text+ self.fragment: str = fragment+ self.nofollow: bool = nofollow++ def __eq__(self, other: Any) -> bool:+ if not isinstance(other, Link):+ raise NotImplementedErrorreturn (self.url == other.urland self.text == other.text@@ -43,12 +48,12 @@ class Link:and self.nofollow == other.nofollow)- def __hash__(self):+ def __hash__(self) -> int:return (hash(self.url) ^ hash(self.text) ^ hash(self.fragment) ^ hash(self.nofollow))- def __repr__(self):+ def __repr__(self) -> str:return (f"Link(url={self.url!r}, text={self.text!r}, "f"fragment={self.fragment!r}, nofollow={self.nofollow!r})"