Skip to content

Commit

Permalink
additional pylint
Browse files Browse the repository at this point in the history
  • Loading branch information
barrust committed Jan 4, 2024
1 parent b882ffe commit fa05086
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 17 deletions.
3 changes: 1 addition & 2 deletions .pylintrc
Expand Up @@ -598,8 +598,7 @@ variable-naming-style=snake_case
[EXCEPTIONS]

# Exceptions that will emit a warning when caught.
overgeneral-exceptions=BaseException,
Exception
overgeneral-exceptions=builtins.BaseException, builtins.Exception


[LOGGING]
Expand Down
20 changes: 10 additions & 10 deletions mediawiki/mediawiki.py
Expand Up @@ -128,8 +128,8 @@ def __init__(

try:
self._get_site_info()
except MediaWikiException:
raise MediaWikiAPIURLError(url)
except MediaWikiException as exc:
raise MediaWikiAPIURLError(url) from exc

# non-settable properties
@property
Expand Down Expand Up @@ -406,11 +406,11 @@ def set_api_url(
self._get_site_info()
self.__supported_languages = None # reset this
self.__available_languages = None # reset this
except (rex.ConnectTimeout, MediaWikiException):
except (rex.ConnectTimeout, MediaWikiException) as exc:
# reset api url and lang in the event that the exception was caught
self._api_url = old_api_url
self._lang = old_lang
raise MediaWikiAPIURLError(api_url)
raise MediaWikiAPIURLError(api_url) from exc
self.clear_memoized()

def _reset_session(self):
Expand Down Expand Up @@ -609,8 +609,8 @@ def test_lat_long(val):
)
try:
return Decimal(val)
except (DecimalException, TypeError):
raise ValueError(error)
except (DecimalException, TypeError) as exc:
raise ValueError(error) from exc
return val

# end local function
Expand Down Expand Up @@ -985,10 +985,10 @@ def __cat_tree_rec(
parent_cats = categories[cat].categories
links[cat] = self.categorymembers(cat, results=None, subcategories=True)
break
except PageError:
raise PageError(f"{self.category_prefix}:{cat}")
except KeyboardInterrupt:
raise
except PageError as exc:
raise PageError(f"{self.category_prefix}:{cat}") from exc
except KeyboardInterrupt as exc:
raise exc
except Exception:
tries = tries + 1
time.sleep(1)
Expand Down
14 changes: 9 additions & 5 deletions mediawiki/mediawikipage.py
Expand Up @@ -37,7 +37,8 @@ class MediaWikiPage:
Raises:
:py:func:`mediawiki.exceptions.DisambiguationError`: if page provided is a disambiguation page
Raises:
:py:func:`mediawiki.exceptions.RedirectError`: if redirect is **False** and the pageid or title provided redirects to another page
:py:func:`mediawiki.exceptions.RedirectError`: if redirect is **False** and the pageid or title \
provided redirects to another page
Warning:
This should never need to be used directly! Please use :func:`mediawiki.MediaWiki.page`"""

Expand Down Expand Up @@ -394,7 +395,8 @@ def backlinks(self) -> List[str]:

@property
def langlinks(self) -> Dict[str, str]:
"""dict: Names of the page in other languages for which page is where the key is the language code and the page name is the name of the page in that language.
"""dict: Names of the page in other languages for which page is where the key is the language code
and the page name is the name of the page in that language.
Note:
Not settable
Expand Down Expand Up @@ -502,7 +504,8 @@ def section(self, section_title: str) -> Optional[str]:
Note:
Use **None** if the header section is desired
Note:
Returns **None** if section title is not found; only text between title and next section or sub-section title is returned
Returns **None** if section title is not found; only text between title and next \
section or sub-section title is returned
Note:
Side effect is to also pull the content which can be slow
Note:
Expand Down Expand Up @@ -543,7 +546,8 @@ def parse_section_links(self, section_title: str) -> List[Tuple[str, str]]:
"""Parse all links within a section
Args:
section_title (str): Name of the section to pull or, if None is provided, the links between the main heading and the first section
section_title (str): Name of the section to pull or, if None is provided, \
the links between the main heading and the first section
Returns:
list: List of (title, url) tuples
Note:
Expand Down Expand Up @@ -725,7 +729,7 @@ def _parse_section_links(self, id_tag: Optional[str]) -> List[str]:
continue
if node.get("role", "") == "navigation":
continue
elif "infobox" in node.get("class", []):
if "infobox" in node.get("class", []):
continue

# If the classname contains "toc", the element is a table of contents.
Expand Down

0 comments on commit fa05086

Please sign in to comment.