Skip to content

Commit

Permalink
Merge pull request #3 from Catminusminus/improve-types
Browse files Browse the repository at this point in the history
make type checkers happy
  • Loading branch information
Catminusminus authored Oct 14, 2024
2 parents 4b29b01 + 5c5d2c4 commit 4ccb777
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
1 change: 1 addition & 0 deletions .github/workflows/python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ jobs:
poetry run flake8 --filename=*.py option/
poetry run black --check .
poetry run isort --check-only --profile black .
poetry run mypy option/ tests/
pytest:
runs-on: ubuntu-latest
Expand Down
12 changes: 6 additions & 6 deletions option/option.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def or_else(self, _: Callable[[], "Some[T]"]) -> "Some[T]":
def unwrap(self) -> T:
return self._value

def unwrap_or(self, _: T) -> T:
def unwrap_or(self, _: object) -> T:
return self._value

def unwrap_or_else(self, _: Callable[[], T]) -> T:
Expand Down Expand Up @@ -87,20 +87,20 @@ def is_nothing(self) -> bool:
def is_some(self) -> bool:
return False

def is_some_and(self, f: Callable[[T], bool]) -> bool:
def is_some_and(self, f: Callable[[Any], bool]) -> bool:
return False

@property
def value(self) -> None:
return None

def map(self, _: Callable) -> "Nothing":
def map(self, _: Callable[[Any], U]) -> "Nothing":
return self

def map_or(self, default: U, _: Callable) -> U:
def map_or(self, default: U, _: Callable[[Any], U]) -> U:
return default

def map_or_else(self, default: Callable[[], U], _: Callable[[T], U]) -> U:
def map_or_else(self, default: Callable[[], U], _: Callable[[Any], U]) -> U:
return default()

def or_else(self, f: Callable[[], Some[T]]) -> Some[T]:
Expand All @@ -109,7 +109,7 @@ def or_else(self, f: Callable[[], Some[T]]) -> Some[T]:
def unwrap(self) -> NoReturn:
raise UnwrapError(self, "Called `Option.unwrap()` on an `Nothing` value")

def unwrap_or(self, default: T) -> T:
def unwrap_or(self, default: U) -> U:
return default

def unwrap_or_else(self, default: Callable[[], T]) -> T:
Expand Down

0 comments on commit 4ccb777

Please sign in to comment.