Compare commits

...

2 commits

Author SHA1 Message Date
d5535fe2d0
ci: nix-ify pipeline
All checks were successful
Continuous Integration / Lint, Check & Test (push) Successful in 1m28s
2025-10-12 08:30:24 +02:00
eaf7fe9b2a
chore: fix pyright errors to make pipeline green 2025-10-12 08:30:10 +02:00
9 changed files with 26 additions and 35 deletions

View file

@ -1,43 +1,34 @@
name: Continuous Integration
on:
push:
workflow_dispatch:
push:
workflow_dispatch:
jobs:
build-and-lint:
name: Lint, Check & Test
runs-on: ubuntu-latest
runs-on: nix
steps:
- name: Check out Repository
uses: https://git.konstantinfickel.de/actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v5
with:
enable-cache: true
version: "0.7.14"
- name: Set up python
uses: actions/setup-python@v5
with:
python-version-file: "pyproject.toml"
- run: nix --version
- run: nix flake check
- name: Install the project
run: uv sync --locked --all-extras --dev
run: nix develop .#impure --command bash -c "uv sync --locked --all-extras --dev"
- name: Test with PyTest
run: uv run pytest --junit-xml test-report.xml
run: nix develop .#impure --command bash -c "uv run pytest --junit-xml test-report.xml"
- name: Report test results
uses: dorny/test-reporter@v2
uses: https://github.com/dorny/test-reporter.git@v2
if: ${{ !cancelled() }}
with:
with:
name: PyTest Results
path: test-report.xml
reporter: java-junit
- name: Check with PyRight
run: uv run pyright
run: nix develop .#impure --command bash -c "uv run pyright"

View file

@ -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",

View file

@ -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}")

View file

@ -3,8 +3,6 @@ from .repostory_configuration import RepositoryConfiguration
from .localized_shard import LocalizedShard
__all__ = [
"Dimension",
"Marker",
"RepositoryConfiguration",
"localize_stream_file",
"LocalizedShard",

View file

@ -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)

View file

@ -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()})

View file

@ -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"]

View file

@ -12,7 +12,7 @@ class Shard(BaseModel):
class StreamFile(BaseModel):
filename: str
shard: Shard = None
shard: Shard | None = None
__all__ = ["Shard", "StreamFile"]

View file

@ -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: