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
Xqt has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/997899?usp=email )
Change subject: [doc] update ROADMAP.rst
......................................................................
[doc] update ROADMAP.rst
Change-Id: Id688c740fc11780cf39b1dc11c35e49ca152d5bc
---
M ROADMAP.rst
1 file changed, 10 insertions(+), 0 deletions(-)
Approvals:
Xqt: Verified; Looks good to me, approved
diff --git a/ROADMAP.rst b/ROADMAP.rst
index 9b450fd..329b941 100644
--- a/ROADMAP.rst
+++ b/ROADMAP.rst
@@ -28,6 +28,7 @@
Breaking changes and code cleanups
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+* :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>`
* ``pywikibot.BaseSite`` and ``pywikibotAPISite`` were dropped. :func:`pywikibot.Site` has to be used to create a
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/997899?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: Id688c740fc11780cf39b1dc11c35e49ca152d5bc
Gerrit-Change-Number: 997899
Gerrit-PatchSet: 1
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-MessageType: merged