Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make type checkers happy #3

Merged
merged 2 commits into from
Oct 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading