Skip to content

Commit

Permalink
fix: type hints
Browse files Browse the repository at this point in the history
  • Loading branch information
lars-reimann committed Apr 22, 2023
1 parent 3b4604a commit 2720d88
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/safeds/data/tabular/containers/_column.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import io
from collections.abc import Sequence
from numbers import Number
from typing import TYPE_CHECKING, Any, TypeVar
from typing import TYPE_CHECKING, Any, TypeVar, overload

import matplotlib.pyplot as plt
import numpy as np
Expand Down Expand Up @@ -82,7 +82,7 @@ def _from_pandas_series(data: pd.Series, type_: ColumnType | None = None) -> Col
# Dunder methods
# ------------------------------------------------------------------------------------------------------------------

def __init__(self, name: str, data: Sequence) -> None:
def __init__(self, name: str, data: Sequence[_T]) -> None:
"""
Create a column.
Expand Down Expand Up @@ -113,7 +113,15 @@ def __eq__(self, other: object) -> bool:
return True
return self.name == other.name and self._data.equals(other._data)

def __getitem__(self, index: int | slice) -> _T:
@overload
def __getitem__(self, index: int) -> _T:
...

@overload
def __getitem__(self, index: slice) -> Sequence[_T]:
...

def __getitem__(self, index: int | slice) -> _T | Column[_T]:
if isinstance(index, int):
if index < 0 or index >= self._data.size:
raise IndexOutOfBoundsError(index)
Expand Down

0 comments on commit 2720d88

Please sign in to comment.