Skip to content

Commit 095d0b6

Browse files
authored
Update to python3.8 (#1669)
* Update to python3.8 * Fix CI
1 parent 1ab51a2 commit 095d0b6

File tree

92 files changed

+304
-307
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

92 files changed

+304
-307
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ def view(request: HttpRequest) -> HttpResponse:
207207

208208
# Somewhere in your `words_app/logic.py`:
209209

210-
from typing_extensions import Protocol
210+
from typing import Protocol
211211
from returns.context import RequiresContext
212212

213213
class _Deps(Protocol): # we rely on abstractions, not direct values or types

docs/pages/context.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ Let's see how our code changes:
119119
120120
# Somewhere in your `words_app/logic.py`:
121121
122-
from typing_extensions import Protocol
122+
from typing import Protocol
123123
from returns.context import RequiresContext
124124
125125
class _Deps(Protocol): # we rely on abstractions, not direct values or types

docs/pages/contrib/hypothesis_plugins.rst

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,7 @@ but with ``__init__`` defined:
105105

106106
.. code:: python
107107
108-
from typing import Callable, TypeVar
109-
from typing_extensions import final
108+
from typing import Callable, TypeVar, final
110109
from returns.interfaces.mappable import Mappable1
111110
from returns.primitives.container import BaseContainer
112111
from returns.primitives.hkt import SupportsKind1

docs/pages/create-your-own-container.rst

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,7 @@ Let's look at the result:
8383

8484
.. code: python
8585
86-
>>> from typing_extensions import final
87-
>>> from typing import Callable, TypeVar, Tuple
86+
>>> from typing import Callable, TypeVar, Tuple, final
8887
8988
>>> from returns.interfaces import bindable, equable, lashable, swappable
9089
>>> from returns.primitives.container import BaseContainer

docs/pages/pointfree.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ This inverse syntax lets us easily compose functions in a pipeline
215215
... return exit_code * 2
216216
217217
>>> def make_error_message(exit_code: int) -> str:
218-
... return f'Badness level: {exit_code}'
218+
... return 'Badness level: {0}'.format(exit_code)
219219
220220
>>> assert flow(
221221
... '12345',

returns/context/requires_context.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
from __future__ import annotations
22

3-
from typing import TYPE_CHECKING, Any, Callable, ClassVar, TypeVar
4-
5-
from typing_extensions import final
3+
from typing import TYPE_CHECKING, Any, Callable, ClassVar, TypeVar, final
64

75
from returns.functions import identity
86
from returns.future import FutureResult
@@ -153,7 +151,7 @@ def map(
153151
def apply(
154152
self,
155153
container: Kind2[
156-
'RequiresContext',
154+
RequiresContext,
157155
Callable[[_ReturnType], _NewReturnType],
158156
_EnvType,
159157
],
@@ -177,7 +175,7 @@ def bind(
177175
self,
178176
function: Callable[
179177
[_ReturnType],
180-
Kind2['RequiresContext', _NewReturnType, _EnvType],
178+
Kind2[RequiresContext, _NewReturnType, _EnvType],
181179
],
182180
) -> RequiresContext[_NewReturnType, _EnvType]:
183181
"""
@@ -355,7 +353,7 @@ def from_context(
355353
@classmethod
356354
def from_requires_context_result(
357355
cls,
358-
inner_value: 'RequiresContextResult[_ValueType, _ErrorType, _EnvType]',
356+
inner_value: RequiresContextResult[_ValueType, _ErrorType, _EnvType],
359357
) -> RequiresContext[Result[_ValueType, _ErrorType], _EnvType]:
360358
"""
361359
Typecasts ``RequiresContextResult`` to ``RequiresContext`` instance.
@@ -381,7 +379,7 @@ def from_requires_context_result(
381379
def from_requires_context_ioresult(
382380
cls,
383381
inner_value:
384-
'RequiresContextIOResult[_ValueType, _ErrorType, _EnvType]',
382+
RequiresContextIOResult[_ValueType, _ErrorType, _EnvType],
385383
) -> RequiresContext[IOResult[_ValueType, _ErrorType], _EnvType]:
386384
"""
387385
Typecasts ``RequiresContextIOResult`` to ``RequiresContext`` instance.
@@ -406,8 +404,9 @@ def from_requires_context_ioresult(
406404
@classmethod
407405
def from_requires_context_future_result(
408406
cls,
409-
inner_value:
410-
'RequiresContextFutureResult[_ValueType, _ErrorType, _EnvType]',
407+
inner_value: RequiresContextFutureResult[
408+
_ValueType, _ErrorType, _EnvType,
409+
],
411410
) -> RequiresContext[FutureResult[_ValueType, _ErrorType], _EnvType]:
412411
"""
413412
Typecasts ``RequiresContextIOResult`` to ``RequiresContext`` instance.

returns/context/requires_context_future_result.py

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
from __future__ import annotations
22

3-
from typing import TYPE_CHECKING, Any, Awaitable, Callable, ClassVar, TypeVar
4-
5-
from typing_extensions import final
3+
from typing import (
4+
TYPE_CHECKING,
5+
Any,
6+
Awaitable,
7+
Callable,
8+
ClassVar,
9+
TypeVar,
10+
final,
11+
)
612

713
from returns._internal.futures import _reader_future_result
814
from returns.context import NoDeps
@@ -434,7 +440,7 @@ def bind_context(
434440
self,
435441
function: Callable[
436442
[_ValueType],
437-
'RequiresContext[_NewValueType, _EnvType]',
443+
RequiresContext[_NewValueType, _EnvType],
438444
],
439445
) -> RequiresContextFutureResult[_NewValueType, _ErrorType, _EnvType]:
440446
"""
@@ -474,7 +480,7 @@ def bind_context_result(
474480
self,
475481
function: Callable[
476482
[_ValueType],
477-
'RequiresContextResult[_NewValueType, _ErrorType, _EnvType]',
483+
RequiresContextResult[_NewValueType, _ErrorType, _EnvType],
478484
],
479485
) -> RequiresContextFutureResult[_NewValueType, _ErrorType, _EnvType]:
480486
"""
@@ -517,7 +523,7 @@ def bind_context_ioresult(
517523
self,
518524
function: Callable[
519525
[_ValueType],
520-
'RequiresContextIOResult[_NewValueType, _ErrorType, _EnvType]',
526+
RequiresContextIOResult[_NewValueType, _ErrorType, _EnvType],
521527
],
522528
) -> RequiresContextFutureResult[_NewValueType, _ErrorType, _EnvType]:
523529
"""
@@ -1180,8 +1186,9 @@ def from_future_result(
11801186
@classmethod
11811187
def from_typecast(
11821188
cls,
1183-
inner_value: 'RequiresContext['
1184-
'FutureResult[_NewValueType, _NewErrorType], _EnvType]',
1189+
inner_value: RequiresContext[
1190+
FutureResult[_NewValueType, _NewErrorType], _EnvType,
1191+
],
11851192
) -> RequiresContextFutureResult[_NewValueType, _NewErrorType, _EnvType]:
11861193
"""
11871194
You might end up with ``RequiresContext[FutureResult]`` as a value.
@@ -1217,7 +1224,7 @@ def from_typecast(
12171224

12181225
@classmethod
12191226
def from_context(
1220-
cls, inner_value: 'RequiresContext[_NewValueType, _NewEnvType]',
1227+
cls, inner_value: RequiresContext[_NewValueType, _NewEnvType],
12211228
) -> RequiresContextFutureResult[_NewValueType, Any, _NewEnvType]:
12221229
"""
12231230
Creates new container from ``RequiresContext`` as a success unit.
@@ -1242,7 +1249,7 @@ def from_context(
12421249

12431250
@classmethod
12441251
def from_failed_context(
1245-
cls, inner_value: 'RequiresContext[_NewValueType, _NewEnvType]',
1252+
cls, inner_value: RequiresContext[_NewValueType, _NewEnvType],
12461253
) -> RequiresContextFutureResult[Any, _NewValueType, _NewEnvType]:
12471254
"""
12481255
Creates new container from ``RequiresContext`` as a failure unit.
@@ -1268,8 +1275,9 @@ def from_failed_context(
12681275
@classmethod
12691276
def from_result_context(
12701277
cls,
1271-
inner_value:
1272-
'RequiresContextResult[_NewValueType, _NewErrorType, _NewEnvType]',
1278+
inner_value: RequiresContextResult[
1279+
_NewValueType, _NewErrorType, _NewEnvType,
1280+
],
12731281
) -> ReaderFutureResult[_NewValueType, _NewErrorType, _NewEnvType]:
12741282
"""
12751283
Creates new container from ``RequiresContextResult`` as a unit value.
@@ -1303,7 +1311,7 @@ def from_result_context(
13031311
def from_ioresult_context(
13041312
cls,
13051313
inner_value:
1306-
'ReaderIOResult[_NewValueType, _NewErrorType, _NewEnvType]',
1314+
ReaderIOResult[_NewValueType, _NewErrorType, _NewEnvType],
13071315
) -> ReaderFutureResult[_NewValueType, _NewErrorType, _NewEnvType]:
13081316
"""
13091317
Creates new container from ``RequiresContextIOResult`` as a unit value.

returns/context/requires_context_ioresult.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
from __future__ import annotations
22

3-
from typing import TYPE_CHECKING, Any, Callable, ClassVar, TypeVar
4-
5-
from typing_extensions import final
3+
from typing import TYPE_CHECKING, Any, Callable, ClassVar, TypeVar, final
64

75
from returns.context import NoDeps
86
from returns.interfaces.specific import reader_ioresult
@@ -329,7 +327,7 @@ def bind_context(
329327
self,
330328
function: Callable[
331329
[_ValueType],
332-
'RequiresContext[_NewValueType, _EnvType]',
330+
RequiresContext[_NewValueType, _EnvType],
333331
],
334332
) -> RequiresContextIOResult[_NewValueType, _ErrorType, _EnvType]:
335333
"""
@@ -364,7 +362,7 @@ def bind_context_result(
364362
self,
365363
function: Callable[
366364
[_ValueType],
367-
'RequiresContextResult[_NewValueType, _ErrorType, _EnvType]',
365+
RequiresContextResult[_NewValueType, _ErrorType, _EnvType],
368366
],
369367
) -> RequiresContextIOResult[_NewValueType, _ErrorType, _EnvType]:
370368
"""
@@ -756,8 +754,9 @@ def from_ioresult_context(
756754
@classmethod
757755
def from_typecast(
758756
cls,
759-
inner_value:
760-
'RequiresContext[IOResult[_NewValueType, _NewErrorType], _EnvType]',
757+
inner_value: RequiresContext[
758+
IOResult[_NewValueType, _NewErrorType], _EnvType,
759+
],
761760
) -> RequiresContextIOResult[_NewValueType, _NewErrorType, _EnvType]:
762761
"""
763762
You might end up with ``RequiresContext[IOResult]`` as a value.
@@ -785,7 +784,7 @@ def from_typecast(
785784

786785
@classmethod
787786
def from_context(
788-
cls, inner_value: 'RequiresContext[_NewValueType, _NewEnvType]',
787+
cls, inner_value: RequiresContext[_NewValueType, _NewEnvType],
789788
) -> RequiresContextIOResult[_NewValueType, Any, _NewEnvType]:
790789
"""
791790
Creates new container from ``RequiresContext`` as a success unit.
@@ -806,7 +805,7 @@ def from_context(
806805

807806
@classmethod
808807
def from_failed_context(
809-
cls, inner_value: 'RequiresContext[_NewValueType, _NewEnvType]',
808+
cls, inner_value: RequiresContext[_NewValueType, _NewEnvType],
810809
) -> RequiresContextIOResult[Any, _NewValueType, _NewEnvType]:
811810
"""
812811
Creates new container from ``RequiresContext`` as a failure unit.
@@ -828,8 +827,9 @@ def from_failed_context(
828827
@classmethod
829828
def from_result_context(
830829
cls,
831-
inner_value:
832-
'RequiresContextResult[_NewValueType, _NewErrorType, _NewEnvType]',
830+
inner_value: RequiresContextResult[
831+
_NewValueType, _NewErrorType, _NewEnvType,
832+
],
833833
) -> RequiresContextIOResult[_NewValueType, _NewErrorType, _NewEnvType]:
834834
"""
835835
Creates new container from ``RequiresContextResult`` as a unit value.

returns/context/requires_context_result.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
from __future__ import annotations
22

3-
from typing import TYPE_CHECKING, Any, Callable, ClassVar, TypeVar
4-
5-
from typing_extensions import final
3+
from typing import TYPE_CHECKING, Any, Callable, ClassVar, TypeVar, final
64

75
from returns.context import NoDeps
86
from returns.interfaces.specific import reader_result
@@ -307,7 +305,7 @@ def bind_context(
307305
self,
308306
function: Callable[
309307
[_ValueType],
310-
'RequiresContext[_NewValueType, _EnvType]',
308+
RequiresContext[_NewValueType, _EnvType],
311309
],
312310
) -> RequiresContextResult[_NewValueType, _ErrorType, _EnvType]:
313311
"""
@@ -481,8 +479,9 @@ def from_result(
481479
@classmethod
482480
def from_typecast(
483481
cls,
484-
inner_value:
485-
'RequiresContext[Result[_NewValueType, _NewErrorType], _EnvType]',
482+
inner_value: RequiresContext[
483+
Result[_NewValueType, _NewErrorType], _EnvType,
484+
],
486485
) -> RequiresContextResult[_NewValueType, _NewErrorType, _EnvType]:
487486
"""
488487
You might end up with ``RequiresContext[Result[...]]`` as a value.
@@ -510,7 +509,7 @@ def from_typecast(
510509

511510
@classmethod
512511
def from_context(
513-
cls, inner_value: 'RequiresContext[_NewValueType, _NewEnvType]',
512+
cls, inner_value: RequiresContext[_NewValueType, _NewEnvType],
514513
) -> RequiresContextResult[_NewValueType, Any, _NewEnvType]:
515514
"""
516515
Creates new container from ``RequiresContext`` as a success unit.
@@ -528,7 +527,7 @@ def from_context(
528527

529528
@classmethod
530529
def from_failed_context(
531-
cls, inner_value: 'RequiresContext[_NewValueType, _NewEnvType]',
530+
cls, inner_value: RequiresContext[_NewValueType, _NewEnvType],
532531
) -> RequiresContextResult[Any, _NewValueType, _NewEnvType]:
533532
"""
534533
Creates new container from ``RequiresContext`` as a failure unit.
@@ -547,8 +546,9 @@ def from_failed_context(
547546
@classmethod
548547
def from_result_context(
549548
cls,
550-
inner_value:
551-
RequiresContextResult[_NewValueType, _NewErrorType, _NewEnvType],
549+
inner_value: RequiresContextResult[
550+
_NewValueType, _NewErrorType, _NewEnvType,
551+
],
552552
) -> RequiresContextResult[_NewValueType, _NewErrorType, _NewEnvType]:
553553
"""
554554
Creates ``RequiresContextResult`` from another instance of it.

returns/contrib/hypothesis/containers.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from __future__ import annotations
22

3-
from typing import TYPE_CHECKING, Any, Callable, List, Type, TypeVar
3+
from typing import TYPE_CHECKING, Any, Callable, TypeVar
44

55
from hypothesis import strategies as st
66

@@ -9,7 +9,7 @@
99

1010

1111
def strategy_from_container(
12-
container_type: Type['Lawful'],
12+
container_type: type[Lawful],
1313
*,
1414
use_init: bool = False,
1515
) -> Callable[[type], st.SearchStrategy]:
@@ -37,7 +37,7 @@ def strategy_from_container(
3737
def factory(type_: type) -> st.SearchStrategy:
3838
value_type, error_type = _get_type_vars(type_)
3939

40-
strategies: List[st.SearchStrategy[Any]] = []
40+
strategies: list[st.SearchStrategy[Any]] = []
4141
if use_init and getattr(container_type, '__init__', None):
4242
strategies.append(st.builds(container_type))
4343
if issubclass(container_type, ApplicativeN):

returns/contrib/hypothesis/laws.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@
99
Optional,
1010
Type,
1111
TypeVar,
12+
final,
1213
)
1314

1415
import pytest
1516
from hypothesis import given
1617
from hypothesis import settings as hypothesis_settings
1718
from hypothesis import strategies as st
1819
from hypothesis.strategies._internal import types
19-
from typing_extensions import final
2020

2121
from returns.contrib.hypothesis.containers import strategy_from_container
2222
from returns.primitives.laws import Law, Lawful

returns/contrib/mypy/_consts.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing_extensions import Final
1+
from typing import Final
22

33
# Constant fullnames for typechecking
44
# ===================================

returns/contrib/mypy/_features/curry.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
from itertools import groupby, product
22
from operator import itemgetter
3-
from typing import Iterator, List, Optional, Tuple, cast
3+
from typing import Iterator, List, Optional, Tuple, cast, final
44

55
from mypy.nodes import ARG_STAR, ARG_STAR2
66
from mypy.plugin import FunctionContext
77
from mypy.types import AnyType, CallableType, FunctionLike, Overloaded
88
from mypy.types import Type as MypyType
99
from mypy.types import TypeOfAny
10-
from typing_extensions import final
1110

1211
from returns.contrib.mypy._structures.args import FuncArg
1312
from returns.contrib.mypy._typeops.transform_callable import (

0 commit comments

Comments
 (0)