Skip to content

Commit

Permalink
[doc] update ROADMAP.rst and CHANGELOG.rst
Browse files Browse the repository at this point in the history
also update documentation in api.Request

Change-Id: I502ee447ac07f6c6ac118a54f1d0cbbf11a0f225
  • Loading branch information
xqt committed Jun 16, 2024
1 parent 2b77d72 commit 8b5d37c
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 9 deletions.
12 changes: 12 additions & 0 deletions ROADMAP.rst
Original file line number Diff line number Diff line change
@@ -1,17 +1,29 @@
Current Release Changes
=======================

* No longer wait in :meth:`data.api.Request._http_request` for ``ImportError`` and ``NameError``
* Replace ``requests.utils.urlparse`` with ``urllib.parse.urlparse`` in
:func:`comms.http.get_authentication` (:phab:`T367649`)
* Show an appropiate message if ``requests_oauthlib`` package is required but missing (:phab:`T353387`)
* Retry ``DBUnexpectedError`` in :meth:`data.api.Request._internal_api_error` (:phab:`T367383`)
* Duplicated entries found in :mod:`pywikibot` were removed
* Pass ``None`` instead of an empty string as *expiry* argument in
:meth:`site.APISite.protect()<pywikibot.site._apisite.APISite.protect>` (:phab:`T367176`)
* Fix keyword argument in :meth:`Page.undelete()<page.BasePage.undelete>` when
calling :meth:`site.APISite.undelete()<pywikibot.site._apisite.APISite.undelete>` (:phab:`T367037`)
* Check whether :attr:`BaseBot.generator<bot.BaseBot.generator>` is None in :meth:`run()<bot.BaseBot.run>` method
* Add *namespaces* parameter to :meth:`Page.templates()<page.BasePage.templates>` and
:meth:`Page.itertemplates()<page.BasePage.itertemplates>` and require keyword arguments;
only use TEMPLATE namespace for meth:`Page.isDisambig()<page.BasePage.isDisambig>` (:phab:`T365199`)
* Drop pheetools support for :mod:`proofreadpage` which is no longer available upstreams (:phab:`T366036`)
* Raise :exc:`exceptions.SectionError` if a section does not exists on a page (:phab:`T107141`)
* Retry api request on ServerError (:phab:`T364275`, :phab:`T364393`)
* i18n updates

Current Deprecations
====================

* 9.2.0: Imports of :mod:`logging` functions from :mod:`bot` module is deprecated and will be desupported
* 9.2.0: *total* argument in ``-logevents`` pagegenerators option is deprecated;
use ``-limit`` instead (:phab:`T128981`)
* 9.0.0: The *content* parameter of :meth:`proofreadpage.IndexPage.page_gen` is deprecated and will be ignored
Expand Down
34 changes: 25 additions & 9 deletions pywikibot/data/api/_requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -675,7 +675,8 @@ def _http_request(self, use_get: bool, uri: str, data, headers,
no wait cycles for :exc:`ImportError` and :exc:`NameError`.
:return: a tuple containing requests.Response object from
http.request and use_get value
:func:`comms.http.request` and *use_get* value
:meta public:
"""
kwargs = {}
Expand Down Expand Up @@ -733,6 +734,8 @@ def _json_loads(self, response) -> dict | None:
:return: a data dict
:raises pywikibot.exceptions.APIError: unknown action found
:raises pywikibot.exceptions.APIError: unknown query result type
:meta public:
"""
try:
result = response.json()
Expand Down Expand Up @@ -813,6 +816,8 @@ def _handle_warnings(self, result: dict[str, Any]) -> bool:
.. versionchanged:: 7.2
Return True to retry the current request and Falso to resume.
:meta public:
"""
retry = False
if 'warnings' not in result:
Expand Down Expand Up @@ -851,6 +856,8 @@ def _default_warning_handler(self, mode: str, msg: str) -> bool | None:
the warning is not handled.
.. versionadded:: 7.2
:meta public:
"""
warnings = {
'purge': ("You've exceeded your rate limit. "
Expand Down Expand Up @@ -896,7 +903,9 @@ def _logged_in(self, code) -> bool:
def _internal_api_error(self, code, error, result) -> bool:
"""Check for ``internal_api_error_`` or readonly and retry.
:raises pywikibot.exceptions.APIMWError: internal_api_error or readonly
:raises pywikibot.exceptions.APIMWError: internal_api_error or
readonly
:meta public:
"""
iae = 'internal_api_error_'
if not (code.startswith(iae) or code == 'readonly'):
Expand All @@ -911,13 +920,14 @@ def _internal_api_error(self, code, error, result) -> bool:
# If the error key is in this table, it is probably a temporary
# problem, so we will retry the edit.
# TODO: T154011: 'ReadOnlyError' seems replaced by 'readonly'
retry = class_name in ['DBConnectionError', # T64974
'DBQueryError', # T60158
'DBQueryTimeoutError', # T297708
'DBUnexpectedError', # T360930
'ReadOnlyError', # T61227
'readonly', # T154011
]
retry = class_name in [
'DBConnectionError', # T64974
'DBQueryError', # T60158
'DBQueryTimeoutError', # T297708
'DBUnexpectedError', # T360930
'ReadOnlyError', # T61227
'readonly', # T154011
]

pywikibot.error('Detected MediaWiki API exception {}{}'
.format(e, '; retrying' if retry else '; raising'))
Expand Down Expand Up @@ -1184,6 +1194,8 @@ def _get_cache_dir(cls) -> Path:
remove Python main version from directoy name
:return: base directory path for cache entries
:meta public:
"""
path = Path(config.base_dir, 'apicache')
cls._make_dir(path)
Expand All @@ -1203,6 +1215,8 @@ def _make_dir(dir_name: str | Path) -> Path:
:param dir_name: directory path
:return: directory path as `pathlib.Path` object for test purpose
:meta public:
"""
if isinstance(dir_name, str):
dir_name = Path(dir_name)
Expand Down Expand Up @@ -1242,6 +1256,8 @@ def _cachefile_path(self) -> Path:
.. versionchanged:: 8.0
return a `pathlib.Path` object.
:meta public:
"""
return CachedRequest._get_cache_dir() / self._create_file_name()

Expand Down
5 changes: 5 additions & 0 deletions scripts/CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ commons_information
* Use transclusions of Information template as default generator
* Preload pages to make the script upto 10 times faster

illustrate_wikidata
^^^^^^^^^^^^^^^^^^^

* ``-always`` option is supported

interwikidata
^^^^^^^^^^^^^

Expand Down

0 comments on commit 8b5d37c

Please sign in to comment.