Skip to content

Commit

Permalink
some linting
Browse files Browse the repository at this point in the history
  • Loading branch information
deeleeramone committed Jan 22, 2025
1 parent 7b2fa3e commit bc4281d
Showing 1 changed file with 17 additions and 17 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""SEC Management & Discussion Model."""

# pylint: disable=unused-argument,too-many-branches,too-many-locals,too-many-statements
# pylint: disable=unused-argument,too-many-branches,too-many-locals,too-many-statements,too-many-nested-blocks,too-many-boolean-expressions

from typing import Any, Optional

Expand Down Expand Up @@ -146,6 +146,7 @@ async def aextract_data(
)

url = target_filing.report_url
response = ""

if query.use_cache is True:
cache_dir = f"{get_user_cache_directory()}/http/sec_financials"
Expand Down Expand Up @@ -186,6 +187,7 @@ async def aextract_data(
"content": response,
}

@staticmethod
def transform_data( # noqa: PLR0912
query: SecManagementDiscussionAnalysisQueryParams,
data: dict,
Expand All @@ -211,16 +213,15 @@ def transform_data( # noqa: PLR0912
raise EmptyDataError("No text was extracted from the filing!")

def is_table_header(line: str) -> bool:
"""Check if line is a table header"""
return (
all(
[
not char.isnumeric()
for char in line.replace("(", "")
.replace(")", "")
.replace(",", "")
.replace(" ", "")
.replace("|", "")
]
not char.isnumeric()
for char in line.replace("(", "")
.replace(")", "")
.replace(",", "")
.replace(" ", "")
.replace("|", "")
)
and line.replace("|", "").replace("-", "").strip() != ""
) or line.replace("|", "").replace(" ", "").endswith(":")
Expand Down Expand Up @@ -386,10 +387,10 @@ def insert_cell_dividers(line):
if "$" in line:
line = line.replace("$ |", "").replace("| |", "|") # noqa
elif "%" in line:
line = line.replace("% |", "").replace("| |", "|")
line = line.replace("% |", "").replace("| |", "|") # noqa

if "|" not in previous_line and all(
[char == "|" for char in line.replace(" ", "")]
char == "|" for char in line.replace(" ", "")
):
line = line + "\n" + line.replace(" ", ":------:") # noqa

Expand Down Expand Up @@ -458,7 +459,7 @@ def insert_cell_dividers(line):

def is_title_case(line: str) -> bool:
"""Check if line follows financial document title case patterns"""
IGNORE_WORDS = {
ignore_words = [
"and",
"the",
"of",
Expand All @@ -477,7 +478,7 @@ def is_title_case(line: str) -> bool:
"per",
"share",
"compared",
}
]

# Basic checks
if (
Expand Down Expand Up @@ -533,7 +534,7 @@ def is_title_case(line: str) -> bool:
# Check remaining words
for i, word in enumerate(words[1:], 1):
# Skip common lowercase words unless first/last
if word.lower() in IGNORE_WORDS and i != len(words) - 1:
if word.lower() in ignore_words and i != len(words) - 1:
continue

# Allow numbers and abbreviations
Expand All @@ -548,7 +549,7 @@ def is_title_case(line: str) -> bool:

def count_columns_in_data_row(data_row: str) -> int:
"""Count actual columns from first data row"""
return len([cell for cell in data_row.split("|")])
return len(list(data_row.split("|")))

def pad_row_columns(row: str, target_cols: int) -> str:
"""Pad a table row with empty cells to match target column count"""
Expand All @@ -563,8 +564,7 @@ def pad_row_columns(row: str, target_cols: int) -> str:
" " for _ in range(target_cols - current_cols - 2)
]
return "|" + "|".join(cells)
else:
cells = [" " for _ in range(target_cols - current_cols - 2)] + cells
cells = [" " for _ in range(target_cols - current_cols - 2)] + cells
return "|".join(cells)

def process_document(document: list[str]) -> list[str]:
Expand Down

0 comments on commit bc4281d

Please sign in to comment.