jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/754071 )
Change subject: [doc] Update documentation for removeDisabledParts ......................................................................
[doc] Update documentation for removeDisabledParts
- add typing hints - enable list for defaults - add versionchanged - add Container to backports.py
Change-Id: I0ba172fdd3e8534048e5e04572a9e309d29362f0 --- M pywikibot/backports.py M pywikibot/textlib.py 2 files changed, 15 insertions(+), 15 deletions(-)
Approvals: Xqt: Looks good to me, approved jenkins-bot: Verified
diff --git a/pywikibot/backports.py b/pywikibot/backports.py index ee524c2..54c15e0 100644 --- a/pywikibot/backports.py +++ b/pywikibot/backports.py @@ -1,6 +1,6 @@ """This module contains backports to support older Python versions.""" # -# (C) Pywikibot team, 2014-2021 +# (C) Pywikibot team, 2014-2022 # # Distributed under the terms of the MIT license. # @@ -61,6 +61,7 @@
if PYTHON_VERSION < (3, 9): from typing import ( + Container, Dict, FrozenSet, Generator, @@ -77,7 +78,7 @@ ) else: from collections.abc import ( - Generator, Iterable, Iterator, Mapping, Sequence, + Container, Generator, Iterable, Iterator, Mapping, Sequence, ) from re import Match, Pattern Dict = dict # type: ignore[misc] diff --git a/pywikibot/textlib.py b/pywikibot/textlib.py index fdffe94..bd26f10 100644 --- a/pywikibot/textlib.py +++ b/pywikibot/textlib.py @@ -6,7 +6,7 @@
""" # -# (C) Pywikibot team, 2008-2021 +# (C) Pywikibot team, 2008-2022 # # Distributed under the terms of the MIT license. # @@ -19,9 +19,8 @@ from typing import NamedTuple, Optional, Union
import pywikibot -from pywikibot.backports import List +from pywikibot.backports import Container, Iterable, List, Tuple from pywikibot.backports import OrderedDict as OrderedDictType -from pywikibot.backports import Tuple from pywikibot.exceptions import InvalidTitleError, SiteDefinitionError from pywikibot.family import Family
@@ -433,32 +432,32 @@ return text
-def removeDisabledParts(text: str, tags=None, include=None, site=None) -> str: +def removeDisabledParts(text: str, + tags: Optional[Iterable] = None, + include: Optional[Container] = None, + site: Optional['pywikibot.site.BaseSite'] = None + ) -> str: """ Return text without portions where wiki markup is disabled.
- Parts that will be removed by default are + Parts that will be removed by default are: + * HTML comments * nowiki tags * pre tags * includeonly tags * source and syntaxhighlight tags
+ .. versionchanged:: 7.0 + the order of removals will correspond to the tags argument + if provided as an ordered collection (list, tuple) :param tags: The exact set of parts which should be removed using keywords from textlib._get_regexes(). - :type tags: list, set, tuple or None - :param include: Or, in alternative, default parts that shall not be removed. - :type include: list, set, tuple or None - :param site: Site to be used for site-dependent regexes. Default disabled parts listed above do not need it. - :type site: pywikibot.Site - :return: text stripped from disabled parts. - .. note:: the order of removals will correspond to the tags argument - if provided as an ordered sequence (list, tuple) """ if not tags: tags = ['comment', 'includeonly', 'nowiki', 'pre', 'syntaxhighlight']
pywikibot-commits@lists.wikimedia.org