Skip to content

Update mypy to 1.4.1 #1658

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

Merged
merged 6 commits into from
Jun 27, 2023
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
1 change: 1 addition & 0 deletions docs/pages/contrib/mypy_plugins.rst
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ Supported features
with ``flow`` function
- ``pipe`` feature allows to write better typed functional pipelines
with ``pipe`` function
- ``do-notation`` feature allows using :ref:`do-notation`


Further reading
Expand Down
58 changes: 29 additions & 29 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ trio = "^0.22"
attrs = "^23.1"
httpx = "^0.24"

mypy = "==1.3.0"
mypy = "^1.4"
wemake-python-styleguide = "^0.17"
flake8-pytest-style = "^1.6"
flake8-pyi = "^23.4"
Expand Down
2 changes: 1 addition & 1 deletion returns/contrib/mypy/_typeops/inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def _infer_constraints(
[arg.name for arg in applied_args],
self._fallback.arg_kinds,
self._fallback.arg_names,
lambda index: checker.accept(exprs[index]), # type: ignore
lambda index: checker.accept(exprs[index]),
)
constraints = infer_constraints_for_callable(
self._fallback,
Expand Down
5 changes: 3 additions & 2 deletions returns/contrib/mypy/_typeops/transform_callable.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

from mypy.nodes import ARG_OPT, ARG_POS, ARG_STAR, ARG_STAR2, ArgKind
from mypy.typeops import get_type_vars
from mypy.types import CallableType, FunctionLike, Overloaded
from mypy.types import AnyType, CallableType, FunctionLike, Overloaded
from mypy.types import Type as MypyType
from mypy.types import TypeVarType
from mypy.types import TypeOfAny, TypeVarType
from typing_extensions import final

from returns.contrib.mypy._structures.args import FuncArg
Expand Down Expand Up @@ -183,6 +183,7 @@ def detach_callable(typ: CallableType) -> CallableType: # noqa: C901, WPS210
values=var.values,
upper_bound=var.upper_bound,
variance=var.variance,
default=AnyType(TypeOfAny.from_omitted_generics),
),
)

Expand Down
4 changes: 4 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,10 @@ warn_return_any = True
warn_unused_configs = True
warn_unreachable = True

# TODO: update our output assertions to match a new syntax
force_uppercase_builtins = true
force_union_syntax = true

# We need this to debug `mypy` plugin:
show_traceback = True

Expand Down
4 changes: 2 additions & 2 deletions tests/test_result/test_result_equality.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ def test_is_compare():
left = Failure(1)
right = Success(1)

assert left.bind(lambda state: state) is left # type: ignore
assert right.lash(lambda state: state) is right # type: ignore
assert left.bind(lambda state: state) is left
assert right.lash(lambda state: state) is right
assert right is not Success(1)


Expand Down
45 changes: 8 additions & 37 deletions typesafety/test_pointfree/test_modify_env2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,29 +42,19 @@

- case: modify_env2_requires_context
disable_cache: false
skip: sys.version_info[:2] < (3, 8)
main: |
from returns.pointfree import modify_env2
from returns.context import RequiresContext

x: RequiresContext[float, int]
reveal_type(modify_env2(int)(x)) # N: Revealed type is "returns.context.requires_context.RequiresContext[builtins.float, Union[builtins.str, builtins.bytes, builtins.bytearray, builtins.memoryview, array.array[Any], mmap.mmap, ctypes._CData, pickle.PickleBuffer, typing.SupportsInt, typing_extensions.SupportsIndex, _typeshed.SupportsTrunc]]"
class A: ...
def mod(arg: A) -> bool: ...


- case: modify_env2_requires_context_py37
disable_cache: false
skip: sys.version_info[:2] >= (3, 8)
main: |
from returns.pointfree import modify_env2
from returns.context import RequiresContext

x: RequiresContext[float, int]
reveal_type(modify_env2(int)(x)) # N: Revealed type is "returns.context.requires_context.RequiresContext[builtins.float, Union[builtins.str, builtins.bytes, builtins.bytearray, builtins.memoryview, array.array[Any], mmap.mmap, ctypes._CData, typing.SupportsInt, typing_extensions.SupportsIndex, _typeshed.SupportsTrunc]]"
x: RequiresContext[float, bool]
reveal_type(modify_env2(mod)(x)) # N: Revealed type is "returns.context.requires_context.RequiresContext[builtins.float, main.A]"


- case: modify_env2_custom_type
disable_cache: false
skip: sys.version_info[:2] < (3, 8)
main: |
from typing import TypeVar
from returns.interfaces.specific.reader import ReaderBased2
Expand All @@ -80,27 +70,8 @@
):
...

x: MyClass[float, int]
reveal_type(modify_env2(int)(x)) # N: Revealed type is "main.MyClass[builtins.float, Union[builtins.str, builtins.bytes, builtins.bytearray, builtins.memoryview, array.array[Any], mmap.mmap, ctypes._CData, pickle.PickleBuffer, typing.SupportsInt, typing_extensions.SupportsIndex, _typeshed.SupportsTrunc]]"


- case: modify_env2_custom_type_py37
disable_cache: false
skip: sys.version_info[:2] >= (3, 8)
main: |
from typing import TypeVar
from returns.interfaces.specific.reader import ReaderBased2
from returns.primitives.hkt import SupportsKind2
from returns.pointfree import modify_env2

_EnvType = TypeVar('_EnvType')
_ReturnType = TypeVar('_ReturnType')

class MyClass(
SupportsKind2['MyClass', _ReturnType, _EnvType],
ReaderBased2[_ReturnType, _EnvType],
):
...
class A: ...
def mod(arg: A) -> bool: ...

x: MyClass[float, int]
reveal_type(modify_env2(int)(x)) # N: Revealed type is "main.MyClass[builtins.float, Union[builtins.str, builtins.bytes, builtins.bytearray, builtins.memoryview, array.array[Any], mmap.mmap, ctypes._CData, typing.SupportsInt, typing_extensions.SupportsIndex, _typeshed.SupportsTrunc]]"
x: MyClass[float, bool]
reveal_type(modify_env2(mod)(x)) # N: Revealed type is "main.MyClass[builtins.float, main.A]"