Skip to content

Commit eef6538

Browse files
committed
Restore 3.10 compatibility (typing.Self unsupported)
1 parent 322045a commit eef6538

File tree

2 files changed

+10
-11
lines changed

2 files changed

+10
-11
lines changed

src/sensai/evaluation/result_set.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import Optional, List, Self, TYPE_CHECKING, Callable
1+
from typing import Optional, List, TYPE_CHECKING, Callable
22

33
import pandas as pd
44

@@ -22,7 +22,7 @@ class ResultSet:
2222
def __init__(self, df: pd.DataFrame):
2323
self.df = df
2424

25-
def _create_result_set(self, df: pd.DataFrame) -> Self:
25+
def _create_result_set(self, df: pd.DataFrame) -> "ResultSet":
2626
"""
2727
Creates a new result set for the given data frame
2828
@@ -31,7 +31,7 @@ def _create_result_set(self, df: pd.DataFrame) -> Self:
3131
"""
3232
return self.__class__(df)
3333

34-
def query(self, sql: str) -> Self:
34+
def query(self, sql: str) -> "ResultSet":
3535
"""
3636
Queries the result set with the given condition specified in SQL syntax.
3737

src/sensai/util/string.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44
import sys
55
import types
66
from abc import ABC, abstractmethod
7-
from io import StringIO
8-
from typing import Union, List, Dict, Any, Sequence, Iterable, Optional, Mapping, Callable, Self
7+
from typing import Union, List, Dict, Any, Sequence, Iterable, Optional, Mapping, Callable
98

109
reCommaWhitespacePotentiallyBreaks = re.compile(r",\s+")
1110

@@ -528,31 +527,31 @@ def __init__(self, initial_text: str | None = None):
528527
def build(self) -> str:
529528
return "\n".join(self._components)
530529

531-
def with_lines(self, lines: Sequence[str], indent=0) -> Self:
530+
def with_lines(self, lines: Sequence[str], indent=0) -> "TextBuilder":
532531
for line in lines:
533532
line = line.rstrip()
534533
if indent > 0:
535534
line = " " * indent + line
536535
self._components.append(line)
537536
return self
538537

539-
def with_lines_from_text(self, text: str, indent=0) -> Self:
538+
def with_lines_from_text(self, text: str, indent=0) -> "TextBuilder":
540539
lines = text.splitlines(keepends=False)
541540
return self.with_lines(lines, indent=indent)
542541

543-
def with_line(self, line: str, indent=0) -> Self:
542+
def with_line(self, line: str, indent=0) -> "TextBuilder":
544543
return self.with_lines([line], indent=indent)
545544

546-
def with_line_conditional(self, cond: bool, line: str, indent=0) -> Self:
545+
def with_line_conditional(self, cond: bool, line: str, indent=0) -> "TextBuilder":
547546
if cond:
548547
self.with_line(line, indent=indent)
549548
return self
550549

551-
def with_text(self, text: str) -> Self:
550+
def with_text(self, text: str) -> "TextBuilder":
552551
self._components.append(text)
553552
return self
554553

555-
def with_break(self, n=1) -> Self:
554+
def with_break(self, n=1) -> "TextBuilder":
556555
for i in range(n):
557556
self._components.append("")
558557
return self

0 commit comments

Comments
 (0)