Skip to content

Commit

Permalink
improve typing
Browse files Browse the repository at this point in the history
  • Loading branch information
PhilipMay committed Jan 1, 2024
1 parent 8cfec64 commit 31a2a2e
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions mltb2/bs.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@
``pip install mltb2[bs]``
"""

from typing import Optional
from typing import Any, Dict, Optional

import mdformat
from bs4 import BeautifulSoup
from markdownify import MarkdownConverter, markdownify


def extract_text(soup: BeautifulSoup, join_str=None) -> str:
def extract_text(soup: BeautifulSoup, join_str: Optional[str] = None) -> str:
"""TODO: add docstring."""
if join_str is None:
join_str = " "
Expand All @@ -25,7 +25,8 @@ def extract_text(soup: BeautifulSoup, join_str=None) -> str:
return result


def extract_one(soup: BeautifulSoup, name=None, attrs=None, **kwargs):
# TODO: add return type
def extract_one(soup: BeautifulSoup, name=None, attrs: Optional[dict] = None, **kwargs: Dict[str, Any]):
"""TODO: add docstring."""
if attrs is None:
attrs = {}
Expand All @@ -35,15 +36,16 @@ def extract_one(soup: BeautifulSoup, name=None, attrs=None, **kwargs):
return result


def extract_all(soup: BeautifulSoup, name=None, attrs=None, **kwargs):
# TODO: add return type
def extract_all(soup: BeautifulSoup, name=None, attrs: Optional[dict] = None, **kwargs: Dict[str, Any]):
"""TODO: add docstring."""
if attrs is None:
attrs = {}
result = soup.find_all(name, attrs, **kwargs)
return result


def remove_all(soup: BeautifulSoup, name=None, attrs=None, **kwargs) -> None:
def remove_all(soup: BeautifulSoup, name=None, attrs: Optional[dict] = None, **kwargs: Dict[str, Any]) -> None:
"""TODO: add docstring."""
if attrs is None:
attrs = {}
Expand Down

0 comments on commit 31a2a2e

Please sign in to comment.