chore: fix pyright errors to make pipeline green
This commit is contained in:
parent
73268a8039
commit
eaf7fe9b2a
8 changed files with 15 additions and 15 deletions
|
|
@ -3,7 +3,7 @@ name = "streamer"
|
|||
version = "0.1.0"
|
||||
description = "Searching for tags in streams"
|
||||
readme = "README.md"
|
||||
requires-python = ">=3.12.11"
|
||||
requires-python = ">=3.12"
|
||||
dependencies = [
|
||||
"click>=8.2.1",
|
||||
"mistletoe>=1.4.0",
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ def new() -> None:
|
|||
|
||||
content = "# "
|
||||
with open(prelimary_path, "w") as file:
|
||||
file.write(content)
|
||||
_ = file.write(content)
|
||||
|
||||
click.edit(None, filename=prelimary_path)
|
||||
|
||||
|
|
@ -59,11 +59,11 @@ def new() -> None:
|
|||
parsed_content = parse_markdown_file(prelimary_path, content)
|
||||
|
||||
final_file_name = f"{timestamp}.md"
|
||||
if len(markers := parsed_content.shard.markers):
|
||||
if parsed_content.shard is not None and len(markers := parsed_content.shard.markers):
|
||||
final_file_name = f"{timestamp} {' '.join(markers)}.md"
|
||||
|
||||
final_path = os.path.join(streamer_directory, final_file_name)
|
||||
move(prelimary_path, final_path)
|
||||
_ = move(prelimary_path, final_path)
|
||||
print(f"Saved as [yellow]{final_file_name}")
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -3,8 +3,6 @@ from .repostory_configuration import RepositoryConfiguration
|
|||
from .localized_shard import LocalizedShard
|
||||
|
||||
__all__ = [
|
||||
"Dimension",
|
||||
"Marker",
|
||||
"RepositoryConfiguration",
|
||||
"localize_stream_file",
|
||||
"LocalizedShard",
|
||||
|
|
|
|||
|
|
@ -1,10 +1,9 @@
|
|||
from datetime import datetime
|
||||
import re
|
||||
import os
|
||||
from typing import Optional
|
||||
|
||||
|
||||
def extract_date_from_file_name(file_name: str) -> Optional[datetime]:
|
||||
def extract_date_from_file_name(file_name: str) -> datetime | None:
|
||||
FILE_NAME_REGEX = r"^(?P<date>\d{8})(?:-(?P<time>\d{4,6}))?.+.md$"
|
||||
base_name = os.path.basename(file_name)
|
||||
match = re.match(FILE_NAME_REGEX, base_name)
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
from typing import Optional
|
||||
|
||||
from streamer.parse.shard import Shard, StreamFile
|
||||
|
||||
from .repostory_configuration import RepositoryConfiguration
|
||||
|
|
@ -10,7 +10,7 @@ def localize_shard(
|
|||
shard: Shard, config: RepositoryConfiguration, propagated: dict[str, str]
|
||||
) -> LocalizedShard:
|
||||
position = {**propagated}
|
||||
private_position = {}
|
||||
private_position: dict[str, str] = {}
|
||||
|
||||
for marker in shard.markers:
|
||||
normalized_marker = marker.lower()
|
||||
|
|
@ -25,7 +25,7 @@ def localize_shard(
|
|||
|
||||
children = [localize_shard(child, config, position) for child in shard.children]
|
||||
|
||||
(position.update(private_position),)
|
||||
position.update(private_position)
|
||||
|
||||
return LocalizedShard(
|
||||
**shard.model_dump(exclude={"children"}), location=position, children=children
|
||||
|
|
@ -34,9 +34,12 @@ def localize_shard(
|
|||
|
||||
def localize_stream_file(
|
||||
stream_file: StreamFile, config: RepositoryConfiguration
|
||||
) -> Optional[LocalizedShard]:
|
||||
) -> LocalizedShard | None:
|
||||
shard_date = extract_date_from_file_name(stream_file.filename)
|
||||
|
||||
if not shard_date or not stream_file.shard:
|
||||
raise ValueError("Could not extract date")
|
||||
|
||||
return localize_shard(stream_file.shard, config, {"moment": shard_date.isoformat()})
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ from streamer.parse.shard import Shard
|
|||
|
||||
class LocalizedShard(Shard):
|
||||
location: dict[str, str]
|
||||
children: list[LocalizedShard]
|
||||
children: list[LocalizedShard] = [] # pyright: ignore[reportIncompatibleVariableOverride]
|
||||
|
||||
|
||||
__all__ = ["LocalizedShard"]
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ class Shard(BaseModel):
|
|||
|
||||
class StreamFile(BaseModel):
|
||||
filename: str
|
||||
shard: Shard = None
|
||||
shard: Shard | None = None
|
||||
|
||||
|
||||
__all__ = ["Shard", "StreamFile"]
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
from datetime import datetime
|
||||
from src.streamer.localize.extract_datetime import extract_date_from_file_name
|
||||
from streamer.localize.extract_datetime import extract_date_from_file_name
|
||||
|
||||
|
||||
class TestExtractDateTime:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue