Skip to content
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
15 changes: 6 additions & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,31 +1,29 @@
---
on:
push:
branches:
# - main
pull_request:

name: CI

jobs:

test:
runs-on: ubuntu-latest
strategy:
matrix:
python:
- '3.13'
- '3.12'
- '3.11'
- '3.10'
- "3.14"
- "3.13"
- "3.12"
- "3.11"
- "3.10"
name: Python ${{ matrix.python }}
steps:
- uses: actions/checkout@v4
- name: Install the latest version of uv and set the python version
uses: astral-sh/setup-uv@v5
with:
python-version: ${{ matrix.python }}

# Quality
- name: Test with python ${{ matrix.python }}
run: uv run --frozen pytest
Expand All @@ -37,4 +35,3 @@ jobs:
# Packaging
- name: Build packages
run: uv build

2 changes: 1 addition & 1 deletion .python-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.13
3.14
40 changes: 23 additions & 17 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,22 @@

## [Unreleased]

- Added Python 3.14

## [0.19.0]

### Breaking

- Dropped Python 3.8 & 3.9 to simplify maintenance

### Features

- Added Python 3.13
- Added support for `@as_generator_result` and `@as_async_generator_result`, which function like `@as_result` but wrap the yield values of a generator
- Allow bubbling up unwrapping of nested `Result` inside the `@as_*` decorated classes. If you unwrap an `Err` of an exception type that you handle in the generator, it will return that `Err(Exception)`from the decorated function as if you had thrown the Exception directly.

### Fixes

- Switch to a uv build system with hatch
- Switched linter to Ruff
- Updated the links to point to forked repo
Expand Down Expand Up @@ -45,7 +52,7 @@

## [0.13.1] - 2023-07-19

- `[fixed]` Use `self._value` instead of deprecated `self.value` in `Err.expect` and `Err.unwrap` to avoid raising a warning (#133)
- `[fixed]` Use `self._value` instead of deprecated `self.value` in `Err.expect` and `Err.unwrap` to avoid raising a warning (#133)

## [0.13.0] - 2023-07-15

Expand Down Expand Up @@ -108,49 +115,48 @@ safe. Unfortunately this means some breaking changes. Please check out
[MIGRATING.md], it will guide you through the necessary changes in your
codebase.


- [changed] Split result type into `Ok` and `Err` classes (#17, #27)
- [deprecated] Python 3.4 support is deprecated and will be removed in the next
release

## [0.5.0] - 2020-03-03

- [added] Implement `map`, `map_err`, `map_or` and `map_or_else` (#19)
- [added] Add `unwrap_err` and `expect_err` methods (#26)
- [changed] Type annotations: Change parameter order
from `Result[E, T]` to `Result[T, E]` to match Rust/OCaml/F# (#7)
- [added] Implement `map`, `map_err`, `map_or` and `map_or_else` (#19)
- [added] Add `unwrap_err` and `expect_err` methods (#26)
- [changed] Type annotations: Change parameter order
from `Result[E, T]` to `Result[T, E]` to match Rust/OCaml/F# (#7)

## [0.4.1] - 2020-02-17

- [added] Add `py.typed` for PEP561 package compliance (#16)
- [added] Add `py.typed` for PEP561 package compliance (#16)

## [0.4.0] - 2019-04-17

- [added] Add `unwrap`, `unwrap_or` and `expect` (#9)
- [removed] Drop support for Python 2 and 3.3
- [changed] Only install typing dependency for Python <3.5
- [added] Add `unwrap`, `unwrap_or` and `expect` (#9)
- [removed] Drop support for Python 2 and 3.3
- [changed] Only install typing dependency for Python <3.5

## [0.3.0] - 2017-07-12

- [added] This library is now fully type annotated (#4, thanks @tyehle)
- [added] Implementations for `__ne__`, `__hash__` and `__repr__`
- [deprecated] Python 2 support is deprecated and will be removed in the 0.4 release
- [added] This library is now fully type annotated (#4, thanks @tyehle)
- [added] Implementations for `__ne__`, `__hash__` and `__repr__`
- [deprecated] Python 2 support is deprecated and will be removed in the 0.4 release

## [0.2.2] - 2016-09-21

- [added] `__eq__` magic method
- [added] `__eq__` magic method

## [0.2.0] - 2016-05-05

- [added] Convenience default: `Ok()` == `Ok(True)`
- [added] Convenience default: `Ok()` == `Ok(True)`

## [0.1.1] - 2015-12-14

- [fixed] Import bugfix
- [fixed] Import bugfix

## [0.1.0] - 2015-12-14

- Initial version
- Initial version

[MIGRATING.md]: https://github.com/rustedpy/result/blob/main/MIGRATING.md
[Unreleased]: https://github.com/rustedpy/result/compare/v0.17.0...HEAD
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ classifiers = [
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: 3.14",
"Programming Language :: Python :: 3 :: Only",
]
requires-python = ">=3.10"
Expand Down
10 changes: 5 additions & 5 deletions tests/type_checking/test_result.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@


res1: Result[str, int] = Ok('hello')
reveal_type(res1) # N: Revealed type is "Union[result.result.Ok[builtins.str], result.result.Err[builtins.int]]"
reveal_type(res1) # N: Revealed type is "result.result.Ok[builtins.str] | result.result.Err[builtins.int]"
if isinstance(res1, Ok):
ok: Ok[str] = res1
reveal_type(ok) # N: Revealed type is "result.result.Ok[builtins.str]"
Expand All @@ -23,7 +23,7 @@
errValue: int = err.err()
reveal_type(errValue) # N: Revealed type is "builtins.int"
mapped_to_list: Optional[List[int]] = res1.map_err(lambda e: [e]).err()
reveal_type(mapped_to_list) # N: Revealed type is "Union[builtins.list[builtins.int], None]"
reveal_type(mapped_to_list) # N: Revealed type is "builtins.list[builtins.int] | None"

# Test constructor functions
res2 = Ok(42)
Expand All @@ -35,7 +35,7 @@
add1: Callable[[int], Result[int, str]] = lambda i: Ok(i + 1)
toint: Callable[[str], Result[int, str]] = lambda i: Ok(int(i))
res5 = res4.and_then(add1)
reveal_type(res5) # N: Revealed type is "Union[result.result.Ok[builtins.int], result.result.Err[builtins.str]]"
reveal_type(res5) # N: Revealed type is "result.result.Ok[builtins.int] | result.result.Err[builtins.str]"
res6 = res4.or_else(toint)
reveal_type(res6) # N: Revealed type is "result.result.Ok[builtins.int]"

Expand Down Expand Up @@ -77,10 +77,10 @@
greeting_res: Result[str, ValueError] = Ok("Hello")

personalized_greeting_res = greeting_res.map(lambda g: f"{g}, John")
reveal_type(personalized_greeting_res) # N: Revealed type is "Union[result.result.Ok[builtins.str], result.result.Err[builtins.ValueError]]"
reveal_type(personalized_greeting_res) # N: Revealed type is "result.result.Ok[builtins.str] | result.result.Err[builtins.ValueError]"

personalized_greeting = personalized_greeting_res.ok()
reveal_type(personalized_greeting) # N: Revealed type is "Union[builtins.str, None]"
reveal_type(personalized_greeting) # N: Revealed type is "builtins.str | None"

- case: map_result
disable_cache: false
Expand Down
Loading