66import logging
77import re
88from abc import ABC
9- from collections .abc import Callable , Generator
9+ from collections .abc import Callable , Generator , Sequence
1010from dataclasses import dataclass
1111from functools import partial
1212from pathlib import Path
13- from typing import Protocol , Self
13+ from typing import Protocol
1414
1515import polars as pl
1616import polars .selectors as cs
17+ from polars ._typing import ColumnNameOrSelector
1718
1819from . import util
1920from .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