Unnecessary else/elif used after raise PYL-R1720
Style
Minor
4 days ago2 months old
Unnecessary "else" after "raise", remove the "else" and de-indent the code inside it
2245            del dateDict['time']
2246
2247            # replace month name in original language with month number
2248            try:2249                value = self.origNames2monthNum[dateDict['month']['value']]
2250            except KeyError:
2251                raise KeyError(
Unnecessary "else" after "raise", remove the "else" and de-indent the code inside it
 840
 841        soup = _bs4_soup(response.text)  # type: ignore
 842
 843        try: 844            url_image = soup.find(class_='prp-page-image')
 845            # if None raises AttributeError
 846            url_image = url_image.find('img')
Unnecessary "else" after "raise", remove the "else" and de-indent the code inside it
 475                raise NoWikibaseEntityError(self) from exc
 476            except Error as exc:
 477                error_message = str(exc)
 478                if 'is not a file' in error_message: 479                    raise NoWikibaseEntityError(self) from exc
 480                else:
 481                    raise Error(self) from exc
Unnecessary "else" after "raise", remove the "else" and de-indent the code inside it
1748        :raises pywikibot.exceptions.NoMoveTargetError: page was not moved
1749        """
1750        gen = iter(self.site.logevents(logtype='move', page=self, total=1))
1751        try:1752            lastmove = next(gen)
1753        except StopIteration:
1754            raise NoMoveTargetError(self)
Unnecessary "else" after "raise", remove the "else" and de-indent the code inside it
 300
 301    def change(self, text: str) -> bool | str:
 302        """Execute all clean up methods and catch errors if activated."""
 303        try: 304            new_text = self._change(text)
 305        except Exception as e:
 306            if self.ignore == CANCEL.PAGE: