Skip to content

Commit

Permalink
revert turning close() into abstractmethod; avoid PageObject type alias
Browse files Browse the repository at this point in the history
  • Loading branch information
BurnzZ committed Nov 21, 2022
1 parent 04bcb9a commit 4a8807a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
3 changes: 1 addition & 2 deletions scrapy_poet/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ def __getitem__(self, fingerprint: str) -> Any:
def __setitem__(self, fingerprint: str, value) -> None:
pass

@abc.abstractmethod
def close(self) -> None:
def close(self) -> None: # noqa: B027
pass


Expand Down
5 changes: 2 additions & 3 deletions scrapy_poet/overrides.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@

logger = logging.getLogger(__name__)

PageObject = Type[ItemPage]
RuleAsTuple = Union[Tuple[str, PageObject, PageObject], List]
RuleAsTuple = Union[Tuple[str, Type[ItemPage], Type[ItemPage]], List]
RuleFromUser = Union[RuleAsTuple, ApplyRule]


Expand Down Expand Up @@ -92,7 +91,7 @@ def from_crawler(cls, crawler: Crawler) -> Crawler:

def __init__(self, rules: Optional[Iterable[RuleFromUser]] = None) -> None:
self.rules: List[ApplyRule] = []
self.matcher: Dict[PageObject, URLMatcher] = defaultdict(URLMatcher)
self.matcher: Dict[Type[ItemPage], URLMatcher] = defaultdict(URLMatcher)
for rule in rules or []:
self.add_rule(rule)
logger.debug(f"List of parsed ApplyRules:\n{self.rules}")
Expand Down

0 comments on commit 4a8807a

Please sign in to comment.