Skip to content

Commit

Permalink
Fix mypy failures and switch to OSSIP branding
Browse files Browse the repository at this point in the history
Signed-off-by: Thomas Cooper <[email protected]>
  • Loading branch information
tomncooper committed Dec 29, 2024
1 parent 45004a9 commit 78a87e4
Show file tree
Hide file tree
Showing 9 changed files with 82 additions and 16 deletions.
2 changes: 1 addition & 1 deletion ipper/common/wiki.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def child_page_generator(wiki_page_info, chunk: int, timeout: int) -> Generator[
first_child_request: requests.Response = requests.get(
APACHE_CONFLUENCE_BASE_URL + wiki_page_child_info_request.json()["_expandable"]["page"],
params={
"limit": chunk,
"limit": str(chunk),
"expand": "history.lastUpdated,body.view",
},
timeout=timeout,
Expand Down
7 changes: 5 additions & 2 deletions ipper/kafka/mailing_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,9 +179,12 @@ def extract_message_payload(msg: Message) -> List[str]:

for message in msg.walk():

temp_payload: Union[List[Message], str] = message.get_payload()
temp_payload: Union[List[Union[Message, str]], Message, str] = message.get_payload()
if isinstance(temp_payload, list):
payload: str = cast(str, temp_payload[0].get_payload())
if isinstance(temp_payload[0], Message):
payload: str = cast(str, temp_payload[0].get_payload())
elif isinstance(temp_payload[0], str):
payload = cast(str, message.get_payload())
elif isinstance(temp_payload, str):
payload = cast(str, message.get_payload())
else:
Expand Down
7 changes: 3 additions & 4 deletions ipper/kafka/output.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from enum import Enum
from pathlib import Path

from pandas import DataFrame, Timestamp, Timedelta, to_datetime
from pandas import DataFrame, Series, Timestamp, Timedelta, to_datetime
from jinja2 import Template, Environment, FileSystemLoader

from ipper.common.utils import calculate_age
Expand Down Expand Up @@ -69,7 +69,6 @@ def create_vote_dict(kip_mentions: DataFrame) -> Dict[int, Dict[str, List[str]]]
from vote type to list of those who voted that way"""

vote_dict: Dict[int, Dict[str, List[str]]] = {}
kip_id: int
kip_votes: DataFrame
for kip_id, kip_votes in kip_mentions[~kip_mentions["vote"].isna()][
["kip", "from", "vote"]
Expand All @@ -82,7 +81,7 @@ def create_vote_dict(kip_mentions: DataFrame) -> Dict[int, Dict[str, List[str]]]
for name in kip_votes[kip_votes["vote"] == vote]["from"]
)
)
vote_dict[kip_id] = kip_dict
vote_dict[cast(int, kip_id)] = kip_dict

return vote_dict

Expand All @@ -95,7 +94,7 @@ def create_status_dict(

recent_mentions: DataFrame = get_most_recent_mention_by_type(kip_mentions)

subject_mentions: DataFrame = recent_mentions["subject"].dropna()
subject_mentions: Series = recent_mentions["subject"].dropna()

vote_dict: Dict[int, Dict[str, List[str]]] = create_vote_dict(kip_mentions)

Expand Down
18 changes: 14 additions & 4 deletions ipper/kafka/wiki.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def get_current_state(html: str) -> Optional[str]:
return None


def enrich_kip_info(body_html: str, kip_dict: dict[str, Union[str, int]]) -> None:
def enrich_kip_info(body_html: str, kip_dict: dict[str, Union[list[str], str, int]]) -> None:
"""Parses the body of the KIP wiki page pointed to by the 'content_url'
key in the supplied dictionary. It will add the derived data to the
supplied dict."""
Expand All @@ -111,7 +111,7 @@ def enrich_kip_info(body_html: str, kip_dict: dict[str, Union[str, int]]) -> Non
elif not jira_processed and "jira" in para.text.lower():
link: Tag = para.find("a")
if link:
href: Optional[str] = link.get("href")
href: Optional[Union[list, str]] = link.get("href")
else:
href = None

Expand All @@ -134,7 +134,7 @@ def process_child_kip(kip_id: int, child: dict):
"""Process and enrich the KIP child page dictionary"""

print(f"Processing KIP {kip_id} wiki page")
child_dict: dict[str, Union[int, str]] = {}
child_dict: dict[str, Union[list[str], str, int]] = {}
child_dict["kip_id"] = kip_id
child_dict["title"] = child["title"]
child_dict["web_url"] = APACHE_CONFLUENCE_BASE_URL + child["_links"]["webui"]
Expand Down Expand Up @@ -234,6 +234,9 @@ def process_discussion_table(
kip_dict: dict[str, str] = {}
columns: list[Tag] = row.find_all("td")

if not columns[0].a:
continue

kip_text: str = columns[0].a.text
kip_match: Optional[re.Match] = re.search(KIP_PATTERN, kip_text)

Expand All @@ -244,7 +247,14 @@ def process_discussion_table(
try:
kip_dict["url"] = cast(str, kip_child_urls[kip_id]["web_url"])
except KeyError:
kip_dict["url"] = columns[0].a.get("href")
href: Optional[Union[list[str], str]] = columns[0].a.get("href")
if href:
if isinstance(href, list):
kip_dict["url"] = href[0]
else:
kip_dict["url"] = href
else:
kip_dict["url"] = "Unknown"
output[kip_id] = kip_dict
else:
continue
Expand Down
53 changes: 52 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,15 @@ beautifulsoup4 = "^4.10.0"
pandas = "^2.2.3"
Jinja2 = "^3.1.4"

[tool.poetry.dev-dependencies]
[tool.poetry.group.dev.dependencies]
ipython = "^8.29.0"
pylint = "^3.3.3"
black = "^24.10.0"
mypy = "^1.14.0"
types-requests = "^2.32.0.20241016"
ipdb = "^0.13.13"
pandas-stubs = "^2.2.3.241126"
types-beautifulsoup4 = "^4.12.0.20241020"

[build-system]
requires = ["poetry-core>=1.0.0"]
Expand Down
1 change: 1 addition & 0 deletions templates/flink-index.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

<body>
<h1>Flink Improvement Proposals</h1>
<p><a href="index.html">Back to OSSIP</a></p>
<h2>Coming Soon..</h2>
</body>

Expand Down
2 changes: 1 addition & 1 deletion templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ <h1>OSSIP</h1>
<h2>A hub for information on Open Source Software Improvement Proposals</h2>

<p>Created by <a href="https://tomcooper.dev">Tom Cooper</a></p>
<p>GitHub Repository: <a href="https://github.com/tomncooper/kipper">tomncooper/kipper</a></p>
<p>GitHub Repository: <a href="https://github.com/tomncooper/ossip">tomncooper/ossip</a></p>

<h2><a href="kafka.html">Kafka</a></h2>
<h2><a href="flink.html">Flink</a></h2>
Expand Down
4 changes: 2 additions & 2 deletions templates/kafka-index.html.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@

<body>
<h1>Kafka Improvement Proposals (KIPs)</h1>
<p><a href="index.html">Back to IPper</a></p>
<p>GitHub Repository: <a href="https://github.com/tomncooper/kipper">tomncooper/kipper</a></p>
<p><a href="index.html">Back to OSSIP</a></p>
<p>GitHub Repository: <a href="https://github.com/tomncooper/ossip">tomncooper/ossip</a></p>
<p>Last Updated: {{ date }}</p>
<h2>Status Key</h2>
<table>
Expand Down

0 comments on commit 78a87e4

Please sign in to comment.