From 3fd17e2ab04a7c458b39c322925f95e60d4137f8 Mon Sep 17 00:00:00 2001 From: naelsondouglas Date: Sat, 16 Oct 2021 15:30:26 -0300 Subject: [PATCH 1/2] removed a case of the default mutable argument pitfall --- requests_html.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/requests_html.py b/requests_html.py index 48e7fb2..22c5a43 100644 --- a/requests_html.py +++ b/requests_html.py @@ -431,12 +431,14 @@ class HTML(BaseParser): def __repr__(self) -> str: return f"" - def next(self, fetch: bool = False, next_symbol: _NextSymbol = DEFAULT_NEXT_SYMBOL) -> _Next: + def next(self, fetch: bool = False, next_symbol: _NextSymbol = None) -> _Next: """Attempts to find the next page, if there is one. If ``fetch`` is ``True`` (default), returns :class:`HTML ` object of next page. If ``fetch`` is ``False``, simply returns the next URL. """ + if _NextSymbol is None: + _NextSymbol = DEFAULT_NEXT_SYMBOL def get_next(): candidates = self.find('a', containing=next_symbol) From 3c0a50fc8ed6a7f5ef929e2076a3512895ddea62 Mon Sep 17 00:00:00 2001 From: naelsondouglas Date: Sat, 16 Oct 2021 15:31:25 -0300 Subject: [PATCH 2/2] fixed a typo --- requests_html.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/requests_html.py b/requests_html.py index 22c5a43..124d276 100644 --- a/requests_html.py +++ b/requests_html.py @@ -437,8 +437,8 @@ class HTML(BaseParser): next page. If ``fetch`` is ``False``, simply returns the next URL. """ - if _NextSymbol is None: - _NextSymbol = DEFAULT_NEXT_SYMBOL + if next_symbol is None: + next_symbol = DEFAULT_NEXT_SYMBOL def get_next(): candidates = self.find('a', containing=next_symbol)