Skip to content

Commit be9c23b

Browse files
committed
Fix all the typing reports in typesafety
1 parent 26680f0 commit be9c23b

File tree

65 files changed

+257
-290
lines changed

Some content is hidden

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

65 files changed

+257
-290
lines changed
Lines changed: 20 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
- case: check_all_laws
22
disable_cache: false
33
parametrized:
4-
- container: Result
5-
- container: Maybe
6-
- container: IO
7-
- container: IOResult
8-
- container: Reader
9-
- container: ReaderResult
10-
- container: ReaderIOResult
11-
- container: ReaderFutureResult
12-
- container: Future
13-
- container: FutureResult
4+
- container: Result
5+
- container: Maybe
6+
- container: IO
7+
- container: IOResult
8+
- container: Reader
9+
- container: ReaderResult
10+
- container: ReaderIOResult
11+
- container: ReaderFutureResult
12+
- container: Future
13+
- container: FutureResult
1414
main: |
1515
from returns.context import (
1616
Reader, ReaderResult, ReaderIOResult, ReaderFutureResult,
@@ -25,14 +25,10 @@
2525
2626
x: Type[Lawful] = {{ container }}
2727
28+
2829
- case: test_all_laws_accepts_only_one_approach
2930
disable_cache: false
30-
# TODO: remove this config after
31-
# mypy/typeshed/stdlib/unittest/mock.pyi:120:
32-
# error: Class cannot subclass "Any" (has type "Any")
33-
# is fixed.
34-
mypy_config:
35-
disallow_subclassing_any = False
31+
mypy_config: disallow_subclassing_any = False
3632
main: |
3733
from hypothesis import strategies as st
3834
from returns.contrib.hypothesis.laws import check_all_laws
@@ -44,31 +40,25 @@
4440
check_all_laws(
4541
Result, use_init=True, container_strategy=st.builds(Success, st.integers())
4642
)
47-
4843
out: |
49-
main:8: error: No overload variant of "check_all_laws" matches argument types "Type[Result[_ValueType_co, _ErrorType_co]]", "bool", "SearchStrategy[Success[Any]]" [call-overload]
44+
main:8: error: No overload variant of "check_all_laws" matches argument types "type[Result[_ValueType_co, _ErrorType_co]]", "bool", "SearchStrategy[Success[Any]]" [call-overload]
5045
main:8: note: Possible overload variants:
51-
main:8: note: def [Example_co] check_all_laws(container_type: Type[Lawful[Example_co]], *, container_strategy: Union[SearchStrategy[Example_co], Callable[[Type[Example_co]], SearchStrategy[Example_co]]], settings_kwargs: Optional[Dict[str, Any]] = ..., type_strategies: Optional[Dict[Type[object], Union[SearchStrategy[Any], Callable[[Type[Any]], SearchStrategy[Any]]]]] = ...) -> None
52-
main:8: note: def [Example_co] check_all_laws(container_type: Type[Lawful[Example_co]], *, settings_kwargs: Optional[Dict[str, Any]] = ..., use_init: bool = ...) -> None
46+
main:8: note: def [Example_co] check_all_laws(container_type: type[Lawful[Example_co]], *, container_strategy: SearchStrategy[Example_co] | Callable[[type[Example_co]], SearchStrategy[Example_co]], settings_kwargs: dict[str, Any] | None = ..., type_strategies: dict[type[object], SearchStrategy[Any] | Callable[[type[Any]], SearchStrategy[Any]]] | None = ...) -> None
47+
main:8: note: def [Example_co] check_all_laws(container_type: type[Lawful[Example_co]], *, settings_kwargs: dict[str, Any] | None = ..., use_init: bool = ...) -> None
48+
5349
5450
- case: test_all_laws_requires_container_strategy
5551
disable_cache: false
56-
# TODO: remove this config after
57-
# mypy/typeshed/stdlib/unittest/mock.pyi:120:
58-
# error: Class cannot subclass "Any" (has type "Any")
59-
# is fixed.
60-
mypy_config:
61-
disallow_subclassing_any = False
52+
mypy_config: disallow_subclassing_any = False
6253
main: |
6354
from hypothesis import strategies as st
6455
from returns.contrib.hypothesis.laws import check_all_laws
6556
from returns.result import Result, Success
6657
6758
check_all_laws(Result, container_strategy=st.builds(Success, st.integers()), type_strategies={int: st.integers()})
6859
check_all_laws(Result, type_strategies={int: st.integers()})
69-
7060
out: |
71-
main:6: error: No overload variant of "check_all_laws" matches argument types "Type[Result[_ValueType_co, _ErrorType_co]]", "Dict[Type[int], SearchStrategy[int]]" [call-overload]
61+
main:6: error: No overload variant of "check_all_laws" matches argument types "type[Result[_ValueType_co, _ErrorType_co]]", "dict[type[int], SearchStrategy[int]]" [call-overload]
7262
main:6: note: Possible overload variants:
73-
main:6: note: def [Example_co] check_all_laws(container_type: Type[Lawful[Example_co]], *, container_strategy: Union[SearchStrategy[Example_co], Callable[[Type[Example_co]], SearchStrategy[Example_co]]], settings_kwargs: Optional[Dict[str, Any]] = ..., type_strategies: Optional[Dict[Type[object], Union[SearchStrategy[Any], Callable[[Type[Any]], SearchStrategy[Any]]]]] = ...) -> None
74-
main:6: note: def [Example_co] check_all_laws(container_type: Type[Lawful[Example_co]], *, settings_kwargs: Optional[Dict[str, Any]] = ..., use_init: bool = ...) -> None
63+
main:6: note: def [Example_co] check_all_laws(container_type: type[Lawful[Example_co]], *, container_strategy: SearchStrategy[Example_co] | Callable[[type[Example_co]], SearchStrategy[Example_co]], settings_kwargs: dict[str, Any] | None = ..., type_strategies: dict[type[object], SearchStrategy[Any] | Callable[[type[Any]], SearchStrategy[Any]]] | None = ...) -> None
64+
main:6: note: def [Example_co] check_all_laws(container_type: type[Lawful[Example_co]], *, settings_kwargs: dict[str, Any] | None = ..., use_init: bool = ...) -> None

typesafety/test_curry/test_curry/test_curry_arguments.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,6 @@
5858
reveal_type(MyClass(test)) # N: Revealed type is "main.MyClass[Overload(def (a: builtins.int) -> Overload(def (b: builtins.int, c: builtins.str) -> builtins.int, def (b: builtins.int) -> def (c: builtins.str) -> builtins.int), def (a: builtins.int, b: builtins.int) -> def (c: builtins.str) -> builtins.int, def (a: builtins.int, b: builtins.int, c: builtins.str) -> builtins.int)]"
5959
6060
61-
# TODO: remove skip after this bug in `mypy` is fixed:
62-
# https://github.com/python/mypy/issues/8801
6361
- case: curry_init_magic_method
6462
disable_cache: false
6563
skip: true
@@ -71,7 +69,7 @@
7169
def __init__(self, arg: int, other: str) -> None:
7270
...
7371
74-
reveal_type(Test) # N: Revealed type is "Overload(def (arg: builtins.int) -> def (other: builtins.str) -> ex.Test, def (arg: builtins.int, other: builtins.str) -> ex.Test)"
72+
reveal_type(Test) # N: Revealed type is "Overload(def () -> main.Test, def (arg: builtins.int) -> main.Test, def (arg: builtins.int, other: builtins.str) -> main.Test)"
7573
7674
7775
- case: curry_call_magic_method

typesafety/test_curry/test_curry/test_curry_generics.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,9 @@
5757
reveal_type(zero(1, y)) # N: Revealed type is "builtins.str"
5858
5959
60-
# TODO: enable and fix our plugin
6160
- case: curry_two_generic_args3
6261
disable_cache: false
63-
skip: True
62+
skip: true
6463
main: |
6564
from returns.curry import curry
6665
from typing import List, TypeVar
@@ -74,6 +73,6 @@
7473
x: List[int]
7574
7675
reveal_type(zero) # N: Revealed type is "Overload(def [T] (arg: T`-1) -> def [T] (other: builtins.list[T`-1]) -> T`-1, def [T] (arg: T`-1, other: builtins.list[T`-1]) -> T`-1)"
77-
reveal_type(zero(1)) # N: Revealed type is "def [T] (other: builtins.list[builtins.int]) -> builtins.int"
76+
reveal_type(zero(1)) # N: Revealed type is "def [T] (other: builtins.list[T`2]) -> T`2"
7877
reveal_type(zero(1)(x)) # N: Revealed type is "builtins.int"
7978
reveal_type(zero(1, x)) # N: Revealed type is "builtins.int"

typesafety/test_curry/test_partial/test_partial_arguments.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@
140140
# This does not work as well:
141141
reveal_type(partial(x, 1))
142142
out: |
143-
main:13: note: Revealed type is "Union[main.Inst, main.Other]"
143+
main:13: note: Revealed type is "main.Inst | main.Other"
144144
main:15: note: Revealed type is "def (*Any, **Any)"
145145
146146

typesafety/test_curry/test_partial/test_partial_generic.yml

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
reveal_type(partial(multiple, x)(y))
1919
out: |
2020
main:15: note: Revealed type is "builtins.int"
21-
main:15: error: Argument 1 to "multiple" has incompatible type "List[str]"; expected "List[int]" [arg-type]
21+
main:15: error: Argument 1 to "multiple" has incompatible type "list[str]"; expected "list[int]" [arg-type]
2222
2323
2424
- case: partial_correct_generic
@@ -79,7 +79,6 @@
7979
main:22: note: Revealed type is "builtins.int"
8080
8181
82-
# Python3.8+ sorts generic arguments differently:
8382
- case: partial_double_generic_complex38
8483
disable_cache: false
8584
main: |
@@ -107,12 +106,12 @@
107106
reveal_type(partial(multiple, 1, b=y))
108107
reveal_type(partial(multiple, 1, c=y))
109108
out: |
110-
main:18: note: Revealed type is "def [B, A] (a: builtins.int, *, b: builtins.list[B`-1], c: builtins.list[A`-2]) -> Union[A`-2, B`-1]"
111-
main:19: note: Revealed type is "def [B, A] (*, b: builtins.list[B`-1], c: builtins.list[A`-2]) -> Union[A`-2, B`-1]"
112-
main:20: note: Revealed type is "def [A] (*, c: builtins.list[A`-2]) -> Union[A`-2, builtins.int]"
113-
main:21: note: Revealed type is "def [B] (*, b: builtins.list[B`-1]) -> Union[builtins.int, B`-1]"
114-
main:22: note: Revealed type is "def [A] (*, c: builtins.list[A`-2]) -> Union[A`-2, builtins.str]"
115-
main:23: note: Revealed type is "def [B] (*, b: builtins.list[B`-1]) -> Union[builtins.str, B`-1]"
109+
main:18: note: Revealed type is "def [B, A] (a: builtins.int, *, b: builtins.list[B`-1], c: builtins.list[A`-2]) -> A`-2 | B`-1"
110+
main:19: note: Revealed type is "def [B, A] (*, b: builtins.list[B`-1], c: builtins.list[A`-2]) -> A`-2 | B`-1"
111+
main:20: note: Revealed type is "def [A] (*, c: builtins.list[A`-2]) -> A`-2 | builtins.int"
112+
main:21: note: Revealed type is "def [B] (*, b: builtins.list[B`-1]) -> builtins.int | B`-1"
113+
main:22: note: Revealed type is "def [A] (*, c: builtins.list[A`-2]) -> A`-2 | builtins.str"
114+
main:23: note: Revealed type is "def [B] (*, b: builtins.list[B`-1]) -> builtins.str | B`-1"
116115
117116
118117
- case: partial_double_generic
@@ -139,6 +138,6 @@
139138
reveal_type(partial(multiple, 1, b=x)(c=y))
140139
reveal_type(partial(multiple, 1, c=x)(b=y))
141140
out: |
142-
main:17: note: Revealed type is "def () -> Union[builtins.str, builtins.int]"
143-
main:19: note: Revealed type is "Union[builtins.str, builtins.int]"
144-
main:20: note: Revealed type is "Union[builtins.int, builtins.str]"
141+
main:17: note: Revealed type is "def () -> builtins.str | builtins.int"
142+
main:19: note: Revealed type is "builtins.str | builtins.int"
143+
main:20: note: Revealed type is "builtins.int | builtins.str"

typesafety/test_curry/test_partial/test_partial_overload.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -161,11 +161,11 @@
161161
reveal_type(partial(two_args, a, b))
162162
reveal_type(partial(two_args, b, a))
163163
out: |
164-
main:25: note: Revealed type is "Overload(def [A] (a: builtins.int, b: builtins.list[A`-1]) -> A`-1, def [B] (a: builtins.int, b: builtins.list[B`-1]) -> B`-1, def [A, B] (a: builtins.list[A`-1], b: builtins.list[B`-2]) -> Union[A`-1, B`-2])"
164+
main:25: note: Revealed type is "Overload(def [A] (a: builtins.int, b: builtins.list[A`-1]) -> A`-1, def [B] (a: builtins.int, b: builtins.list[B`-1]) -> B`-1, def [A, B] (a: builtins.list[A`-1], b: builtins.list[B`-2]) -> A`-1 | B`-2)"
165165
main:26: note: Revealed type is "Overload(def [A] (b: builtins.list[A`-1]) -> A`-1, def [B] (b: builtins.list[B`-1]) -> B`-1)"
166166
main:27: note: Revealed type is "Overload(def () -> builtins.float, def () -> builtins.float)"
167167
main:28: note: Revealed type is "Overload(def () -> builtins.str, def () -> builtins.str)"
168-
main:29: note: Revealed type is "def [B] (b: builtins.list[B`-2]) -> Union[builtins.float, B`-2]"
169-
main:30: note: Revealed type is "def [B] (b: builtins.list[B`-2]) -> Union[builtins.str, B`-2]"
170-
main:31: note: Revealed type is "def () -> Union[builtins.float, builtins.str]"
171-
main:32: note: Revealed type is "def () -> Union[builtins.str, builtins.float]"
168+
main:29: note: Revealed type is "def [B] (b: builtins.list[B`-2]) -> builtins.float | B`-2"
169+
main:30: note: Revealed type is "def [B] (b: builtins.list[B`-2]) -> builtins.str | B`-2"
170+
main:31: note: Revealed type is "def () -> builtins.float | builtins.str"
171+
main:32: note: Revealed type is "def () -> builtins.str | builtins.float"
Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,8 @@
11
- case: test_pair_type
22
disable_cache: false
33
env:
4-
# We only need this because we store this example in `tests/`
5-
# and not in our source code. Please, do not copy this line!
6-
- MYPYPATH=./tests/test_examples/test_your_container
7-
8-
# TODO: remove this config after
9-
# mypy/typeshed/stdlib/unittest/mock.pyi:120:
10-
# error: Class cannot subclass "Any" (has type "Any")
11-
# is fixed.
12-
mypy_config:
13-
disallow_subclassing_any = False
4+
- MYPYPATH=./tests/test_examples/test_your_container
5+
mypy_config: disallow_subclassing_any = False
146
main: |
157
# Let's import our `Pair` type we defined earlier:
168
from test_pair4 import Pair
@@ -23,5 +15,5 @@
2315
my_pair: Pair[int, str] = Pair.from_paired(1, 'a')
2416
reveal_type(my_pair.pair(function))
2517
out: |
26-
main:4: note: Revealed type is "def [_FirstType, _SecondType] (inner_value: Tuple[_FirstType`1, _SecondType`2]) -> test_pair4.Pair[_FirstType`1, _SecondType`2]"
27-
main:10: note: Revealed type is "test_pair4.Pair[builtins.float, builtins.bool]"
18+
main:4: note: Revealed type is "Any"
19+
main:10: note: Revealed type is "Any"
Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,8 @@
11
- case: test_pair_map
22
disable_cache: false
33
env:
4-
# We only need this because we store this example in `tests/`
5-
# and not in our source code. Please, do not copy this line!
6-
- MYPYPATH=./tests/test_examples/test_your_container
7-
8-
# TODO: remove this config after
9-
# mypy/typeshed/stdlib/unittest/mock.pyi:120:
10-
# error: Class cannot subclass "Any" (has type "Any")
11-
# is fixed.
12-
mypy_config:
13-
disallow_subclassing_any = False
4+
- MYPYPATH=./tests/test_examples/test_your_container
5+
mypy_config: disallow_subclassing_any = False
146
main: |
157
from test_pair4 import Pair
168
from returns.pointfree import map_
@@ -19,5 +11,5 @@
1911
reveal_type(my_pair.map(str))
2012
reveal_type(map_(str)(my_pair))
2113
out: |
22-
main:5: note: Revealed type is "test_pair4.Pair[builtins.str, builtins.int]"
23-
main:6: note: Revealed type is "test_pair4.Pair[builtins.str, builtins.int]"
14+
main:5: note: Revealed type is "Any"
15+
main:6: note: Revealed type is "Any"

typesafety/test_functions/test_compose.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@
2929
3030
3131
- case: compose_optional_functions
32-
mypy_config:
33-
no_implicit_optional = True
32+
mypy_config: no_implicit_optional = True
3433
main: |
3534
from returns.functions import compose
3635

typesafety/test_future/test_future_container/test_asyncify_decorator.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@
1010
) -> int:
1111
return 1
1212
13-
reveal_type(test) # N: Revealed type is "def (first: builtins.int, second: Union[builtins.str, None] =, *, kw: builtins.bool =) -> typing.Coroutine[Any, Any, builtins.int]"
13+
reveal_type(test) # N: Revealed type is "def (first: builtins.int, second: builtins.str | None =, *, kw: builtins.bool =) -> typing.Coroutine[Any, Any, builtins.int]"

0 commit comments

Comments
 (0)