Skip to content

Commit

Permalink
Fix lints.
Browse files Browse the repository at this point in the history
  • Loading branch information
emmiegit committed Feb 23, 2024
1 parent f4732af commit f9ae54a
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 7 deletions.
5 changes: 4 additions & 1 deletion yellowstone/request/forum_post_revision.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ def get(
...

logger.info(
"Retrieving forum post revision HTML for site %s category %d thread %d post %d revision %d",
(
"Retrieving forum post revision HTML for "
"site %s category %d thread %d post %d revision %d"
),
site_slug,
category_id,
thread_id,
Expand Down
8 changes: 8 additions & 0 deletions yellowstone/request/forum_post_revisions.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"""

import logging
from dataclasses import dataclass

from ..scraper import (
make_soup,
Expand All @@ -12,6 +13,12 @@
logger = logging.getLogger(__name__)


@dataclass
class ForumPostRevisionData:
# TODO
...


def get(
site_slug: str,
*,
Expand All @@ -37,3 +44,4 @@ def get(
)
soup = make_soup(html)
# TODO
_ = soup
1 change: 0 additions & 1 deletion yellowstone/request/forum_posts.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
make_soup,
regex_extract_int,
regex_extract_str,
select_element,
)
from ..types import UserModuleData
from ..wikidot import Wikidot
Expand Down
1 change: 0 additions & 1 deletion yellowstone/request/forum_threads.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
get_entity_user,
make_soup,
regex_extract_int,
select_element,
)
from ..types import ForumLastPostData, UserModuleData
from ..wikidot import Wikidot
Expand Down
18 changes: 15 additions & 3 deletions yellowstone/scraper.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,13 @@
from bs4 import BeautifulSoup, PageElement, Tag

from .exception import ScrapingError
from .types import CustomUserData, DeletedUserData, ForumLastPostData, UserModuleData
from .types import (
AnonymousUserData,
CustomUserData,
DeletedUserData,
ForumLastPostData,
UserModuleData,
)

LAST_THREAD_AND_POST_ID = re.compile(r"/forum/t-(\d+)(?:/[^/]*)?#post-(\d+)")
TIMESTAMP_REGEX = re.compile(r"time_(\d+)")
Expand Down Expand Up @@ -91,7 +97,10 @@ def get_entity_date(source: str, tag: Tag) -> datetime:
raise ScrapingError(f"Could not find date timestamp from {source}")


def get_entity_user(source: str, tag: Tag) -> Union[UserModuleData, DeletedUserData, CustomUserData]:
def get_entity_user(
source: str,
tag: Tag,
) -> Union[UserModuleData, DeletedUserData, CustomUserData]:
"""
Parses out a user module entity, including unusual cases.
Requires being focused on .printuser
Expand Down Expand Up @@ -136,7 +145,10 @@ def get_entity_user(source: str, tag: Tag) -> Union[UserModuleData, DeletedUserD
raise ScrapingError("Cannot determine user data from {source}")


def get_entity_user_exists(source: str, tag: Tag) -> UserModuleData:
def get_entity_user_exists(
source: str,
tag: Tag,
) -> UserModuleData:
"""
Parses out a user module entity, when it is known to be "real" (e.g. not anonymous, deleted, etc).
Requires being focused on the ".printuser a" element.
Expand Down
2 changes: 1 addition & 1 deletion yellowstone/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from dataclasses import dataclass
from datetime import datetime
from typing import Optional, Union
from typing import Union

Json = Union[None, int, float, str, list["Json"], dict[str, "Json"]]

Expand Down

0 comments on commit f9ae54a

Please sign in to comment.