33from typing import Any
44
55import pytest
6- from hypothesis import example , given
6+ from hypothesis import given
77from hypothesis import strategies as st
88
99from returns .io import IO
10- from returns .maybe import Maybe , Nothing , Some
10+ from returns .maybe import Nothing , Some
1111from returns .primitives .container import BaseContainer
12- from returns .result import Failure , Result , Success
12+ from returns .result import Failure , Success
1313
1414
1515@given (st .integers (), st .integers ())
@@ -25,7 +25,9 @@ def test_base_container_replace_inner_value(initial: int, new_val: int):
2525
2626
2727@given (st .text (), st .text ())
28- def test_base_container_replace_underscore_inner_value (initial : str , new_val : str ):
28+ def test_base_container_replace_underscore_inner_value (
29+ initial : str , new_val : str
30+ ):
2931 """Ensures that __replace__ accepts _inner_value keyword argument."""
3032 container = BaseContainer (initial )
3133 replaced = container .__replace__ (_inner_value = new_val )
@@ -46,14 +48,16 @@ def test_base_container_replace_no_args():
4648def test_base_container_replace_unexpected_kwarg ():
4749 """Ensures that unexpected kwargs raise TypeError."""
4850 container = BaseContainer (42 )
49- with pytest .raises (TypeError , match = "unexpected keyword argument 'invalid'" ):
51+ with pytest .raises (
52+ TypeError , match = "unexpected keyword argument 'invalid'"
53+ ):
5054 container .__replace__ (invalid = True )
5155
5256
5357def test_base_container_replace_multiple_values ():
5458 """Ensures providing both inner_value and _inner_value raises TypeError."""
5559 container = BaseContainer (42 )
56- with pytest .raises (TypeError , match = " multiple values for inner value" ):
60+ with pytest .raises (TypeError , match = ' multiple values for inner value' ):
5761 container .__replace__ (inner_value = 1 , _inner_value = 2 )
5862
5963
@@ -66,7 +70,9 @@ def test_base_container_replace_multiple_values():
6670 (IO (100 ), 200 , IO (200 )),
6771 ],
6872)
69- def test_concrete_containers_replace (container : Any , new_value : Any , expected : Any ):
73+ def test_concrete_containers_replace (
74+ container : Any , new_value : Any , expected : Any
75+ ):
7076 """Ensures concrete containers support __replace__."""
7177 replaced = container .__replace__ (inner_value = new_value )
7278 assert replaced == expected
@@ -79,17 +85,23 @@ def test_nothing_replace():
7985 assert Nothing .__replace__ (inner_value = None ) is Nothing
8086 assert Nothing .__replace__ (_inner_value = None ) is Nothing
8187
82- with pytest .raises (TypeError , match = "Cannot replace inner_value on Nothing" ):
88+ with pytest .raises (
89+ TypeError , match = 'Cannot replace inner_value on Nothing'
90+ ):
8391 Nothing .__replace__ (inner_value = 42 )
8492
85- with pytest .raises (TypeError , match = "Cannot replace _inner_value on Nothing" ):
93+ with pytest .raises (
94+ TypeError , match = 'Cannot replace _inner_value on Nothing'
95+ ):
8696 Nothing .__replace__ (_inner_value = 42 )
8797
8898
89- @pytest .mark .skipif (sys .version_info < (3 , 13 ), reason = "copy.replace was added in Python 3.13" )
99+ @pytest .mark .skipif (
100+ sys .version_info < (3 , 13 ), reason = 'copy.replace was added in Python 3.13'
101+ )
90102def test_copy_replace_standard_library ():
91103 """Ensures stdlib copy.replace works seamlessly on Python 3.13+."""
92- replace = getattr ( copy , " replace" )
104+ replace = copy . replace
93105 s = Success (1 )
94106 replaced = replace (s , inner_value = 2 )
95107 assert replaced == Success (2 )
0 commit comments