Introduction
--
The PEP8 naming convention suggests that exceptions should have the suffix "Error" on exception names bot a lot of exceptions does not follow them.
Proposal
--
- rename exceptions to follow the naming convention
- Find a way to deprecate the renamed exception
Hints
--
Here is a code snipped how to proceed and implement a deprecation warning:
```
class NoPageError(PageRelatedError):
"""Page does not exist."""
message = "Page %s doesn't exist."
class DeprecatedException:
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
print('Exception "{}" is deprecated'.format(self.__class__.__name__))
def __str__(self):
print('Exception "{}" is deprecated'.format(self.__class__.__name__))
super().__getattr__(attr)
class NoPage(DeprecatedExcption, NoPageError):
pass
```
`DeprecatedException` class should use `pywikibot.tools.issue_deprecation_warning` to print the warning. Use a separate method to do it. The parameters like `instead` or `since` should be passed as keyword parameters to `DeprecatedException.__init__`. We always can use a `FutureWarning` as `warning_class`.
Links
--
- [[https://www.python.org/dev/peps/pep-0008/#exception-names | PEP8 exceptions naming convention]]
- [[https://doc.wikimedia.org/pywikibot/master/api_ref/pywikibot.html#module-pywikibot.exceptions | Pywikibot exception module documentation]]
- [[https://doc.wikimedia.org/pywikibot/master/api_ref/pywikibot.tools.html#pywikibot.tools.issue_deprecation_warning | pywikibot.tools.issue_deprecation_warning documentation]]