Skip to content

Commit 7fb0ef0

Browse files
committed
Merge branch 'master' into stable
Change-Id: I83e1efacfc0076341cc6b3754ce4f01c4f635cef
2 parents f993bad + ade985b commit 7fb0ef0

File tree

12 files changed

+88
-62
lines changed

12 files changed

+88
-62
lines changed

.appveyor.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ environment:
4646
PYTHON_VERSION: "3.11.x"
4747
PYTHON_ARCH: "64"
4848

49+
- PYTHON: "C:\\Python312"
50+
PYTHON_VERSION: "3.12.x"
51+
PYTHON_ARCH: "32"
52+
4953
matrix:
5054
fast_finish: false
5155

HISTORY.rst

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,24 @@
11
Release history
22
===============
3+
4+
8.5.0
5+
-----
6+
*05. November 2023*
7+
8+
* Add a pagegenerators filter option to check if a page is redirect (:phab:`T261549`)
9+
* Add support for ``vikidia:nl`` site
10+
* Replace MediaWiki API deprecated ``inprop=preload`` with ``preloadcontent`` (:phab:`T348910`)
11+
* Remove check for purge right from APISite.purgepages (:phab:`T349348`)
12+
* Add MediaInfo editLabels, AddClaim and removeClaim functions (:phab:`T348422`)
13+
* Drop unused ``Family.use_hard_category_redirects`` (:phab:`T348953`)
14+
* No longer drop site decorators for optimized codes (:phab:`T74424`)
15+
* Improve handling of uninitialized MediaInfo
16+
* Add support for ``vikidia:ar`` site
17+
* Make exception about missing mediainfo more friendly
18+
* L10N and i18n updates
19+
* Give visible error to user when there are no rights (:phab:`T345342`)
20+
21+
322
8.4.0
423
-----
524
*07. October 2023*

ROADMAP.rst

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,8 @@
11
Current release
22
---------------
33

4-
* Add a pagegenerators filter option to check if a page is redirect (:phab:`T261549`)
5-
* Add support for ``vikidia:nl`` site
6-
* Replace MediaWiki API deprecated ``inprop=preload`` with ``preloadcontent`` (:phab:`T348910`)
7-
* Remove check for purge right from APISite.purgepages (:phab:`T349348`)
8-
* Add MediaInfo editLabels, AddClaim and removeClaim functions (:phab:`T348422`)
9-
* Drop unused ``Family.use_hard_category_redirects`` (:phab:`T348953`)
10-
* No longer drop site decorators for optimized codes (:phab:`T74424`)
11-
* Improve handling of uninitialized MediaInfo
12-
* Add support for ``vikidia:ar`` site
13-
* Make exception about missing mediainfo more friendly
14-
* L10N and i18n updates
15-
* Give visible error to user when there are no rights (:phab:`T345342`)
16-
* **Python 3.6 support will be discontinued** and this is the last version supporting it.
4+
* Add support for new wikis (:phab:`T350231`, :phab:`T350237`, :phab:`T350243`, :phab:`T350375`)
5+
* **Python 3.6 support will be discontinued soon**.
176

187

198
Deprecations

pywikibot/__metadata__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212

1313
__name__ = 'pywikibot'
14-
__version__ = '8.5.0'
14+
__version__ = '8.5.1'
1515
__description__ = 'Python MediaWiki Bot Framework'
1616
__maintainer__ = 'The Pywikibot team'
1717
__maintainer_email__ = '[email protected]'

pywikibot/data/sparql.py

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#
55
# Distributed under the terms of the MIT license.
66
#
7+
from textwrap import fill
78
from typing import Optional
89
from urllib.parse import quote
910

@@ -135,10 +136,14 @@ def select(self,
135136
return result
136137

137138
def query(self, query: str, headers: Optional[Dict[str, str]] = None):
138-
"""
139-
Run SPARQL query and return parsed JSON result.
139+
"""Run SPARQL query and return parsed JSON result.
140+
141+
.. versionchanged:: 8.5
142+
:exc:``exceptions.NoUsernameError` is raised if the response
143+
looks like the user is not logged in.
140144
141145
:param query: Query text
146+
:raises NoUsernameError: User not logged in
142147
"""
143148
if headers is None:
144149
headers = DEFAULT_HEADERS
@@ -165,15 +170,15 @@ def query(self, query: str, headers: Optional[Dict[str, str]] = None):
165170
# not in case the response otherwise might have it in between
166171
strcontent = self.last_response.content.decode()
167172
if (strcontent.startswith('<!DOCTYPE html>')
168-
and 'https://commons-query.wikimedia.org' in url):
169-
if ('Special:UserLogin' in strcontent
170-
or 'Special:OAuth' in strcontent):
171-
message = ('You need to log in to Wikimedia Commons '
172-
'and give OAUTH permission. '
173-
'Open https://commons-query.wikimedia.org '
174-
'with browser to login and give permission.')
175-
raise NoUsernameError('User not logged in. ' + message)
176-
173+
and 'https://commons-query.wikimedia.org' in url
174+
and ('Special:UserLogin' in strcontent
175+
or 'Special:OAuth' in strcontent)):
176+
raise NoUsernameError(fill(
177+
'User not logged in. You need to log in to Wikimedia '
178+
'Commons and give OAUTH permission. Open '
179+
'https://commons-query.wikimedia.org with browser to '
180+
'login and give permission.'
181+
))
177182
return None
178183

179184
def ask(self, query: str,

pywikibot/families/wikipedia_family.py

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -30,34 +30,34 @@ class Family(family.SubdomainFamily, family.WikimediaFamily):
3030
'ja', 'zh', 'uk', 'vi', 'war', 'ar', 'pt', 'fa', 'ca', 'sr', 'id',
3131
'ko', 'no', 'ce', 'fi', 'tr', 'cs', 'hu', 'tt', 'sh', 'ro',
3232
'zh-min-nan', 'eu', 'ms', 'eo', 'he', 'hy', 'da', 'bg', 'cy', 'sk',
33-
'uz', 'azb', 'simple', 'et', 'be', 'kk', 'min', 'el', 'hr', 'lt', 'gl',
34-
'ur', 'az', 'sl', 'lld', 'ka', 'nn', 'th', 'hi', 'ta', 'bn', 'mk',
33+
'uz', 'azb', 'simple', 'et', 'be', 'kk', 'el', 'min', 'hr', 'lt', 'gl',
34+
'ur', 'az', 'sl', 'lld', 'ka', 'nn', 'hi', 'th', 'ta', 'bn', 'mk',
3535
'la', 'zh-yue', 'ast', 'lv', 'af', 'tg', 'my', 'mg', 'sq', 'mr', 'bs',
36-
'oc', 'te', 'ml', 'be-tarask', 'br', 'nds', 'ky', 'sw', 'lmo', 'jv',
37-
'new', 'pnb', 'vec', 'ht', 'pms', 'ba', 'ku', 'lb', 'su', 'ga', 'is',
38-
'szl', 'fy', 'ckb', 'cv', 'pa', 'tl', 'an', 'wuu', 'diq', 'io', 'sco',
39-
'vo', 'yo', 'ne', 'ha', 'kn', 'ia', 'gu', 'als', 'avk', 'crh', 'bar',
36+
'oc', 'te', 'ml', 'br', 'be-tarask', 'nds', 'ky', 'sw', 'lmo', 'jv',
37+
'new', 'pnb', 'vec', 'ht', 'pms', 'ku', 'ba', 'lb', 'su', 'ga', 'is',
38+
'szl', 'fy', 'ckb', 'cv', 'pa', 'tl', 'an', 'wuu', 'diq', 'io', 'vo',
39+
'sco', 'yo', 'ha', 'ne', 'kn', 'ia', 'gu', 'als', 'avk', 'crh', 'bar',
4040
'scn', 'bpy', 'qu', 'mn', 'nv', 'ig', 'ban', 'xmf', 'si', 'frr', 'tum',
41-
'ps', 'mzn', 'os', 'or', 'bat-smg', 'sah', 'cdo', 'gd', 'bug', 'bcl',
42-
'sd', 'yi', 'ilo', 'am', 'li', 'nap', 'gor', 'fo', 'hsb', 'map-bms',
43-
'mai', 'shn', 'eml', 'ace', 'zh-classical', 'as', 'sa', 'wa', 'ie',
41+
'mzn', 'ps', 'os', 'or', 'bat-smg', 'sah', 'cdo', 'gd', 'bug', 'bcl',
42+
'sd', 'yi', 'ilo', 'am', 'li', 'nap', 'gor', 'fo', 'hsb', 'mai',
43+
'map-bms', 'shn', 'eml', 'ace', 'zh-classical', 'as', 'sa', 'wa', 'ie',
4444
'hyw', 'sn', 'mhr', 'lij', 'zu', 'hif', 'bjn', 'mrj', 'km', 'mni',
4545
'hak', 'sat', 'roa-tara', 'pam', 'rue', 'bh', 'nso', 'ary', 'dag',
46-
'so', 'mi', 'myv', 'nds-nl', 'se', 'vls', 'co', 'sc', 'bo', 'kw',
47-
'vep', 'glk', 'tk', 'kab', 'gan', 'rw', 'fiu-vro', 'gv', 'ab', 'zea',
46+
'so', 'mi', 'nds-nl', 'myv', 'se', 'co', 'vls', 'sc', 'bo', 'vep',
47+
'kw', 'glk', 'tk', 'kab', 'gan', 'rw', 'fiu-vro', 'gv', 'ab', 'zea',
4848
'ug', 'nah', 'skr', 'mt', 'frp', 'tly', 'udm', 'pcd', 'kv', 'gn',
4949
'csb', 'smn', 'ay', 'nrm', 'ks', 'lez', 'olo', 'mwl', 'lfn', 'mdf',
50-
'lo', 'stq', 'ang', 'kaa', 'fur', 'rm', 'lad', 'ext', 'gom', 'pap',
51-
'tw', 'tyv', 'koi', 'av', 'dsb', 'ln', 'dty', 'cbk-zam', 'dv', 'ksh',
52-
'za', 'gag', 'lg', 'bxr', 'pfl', 'szy', 'blk', 'tay', 'pag', 'pi',
50+
'stq', 'ang', 'kaa', 'lo', 'fur', 'rm', 'lad', 'ext', 'gom', 'pap',
51+
'tw', 'tyv', 'koi', 'av', 'ln', 'dsb', 'dty', 'cbk-zam', 'dv', 'ksh',
52+
'za', 'lg', 'gag', 'bxr', 'pfl', 'szy', 'blk', 'tay', 'pag', 'pi',
5353
'haw', 'awa', 'inh', 'krc', 'xal', 'pdc', 'to', 'atj', 'tcy', 'arc',
54-
'mnw', 'shi', 'jam', 'kbp', 'wo', 'ff', 'nia', 'anp', 'kbd', 'om',
55-
'nov', 'xh', 'ki', 'nqo', 'bi', 'tpi', 'tet', 'roa-rup', 'jbo', 'tn',
54+
'mnw', 'shi', 'jam', 'kbp', 'wo', 'ff', 'nia', 'anp', 'xh', 'om',
55+
'kbd', 'nov', 'ki', 'nqo', 'bi', 'tpi', 'tet', 'roa-rup', 'jbo', 'tn',
5656
'fj', 'kg', 'lbe', 'guw', 'ty', 'cu', 'rmy', 'trv', 'ami', 'srn',
57-
'mad', 'sm', 'alt', 'ltg', 'gcr', 'chr', 'ny', 'pcm', 'st', 'pih',
58-
'gpe', 'got', 'ss', 'gur', 'ee', 'kcg', 'bm', 'ts', 've', 'chy', 'rn',
59-
'ch', 'ady', 'ik', 'fon', 'guc', 'fat', 'pnt', 'iu', 'pwn', 'sg',
60-
'din', 'ti', 'kl', 'dz', 'cr',
57+
'mad', 'alt', 'sm', 'ltg', 'gcr', 'chr', 'ny', 'pcm', 'st', 'zgh',
58+
'pih', 'gpe', 'got', 'ss', 'dga', 'kcg', 'gur', 'ee', 'bm', 'ts', 've',
59+
'bbc', 'chy', 'rn', 'ch', 'ady', 'ik', 'fon', 'guc', 'fat', 'pnt',
60+
'iu', 'pwn', 'sg', 'din', 'ti', 'kl', 'dz', 'cr',
6161
]
6262

6363
# Sites we want to edit but not count as real languages

pywikibot/families/wikiquote_family.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ class Family(family.SubdomainFamily, family.WikimediaFamily):
3131
'es', 'tr', 'eo', 'sk', 'az', 'bs', 'ca', 'zh', 'sr', 'fi', 'lt', 'sl',
3232
'ar', 'id', 'su', 'bg', 'hy', 'hr', 'el', 'nn', 'sv', 'li', 'hu', 'ko',
3333
'sah', 'nl', 'ja', 'la', 'ta', 'ig', 'hi', 'as', 'gl', 'gu', 'ur',
34-
'tl', 'guw', 'be', 'te', 'vi', 'bn', 'cy', 'no', 'sq', 'ml', 'kn',
35-
'eu', 'ro', 'ku', 'uz', 'ka', 'da', 'sa', 'is', 'th', 'bcl', 'br',
36-
'mr', 'af', 'ky',
34+
'bjn', 'tl', 'guw', 'be', 'te', 'vi', 'bn', 'cy', 'no', 'sq', 'ml',
35+
'kn', 'eu', 'ro', 'ku', 'uz', 'ka', 'da', 'sa', 'is', 'th', 'bcl',
36+
'br', 'mr', 'af', 'ky',
3737
]
3838

3939
category_redirect_templates = {

pywikibot/families/wikisource_family.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ class Family(family.SubdomainFamily, family.WikimediaFamily):
2626

2727
languages_by_size = [
2828
'pl', 'en', 'ru', 'de', 'fr', 'zh', 'he', 'uk', 'it', 'ar', 'es',
29-
'mul', 'gu', 'cs', 'sr', 'pt', 'bn', 'sv', 'fa', 'ko', 'hu', 'ta',
30-
'ml', 'sa', 'te', 'tr', 'sl', 'be', 'vi', 'la', 'hy', 'nl', 'el', 'ja',
31-
'ro', 'fi', 'nap', 'az', 'ca', 'hr', 'br', 'no', 'id', 'kn', 'th',
29+
'mul', 'gu', 'cs', 'sr', 'pt', 'bn', 'sv', 'fa', 'ko', 'ta', 'hu',
30+
'ml', 'sa', 'te', 'tr', 'be', 'sl', 'la', 'vi', 'hy', 'nl', 'el', 'ja',
31+
'ro', 'fi', 'nap', 'az', 'ca', 'hr', 'br', 'id', 'no', 'kn', 'th',
3232
'hi', 'cy', 'vec', 'eo', 'is', 'mr', 'ban', 'pms', 'lij', 'da', 'et',
3333
'as', 'mk', 'yi', 'bg', 'jv', 'wa', 'li', 'lt', 'pa', 'or', 'eu', 'gl',
3434
'bs', 'sah', 'sk', 'su', 'zh-min-nan', 'fo',

pywikibot/families/wiktionary_family.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class Family(family.SubdomainFamily, family.WikimediaFamily):
4141
'ur', 'cy', 'ps', 'tg', 'kbd', 'he', 'vo', 'om', 'sl', 'af',
4242
'zh-min-nan', 'ms', 'scn', 'tl', 'pa', 'fy', 'sw', 'kk', 'ka', 'nn',
4343
'min', 'lv', 'nds', 'gor', 'sq', 'lb', 'bs', 'co', 'mn', 'pnb', 'nah',
44-
'yue', 'ckb', 'sa', 'km', 'diq', 'be', 'vec', 'nia', 'tk', 'mk', 'sm',
44+
'yue', 'ckb', 'sa', 'diq', 'km', 'be', 'vec', 'nia', 'tk', 'mk', 'sm',
4545
'hsb', 'ks', 'shy', 'bcl', 'su', 'ga', 'btm', 'gd', 'an', 'gom', 'mr',
4646
'ha', 'wo', 'mni', 'ia', 'bjn', 'ang', 'mt', 'tt', 'sd', 'blk', 'fo',
4747
'so', 'si', 'gn', 'ie', 'mi', 'csb', 'ug', 'guw', 'st', 'hif', 'jbo',

pywikibot/page/_wikibase.py

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ class WikibaseEntity:
9494

9595
DATA_ATTRIBUTES: Dict[str, Any] = {}
9696

97-
def __init__(self, repo, id_=None) -> None:
97+
def __init__(self, repo, id_: Optional[str] = None) -> None:
9898
"""
9999
Initializer.
100100
@@ -141,14 +141,14 @@ def _initialize_empty(self):
141141
for key, cls in self.DATA_ATTRIBUTES.items():
142142
setattr(self, key, cls.new_empty(self.repo))
143143

144-
def _defined_by(self, singular: bool = False) -> dict:
144+
def _defined_by(self, singular: bool = False) -> Dict[str, str]:
145145
"""
146146
Internal function to provide the API parameters to identify the entity.
147147
148148
An empty dict is returned if the entity has not been created yet.
149149
150150
:param singular: Whether the parameter names should use the singular
151-
form
151+
form
152152
:return: API parameters
153153
"""
154154
params = {}
@@ -159,7 +159,7 @@ def _defined_by(self, singular: bool = False) -> dict:
159159
params['ids'] = self.id
160160
return params
161161

162-
def getID(self, numeric: bool = False):
162+
def getID(self, numeric: bool = False) -> Union[int, str]:
163163
"""
164164
Get the identifier of this entity.
165165
@@ -406,6 +406,8 @@ def _defined_by(self, singular: bool = False) -> dict:
406406
"""
407407
Internal function to provide the API parameters to identify the entity.
408408
409+
.. versionadded:: 8.5
410+
409411
:param singular: Whether the parameter names should use the singular
410412
form
411413
:raise NoWikibaseEntityError: if this entity is associated with
@@ -500,13 +502,16 @@ def editLabels(self, labels: LANGUAGE_TYPE, **kwargs) -> None:
500502
>>> page = pywikibot.FilePage(repo, 'File:Sandbox-Test.svg')
501503
>>> item = page.data_item()
502504
>>> item.editLabels({'en': 'Test file.'}) # doctest: +SKIP
505+
506+
.. versionadded:: 8.5
503507
"""
504508
data = {'labels': labels}
505509
self.editEntity(data, **kwargs)
506510

507511
def addClaim(self, claim, bot: bool = True, **kwargs):
508-
"""
509-
Add a claim to the MediaInfo.
512+
"""Add a claim to the MediaInfo.
513+
514+
.. versionadded:: 8.5
510515
511516
:param claim: The claim to add
512517
:type claim: pywikibot.page.Claim
@@ -525,8 +530,9 @@ def addClaim(self, claim, bot: bool = True, **kwargs):
525530
claim.on_item = self
526531

527532
def removeClaims(self, claims, **kwargs) -> None:
528-
"""
529-
Remove the claims from the MediaInfo.
533+
"""Remove the claims from the MediaInfo.
534+
535+
.. versionadded:: 8.5
530536
531537
:param claims: list of claims to be removed
532538
:type claims: list or pywikibot.Claim

pywikibot/pagegenerators/_factory.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -913,7 +913,10 @@ def _handle_logevents(self, value: str) -> HANDLER_RETURN_TYPE:
913913
return self._parse_log_events(*params)
914914

915915
def _handle_redirect(self, value: str) -> HANDLER_RETURN_TYPE:
916-
"""Handle `-redirect` argument."""
916+
"""Handle `-redirect` argument.
917+
918+
.. versionadded:: 8.5
919+
"""
917920
if not value:
918921
# True by default
919922
value = 'true'

scripts/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,4 @@
2929
#
3030
# Distributed under the terms of the MIT license.
3131
#
32-
__version__ = '8.5.0'
32+
__version__ = '8.6.0'

0 commit comments

Comments
 (0)