Skip to content

Commit

Permalink
minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
barrust committed Jan 10, 2024
1 parent cc7d867 commit a0c9015
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions mediawiki/mediawiki.py
Expand Up @@ -93,7 +93,7 @@ def __init__(
)

# requests library parameters
self._session: Optional[requests.Session] = None
self._session: requests.Session = requests.Session()

# reset libary parameters
self._extensions = None
Expand Down Expand Up @@ -198,7 +198,6 @@ def rate_limit_min_wait(self) -> timedelta:
def rate_limit_min_wait(self, min_wait: timedelta):
"""Set minimum wait to use for rate limiting"""
self._config.rate_limit_min_wait = min_wait
self._config._rate_limit_last_call = None

@property
def timeout(self) -> Optional[float]:
Expand Down Expand Up @@ -978,18 +977,14 @@ def __cat_tree_rec(
def _get_response(self, params: Dict[str, Any]) -> Dict[str, Any]:
"""wrap the call to the requests package"""
try:
if self._session is not None:
return self._session.get(self._config.api_url, params=params, timeout=self._config.timeout).json()
return {}
return self._session.get(self._config.api_url, params=params, timeout=self._config.timeout).json()
except JSONDecodeError:
return {}

def _post_response(self, params: Dict[str, Any]) -> Dict[str, Any]:
"""wrap a post call to the requests package"""
try:
if self._session is not None:
return self._session.post(self._config.api_url, data=params, timeout=self._config.timeout).json()
return {}
return self._session.post(self._config.api_url, data=params, timeout=self._config.timeout).json()
except JSONDecodeError:
return {}

Expand Down

0 comments on commit a0c9015

Please sign in to comment.