From 3435c5b357e7bd0bfc1ea1720230f534b14a5c15 Mon Sep 17 00:00:00 2001 From: JPFrancoia Date: Wed, 25 Dec 2019 11:06:01 +0100 Subject: Renaming QueryParser from_browse and from_search methods to browse and search. Adding type hinting for these two methods. --- tpblite/models/utils.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'tpblite') diff --git a/tpblite/models/utils.py b/tpblite/models/utils.py index 1d5bda6..c6b6248 100644 --- a/tpblite/models/utils.py +++ b/tpblite/models/utils.py @@ -1,9 +1,12 @@ -from typing import Tuple +from typing import Tuple, TypeVar import random from urllib.request import Request, urlopen import urllib.error from purl import URL as pURL +# https://github.com/python/typing/issues/58#issuecomment-326240794 +T = TypeVar("T", bound="QueryParser") + class QueryParser: """Query object capable of getting html response given a search query and other @@ -27,14 +30,14 @@ class QueryParser: ) @classmethod - def from_search( + def search( cls, query: str, base_url: str, page: int, order: int, category: int - ): + ) -> T: segments = ("search", query, str(page), str(order), str(category)) return cls(base_url, segments) @classmethod - def from_browse(cls, base_url: str, category: int, page: int, order: int): + def browse(cls, base_url: str, category: int, page: int, order: int) -> T: segments = ("browse", str(category), str(page), str(order), "0") return cls(base_url, segments) -- cgit v1.2.3