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

Remove support for Python 3.8 #196

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
7 changes: 3 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ jobs:
- '3.11'
- '3.10'
- '3.9'
- '3.8'
name: Python ${{ matrix.python }}
steps:
# Python
Expand Down Expand Up @@ -46,7 +45,7 @@ jobs:
- name: Run tests
run: pytest --ignore=tests/test_pattern_matching.py --ignore=tests/type_checking/test_result.yml
- name: Run tests (type checking)
if: matrix.python != '3.8' && matrix.python != '3.9'
if: matrix.python != '3.9'
# These started breaking for <= 3.9, due to the type checker using a
# '|' for unions rather than 'Union[...]', so it's not possible to run
# the tests without maintaining two duplicate files (one for <= 3.9 and
Expand All @@ -59,10 +58,10 @@ jobs:
# Linters
- name: Run flake8 (Python >= 3.10)
run: make lint-flake
if: matrix.python != '3.9' && matrix.python != '3.8'
if: matrix.python != '3.9'
- name: Run flake8 (Python < 3.10)
run: make lint-flake-pre310
if: matrix.python == '3.9' || matrix.python == '3.8'
if: matrix.python == '3.9'
- name: Run mypy
run: make lint-mypy

Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Possible log types:

- `[changed]` Improve type narrowing for `is_ok` and `is_err` type guards by
replacing `typing.TypeGuard` with `typing.TypeIs` (#193)
- `[removed]` Drop support for Python 3.8 (#180)

## [0.17.0] - 2024-06-02

Expand Down
3 changes: 1 addition & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ classifiers =
Development Status :: 4 - Beta
License :: OSI Approved :: MIT License
Programming Language :: Python :: 3
Programming Language :: Python :: 3.8
Programming Language :: Python :: 3.9
Programming Language :: Python :: 3.10
Programming Language :: Python :: 3.11
Expand All @@ -29,7 +28,7 @@ install_requires =
package_dir =
=src
packages = find:
python_requires = >=3.8
python_requires = >=3.9
zip_safe = True

[options.packages.find]
Expand Down
20 changes: 8 additions & 12 deletions src/result/result.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,15 @@
from warnings import warn
from typing import (
Any,
AsyncGenerator,
Awaitable,
Callable,
Final,
Generator,
Generic,
Iterator,
Literal,
NoReturn,
Type,
TypeVar,
Union,
)
from collections.abc import AsyncGenerator, Awaitable, Generator, Iterator

from typing_extensions import TypeIs

Expand Down Expand Up @@ -52,7 +48,7 @@ def __init__(self, value: T) -> None:
self._value = value

def __repr__(self) -> str:
return "Ok({})".format(repr(self._value))
return f"Ok({repr(self._value)})"

def __eq__(self, other: Any) -> bool:
return isinstance(other, Ok) and self._value == other._value
Expand Down Expand Up @@ -251,7 +247,7 @@ def __init__(self, value: E) -> None:
self._value = value

def __repr__(self) -> str:
return "Err({})".format(repr(self._value))
return f"Err({repr(self._value)})"

def __eq__(self, other: Any) -> bool:
return isinstance(other, Err) and self._value == other._value
Expand Down Expand Up @@ -352,7 +348,7 @@ def unwrap_or_else(self, op: Callable[[E], T]) -> T:
"""
return op(self._value)

def unwrap_or_raise(self, e: Type[TBE]) -> NoReturn:
def unwrap_or_raise(self, e: type[TBE]) -> NoReturn:
"""
The contained result is ``Err``, so raise the exception with the value.
"""
Expand Down Expand Up @@ -465,7 +461,7 @@ def result(self) -> Result[Any, Any]:


def as_result(
*exceptions: Type[TBE],
*exceptions: type[TBE],
) -> Callable[[Callable[P, R]], Callable[P, Result[R, TBE]]]:
"""
Make a decorator to turn a function into one that returns a ``Result``.
Expand Down Expand Up @@ -497,7 +493,7 @@ def wrapper(*args: P.args, **kwargs: P.kwargs) -> Result[R, TBE]:


def as_async_result(
*exceptions: Type[TBE],
*exceptions: type[TBE],
) -> Callable[[Callable[P, Awaitable[R]]], Callable[P, Awaitable[Result[R, TBE]]]]:
"""
Make a decorator to turn an async function into one that returns a ``Result``.
Expand Down Expand Up @@ -563,7 +559,7 @@ def is_err(result: Result[T, E]) -> TypeIs[Err[E]]:
return result.is_err()


def do(gen: Generator[Result[T, E], None, None]) -> Result[T, E]:
def do(gen: Generator[Result[T, E]]) -> Result[T, E]:
"""Do notation for Result (syntactic sugar for sequence of `and_then()` calls).


Expand Down Expand Up @@ -609,7 +605,7 @@ def do(gen: Generator[Result[T, E], None, None]) -> Result[T, E]:


async def do_async(
gen: Union[Generator[Result[T, E], None, None], AsyncGenerator[Result[T, E], None]]
gen: Generator[Result[T, E]] | AsyncGenerator[Result[T, E]]
) -> Result[T, E]:
"""Async version of do. Example:

Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tox]
envlist = py312,py311,py310,py39,py38
envlist = py312,py311,py310,py39

[testenv]
deps = -rrequirements-dev.txt
Expand Down
Loading