Skip to content

Commit 40a510f

Browse files
committed
🚨 Fix typing errors
1 parent 5ed223f commit 40a510f

1 file changed

Lines changed: 9 additions & 11 deletions

File tree

src/mindlogger_data_export/outputs.py

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,15 @@
66
import logging
77
import re
88
from abc import ABC
9-
from collections.abc import Callable, Generator
9+
from collections.abc import Callable, Generator, Sequence
1010
from dataclasses import dataclass
1111
from functools import partial
1212
from pathlib import Path
13-
from typing import Protocol, Self
13+
from typing import Protocol
1414

1515
import polars as pl
1616
import polars.selectors as cs
17+
from polars._typing import ColumnNameOrSelector
1718

1819
from . import util
1920
from .mindlogger import MindloggerData
@@ -31,7 +32,7 @@ def __call__(
3132
option_scores: pl.DataFrame,
3233
*,
3334
include_options: bool = False,
34-
) -> Self:
35+
) -> pl.DataFrame:
3536
"""Signature for Pivot Functions with keyword-only `include_options`."""
3637
...
3738

@@ -194,7 +195,9 @@ def _pivot_singleselect(
194195
df = df.with_columns(item_name=pl.col("item").struct.field("name")).drop("item")
195196

196197
# Determine which columns to pivot
197-
pivot_values = cs.starts_with("response")
198+
pivot_values: ColumnNameOrSelector | Sequence[ColumnNameOrSelector] = (
199+
cs.starts_with("response")
200+
)
198201
if include_options:
199202
pivot_values = [
200203
"response_index",
@@ -528,13 +531,8 @@ def _prepare_activity_columns(
528531
[
529532
col
530533
for col in df.columns
531-
if col not in response_bases | score_bases | index_bases
532-
]
533-
).select(
534-
[
535-
col
536-
for col in df.columns
537-
if not col.startswith(f"{activity_prefix}_response_response_")
534+
if col not in (response_bases | score_bases | index_bases)
535+
and not col.startswith(f"{activity_prefix}_response_response_")
538536
and not col.startswith(f"{activity_prefix}_response_value_")
539537
]
540538
)

0 commit comments

Comments
 (0)