jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/999922?usp=email )
Change subject: [doc] Only use major and minor version numbers within documentation
......................................................................
[doc] Only use major and minor version numbers within documentation
Change-Id: I4afa2e42918f9a6dda3a547be51c363f2f6a878d
---
M pywikibot/data/api/_paraminfo.py
M pywikibot/family.py
M pywikibot/page/_basepage.py
M pywikibot/page/_filepage.py
M pywikibot/site/_apisite.py
M pywikibot/site/_generators.py
M tests/aspects.py
M tests/utils.py
8 files changed, 23 insertions(+), 14 deletions(-)
Approvals:
jenkins-bot: Verified
Xqt: Looks good to me, approved
diff --git a/pywikibot/data/api/_paraminfo.py b/pywikibot/data/api/_paraminfo.py
index eb5b03d..b7cb846 100644
--- a/pywikibot/data/api/_paraminfo.py
+++ b/pywikibot/data/api/_paraminfo.py
@@ -1,6 +1,6 @@
"""Object representing API parameter information."""
#
-# (C) Pywikibot team, 2014-2023
+# (C) Pywikibot team, 2014-2024
#
# Distributed under the terms of the MIT license.
#
@@ -442,7 +442,7 @@
def paraminfo_keys(cls) -> frozenset[str]:
"""Return module types.
- .. deprecated:: 8.4.0
+ .. deprecated:: 8.4
"""
return frozenset(['modules'])
@@ -451,6 +451,6 @@
def preloaded_modules(self) -> frozenset[str] | set[str]:
"""Return set of preloaded modules.
- .. deprecated:: 8.4.0
+ .. deprecated:: 8.4
"""
return self._preloaded_modules
diff --git a/pywikibot/family.py b/pywikibot/family.py
index 4542749..cf48d4f 100644
--- a/pywikibot/family.py
+++ b/pywikibot/family.py
@@ -57,7 +57,7 @@
:attr:`obsolete` setter was removed.
.. versionchanged:: 8.3
Having an initializer method a ``FutureWarning`` will be given.
- .. versionchanged:: 9.0.0
+ .. versionchanged:: 9.0
raises RuntimeError if an initializer method was found;
:meth:`__post_init__` classmethod should be used instead.
"""
diff --git a/pywikibot/page/_basepage.py b/pywikibot/page/_basepage.py
index 52d5248..6af8970 100644
--- a/pywikibot/page/_basepage.py
+++ b/pywikibot/page/_basepage.py
@@ -726,7 +726,7 @@
def editTime(self) -> pywikibot.Timestamp:
"""Return timestamp of last revision to page.
- .. deprecated:: 8.0.0
+ .. deprecated:: 8.0
Use :attr:`latest_revision.timestamp<latest_revision>`
instead.
"""
diff --git a/pywikibot/page/_filepage.py b/pywikibot/page/_filepage.py
index ec71d41..94dc98f 100644
--- a/pywikibot/page/_filepage.py
+++ b/pywikibot/page/_filepage.py
@@ -6,7 +6,7 @@
* FileInfo: a structure holding imageinfo of latest revision of FilePage
"""
#
-# (C) Pywikibot team, 2008-2023
+# (C) Pywikibot team, 2008-2024
#
# Distributed under the terms of the MIT license.
#
@@ -263,7 +263,7 @@
def usingPages(self, **kwargs): # noqa: N802
"""Yield Pages on which the file is displayed.
- .. deprecated:: 7.4.0
+ .. deprecated:: 7.4
Use :meth:`using_pages` instead.
"""
return self.using_pages(**kwargs)
diff --git a/pywikibot/site/_apisite.py b/pywikibot/site/_apisite.py
index 8004a75..33af282 100644
--- a/pywikibot/site/_apisite.py
+++ b/pywikibot/site/_apisite.py
@@ -349,7 +349,7 @@
) -> None:
"""Log the user in if not already logged in.
- .. versionchanged:: 8.0.0
+ .. versionchanged:: 8.0
lazy load cookies when logging in. This was dropped in 8.0.4
.. versionchanged:: 8.0.4
the *cookie_only* parameter was added and cookies are loaded
diff --git a/pywikibot/site/_generators.py b/pywikibot/site/_generators.py
index 763b0d9..93ca190 100644
--- a/pywikibot/site/_generators.py
+++ b/pywikibot/site/_generators.py
@@ -526,9 +526,9 @@
- :meth:`pywikibot.Category.members`
- :meth:`pywikibot.Category.subcategories`
- .. versionchanged:: 4.0.0
+ .. versionchanged:: 4.0
parameters except *category* are keyword arguments only.
- .. versionchanged:: 8.0.0
+ .. versionchanged:: 8.0
raises TypeError instead of Error if no Category is specified
.. seealso:: :api:`Categorymembers`
diff --git a/tests/aspects.py b/tests/aspects.py
index 3a44491..efca054 100644
--- a/tests/aspects.py
+++ b/tests/aspects.py
@@ -312,7 +312,7 @@
for other than the current site e.g. for the related data or image
repositoy of the current site is ot possible.
- .. versionadded:: 8.0.0
+ .. versionadded:: 8.0
:param version_needed: The version needed
:param reason: A reason for skipping the test.
diff --git a/tests/utils.py b/tests/utils.py
index 8057aa6..9465863 100644
--- a/tests/utils.py
+++ b/tests/utils.py
@@ -1,6 +1,6 @@
"""Test utilities."""
#
-# (C) Pywikibot team, 2013-2023
+# (C) Pywikibot team, 2013-2024
#
# Distributed under the terms of the MIT license.
#
@@ -469,7 +469,7 @@
def execute(command: list[str], data_in=None, timeout=None):
"""Execute a command and capture outputs.
- .. versionchanged:: 8.2.0
+ .. versionchanged:: 8.2
*error* parameter was removed.
:param command: executable to run and arguments to use
@@ -518,7 +518,7 @@
overrides: dict[str, str] | None = None) -> dict[str, Any]:
"""Execute the pwb.py script and capture outputs.
- .. versionchanged:: 8.2.0
+ .. versionchanged:: 8.2
the *error* parameter was removed.
:param args: list of arguments for pwb.py
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/999922?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: I4afa2e42918f9a6dda3a547be51c363f2f6a878d
Gerrit-Change-Number: 999922
Gerrit-PatchSet: 1
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged
jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/998295?usp=email )
Change subject: [bugfix] use str instead of repr for family
......................................................................
[bugfix] use str instead of repr for family
family is an object and not a string. Therefore do not use repr
for these variables when printing.
Bug detected with T356782
Bug: T356782
Change-Id: Ifde56185f8c095d6cdccfbe8063301a0ffb8f312
---
M pywikibot/scripts/version.py
M pywikibot/site/_apisite.py
2 files changed, 17 insertions(+), 2 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/scripts/version.py b/pywikibot/scripts/version.py
index b0e1156..1178caf 100755
--- a/pywikibot/scripts/version.py
+++ b/pywikibot/scripts/version.py
@@ -93,7 +93,7 @@
for family, usernames in pywikibot.config.usernames.items():
if not usernames:
continue
- pywikibot.info(f'Usernames for family {family!r}:')
+ pywikibot.info(f"Usernames for family '{family}':")
for lang, username in usernames.items():
pywikibot.info(f'\t{lang}: {username}')
diff --git a/pywikibot/site/_apisite.py b/pywikibot/site/_apisite.py
index b66ae01..8004a75 100644
--- a/pywikibot/site/_apisite.py
+++ b/pywikibot/site/_apisite.py
@@ -415,7 +415,7 @@
error_msg = ('No username has been defined in your '
'user config file: you have to add in this '
'file the following line:\n'
- 'usernames[{family!r}][{lang!r}]= {username!r}'
+ "usernames['{family}'][{lang!r}]= {username!r}"
.format(family=self.family,
lang=self.lang,
username=self.userinfo['name']))
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/998295?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: Ifde56185f8c095d6cdccfbe8063301a0ffb8f312
Gerrit-Change-Number: 998295
Gerrit-PatchSet: 1
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged
jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/994696?usp=email )
Change subject: [cleanup] raise RuntimeError if a Family has an initializer
......................................................................
[cleanup] raise RuntimeError if a Family has an initializer
Family class are to be immutable. Therefore the __init__ initializer
is deprecated for more than 5 years. A FutureWarning was given since
Pywikibot 8.3. Now remove this deprecation warning and raise a
RuntimeError instead.
Change-Id: I664ef4ff906b38dbc96d6b01668bebda81db3934
---
M ROADMAP.rst
M docs/api_ref/family.rst
M pywikibot/family.py
3 files changed, 38 insertions(+), 24 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/ROADMAP.rst b/ROADMAP.rst
index 329b941..0e61df9 100644
--- a/ROADMAP.rst
+++ b/ROADMAP.rst
@@ -28,6 +28,8 @@
Breaking changes and code cleanups
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+* A RuntimeError will be raised if a :class:`family.Family` subclass has an ``__init__`` initializer method.
+ :meth:`family.Family.__post_init__` classmethod can be used instead.
* :class:`InteractiveReplace<bot_choice.InteractiveReplace>` was moved from :mod:`bot` to :mod:`bot_choice` module
* ``userinterfaces.transliteration.transliterator`` was renamed to :class:`Transliterator
<userinterfaces.transliteration.Transliterator>`
diff --git a/docs/api_ref/family.rst b/docs/api_ref/family.rst
index 3a61f22..9ba9afd 100644
--- a/docs/api_ref/family.rst
+++ b/docs/api_ref/family.rst
@@ -7,17 +7,6 @@
.. autoclass:: Family
- .. method:: __init__()
-
- Initializer
-
- .. deprecated:: 3.0.20180710
- Use :meth:`__post_init__` instead.
- .. versionchanged:: 8.3
- A FutureWarning is printed instead of a ``NotImplementedWarning``.
- The deprecation may be removed in a future release and a
- ``RuntimeError`` will be thrown instead.
-
.. method:: __post_init__()
:classmethod:
diff --git a/pywikibot/family.py b/pywikibot/family.py
index 5c8dd28..968fcef 100644
--- a/pywikibot/family.py
+++ b/pywikibot/family.py
@@ -43,11 +43,22 @@
"""Parent singleton class for all wiki families.
+ Families are immutable and initializer is unsupported. Any class
+ modification should go to :meth:`__post_init__` class method.
+
+ .. versionchanged:: 3.0
+ the family class is immutable. Having an ``__init__`` initializer
+ method a ``NotImplementedWarning`` will be given.
.. versionchanged:: 8.0
``alphabetic``, ``alphabetic_revised`` and ``fyinterwiki``
attributes where removed.
.. versionchanged:: 8.2
:attr:`obsolete` setter was removed.
+ .. versionchanged:: 8.3
+ Having an initializer method a ``FutureWarning`` will be given.
+ .. versionchanged:: 9.0.0
+ raises RuntimeError if an initializer method was found;
+ :meth:`__post_init__` classmethod should be used instead.
"""
def __new__(cls):
@@ -63,17 +74,12 @@
# don't use hasattr() here. consider only the class itself
if '__init__' in cls.__dict__:
- # Initializer deprecated. Families should be immutable and any
- # instance / class modification should go to allocator (__new__).
- cls.__init__ = deprecated(instead='__post_init__() classmethod',
- since='3.0.20180710')(cls.__init__)
+ raise RuntimeError(fill(
+ f'Family class {cls.__module__}.{cls.__name__} cannot be'
+ ' instantiated; use __post_init__() classmethod to modify'
+ ' your family class. Refer the documentation.', width=66))
- # Invoke initializer immediately and make initializer no-op.
- # This is to avoid repeated initializer invocation on repeated
- # invocations of the metaclass's __call__.
- cls.instance.__init__()
- cls.__init__ = lambda self: None # no-op
- elif '__post_init__' not in cls.__dict__:
+ if '__post_init__' not in cls.__dict__:
pass
elif inspect.ismethod(cls.__post_init__): # classmethod check
cls.__post_init__()
@@ -87,11 +93,14 @@
@classproperty
def instance(cls):
- """Get the singleton instance."""
- # This is a placeholder to invoke allocator before it's allocated.
- # Allocator will override this classproperty.
+ """Get the singleton instance.
+
+ This is a placeholder to invoke allocator before it's allocated.
+ Allocator will override this classproperty.
+ """
return cls()
+ #: The family name
name: str | None = None
#: Not open for edits; stewards can still edit.
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/994696?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: I664ef4ff906b38dbc96d6b01668bebda81db3934
Gerrit-Change-Number: 994696
Gerrit-PatchSet: 6
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged