Skip to content
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

Fix the multiple-statements issue on pypy 3.8 #7945

Merged
merged 3 commits into from
Dec 15, 2022
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
2 changes: 2 additions & 0 deletions tests/functional/a/alternative/alternative_union_syntax.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
"""Test PEP 604 - Alternative Union syntax"""

# pylint: disable=missing-function-docstring,unused-argument,invalid-name,missing-class-docstring
# pylint: disable=inherit-non-class,too-few-public-methods,unnecessary-direct-lambda-call,superfluous-parens

import dataclasses
import typing
from dataclasses import dataclass
Expand Down
14 changes: 11 additions & 3 deletions tests/functional/a/alternative/alternative_union_syntax_error.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
"""Test PEP 604 - Alternative Union syntax
without postponed evaluation of annotations.
"""Test PEP 604 - Alternative Union syntax with postponed evaluation of
annotations enabled.

For Python 3.7 - 3.9: Everything should fail.
Testing only 3.8/3.9 to support TypedDict.
"""
# pylint: disable=missing-function-docstring,unused-argument,invalid-name,missing-class-docstring,inherit-non-class,too-few-public-methods,line-too-long,unnecessary-direct-lambda-call,unnecessary-lambda-assignment

# pylint: disable=missing-function-docstring,unused-argument,invalid-name,missing-class-docstring
# pylint: disable=inherit-non-class,too-few-public-methods,line-too-long,unnecessary-direct-lambda-call
# pylint: disable=unnecessary-lambda-assignment

# Disabled because of a bug with pypy 3.8 see
# https://github.com/PyCQA/pylint/pull/7918#issuecomment-1352737369
# pylint: disable=multiple-statements

import dataclasses
import typing
from dataclasses import dataclass
Expand Down
52 changes: 26 additions & 26 deletions tests/functional/a/alternative/alternative_union_syntax_error.txt
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
unsupported-binary-operation:14:8:14:30::unsupported operand type(s) for |:INFERENCE
unsupported-binary-operation:15:7:15:35::unsupported operand type(s) for |:INFERENCE
unsupported-binary-operation:17:23:17:33::unsupported operand type(s) for |:INFERENCE
unsupported-binary-operation:18:6:18:22::unsupported operand type(s) for |:INFERENCE
unsupported-binary-operation:18:6:18:15::unsupported operand type(s) for |:INFERENCE
unsupported-binary-operation:19:6:19:34::unsupported operand type(s) for |:INFERENCE
unsupported-binary-operation:20:18:20:46::unsupported operand type(s) for |:INFERENCE
unsupported-binary-operation:23:23:23:32::unsupported operand type(s) for |:INFERENCE
unsupported-binary-operation:25:24:25:33::unsupported operand type(s) for |:INFERENCE
unsupported-binary-operation:27:14:27:23::unsupported operand type(s) for |:INFERENCE
unsupported-binary-operation:29:5:29:14::unsupported operand type(s) for |:INFERENCE
unsupported-binary-operation:31:14:31:23:func:unsupported operand type(s) for |:INFERENCE
unsupported-binary-operation:34:15:34:24:func2:unsupported operand type(s) for |:INFERENCE
unsupported-binary-operation:40:9:40:25::unsupported operand type(s) for |:INFERENCE
unsupported-binary-operation:47:36:47:45::unsupported operand type(s) for |:INFERENCE
unsupported-binary-operation:50:12:50:21:CustomNamedTuple2:unsupported operand type(s) for |:INFERENCE
unsupported-binary-operation:53:12:53:21:CustomNamedTuple3:unsupported operand type(s) for |:INFERENCE
unsupported-binary-operation:57:54:57:63::unsupported operand type(s) for |:INFERENCE
unsupported-binary-operation:59:60:59:69::unsupported operand type(s) for |:INFERENCE
unsupported-binary-operation:62:12:62:21:CustomTypedDict3:unsupported operand type(s) for |:INFERENCE
unsupported-binary-operation:65:12:65:21:CustomTypedDict4:unsupported operand type(s) for |:INFERENCE
unsupported-binary-operation:76:12:76:21:CustomDataClass:unsupported operand type(s) for |:INFERENCE
unsupported-binary-operation:80:12:80:21:CustomDataClass2:unsupported operand type(s) for |:INFERENCE
unsupported-binary-operation:84:12:84:21:CustomDataClass3:unsupported operand type(s) for |:INFERENCE
unsupported-binary-operation:89:12:89:21:CustomDataClass4:unsupported operand type(s) for |:INFERENCE
unsupported-binary-operation:111:31:111:61::unsupported operand type(s) for |:INFERENCE
unsupported-binary-operation:22:8:22:30::unsupported operand type(s) for |:INFERENCE
unsupported-binary-operation:23:7:23:35::unsupported operand type(s) for |:INFERENCE
unsupported-binary-operation:25:23:25:33::unsupported operand type(s) for |:INFERENCE
unsupported-binary-operation:26:6:26:22::unsupported operand type(s) for |:INFERENCE
unsupported-binary-operation:26:6:26:15::unsupported operand type(s) for |:INFERENCE
unsupported-binary-operation:27:6:27:34::unsupported operand type(s) for |:INFERENCE
unsupported-binary-operation:28:18:28:46::unsupported operand type(s) for |:INFERENCE
unsupported-binary-operation:31:23:31:32::unsupported operand type(s) for |:INFERENCE
unsupported-binary-operation:33:24:33:33::unsupported operand type(s) for |:INFERENCE
unsupported-binary-operation:35:14:35:23::unsupported operand type(s) for |:INFERENCE
unsupported-binary-operation:37:5:37:14::unsupported operand type(s) for |:INFERENCE
unsupported-binary-operation:39:14:39:23:func:unsupported operand type(s) for |:INFERENCE
unsupported-binary-operation:42:15:42:24:func2:unsupported operand type(s) for |:INFERENCE
unsupported-binary-operation:48:9:48:25::unsupported operand type(s) for |:INFERENCE
unsupported-binary-operation:55:36:55:45::unsupported operand type(s) for |:INFERENCE
unsupported-binary-operation:58:12:58:21:CustomNamedTuple2:unsupported operand type(s) for |:INFERENCE
unsupported-binary-operation:61:12:61:21:CustomNamedTuple3:unsupported operand type(s) for |:INFERENCE
unsupported-binary-operation:65:54:65:63::unsupported operand type(s) for |:INFERENCE
unsupported-binary-operation:67:60:67:69::unsupported operand type(s) for |:INFERENCE
unsupported-binary-operation:70:12:70:21:CustomTypedDict3:unsupported operand type(s) for |:INFERENCE
unsupported-binary-operation:73:12:73:21:CustomTypedDict4:unsupported operand type(s) for |:INFERENCE
unsupported-binary-operation:84:12:84:21:CustomDataClass:unsupported operand type(s) for |:INFERENCE
unsupported-binary-operation:88:12:88:21:CustomDataClass2:unsupported operand type(s) for |:INFERENCE
unsupported-binary-operation:92:12:92:21:CustomDataClass3:unsupported operand type(s) for |:INFERENCE
unsupported-binary-operation:97:12:97:21:CustomDataClass4:unsupported operand type(s) for |:INFERENCE
unsupported-binary-operation:119:31:119:61::unsupported operand type(s) for |:INFERENCE
13 changes: 10 additions & 3 deletions tests/functional/a/alternative/alternative_union_syntax_py37.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
"""Test PEP 604 - Alternative Union syntax
with postponed evaluation of annotations enabled.
"""Test PEP 604 - Alternative Union syntax with postponed evaluation of
annotations enabled.

For Python 3.7 - 3.9: Most things should work.
Testing only 3.8/3.9 to support TypedDict.
"""
# pylint: disable=missing-function-docstring,unused-argument,invalid-name,missing-class-docstring,inherit-non-class,too-few-public-methods,line-too-long,unnecessary-direct-lambda-call

# pylint: disable=missing-function-docstring,unused-argument,invalid-name,missing-class-docstring
# pylint: disable=inherit-non-class,too-few-public-methods,line-too-long,unnecessary-direct-lambda-call

# Disabled because of a bug with pypy 3.8 see
# https://github.com/PyCQA/pylint/pull/7918#issuecomment-1352737369
# pylint: disable=multiple-statements

from __future__ import annotations
import dataclasses
import typing
Expand Down
18 changes: 9 additions & 9 deletions tests/functional/a/alternative/alternative_union_syntax_py37.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
unsupported-binary-operation:15:8:15:30::unsupported operand type(s) for |:INFERENCE
unsupported-binary-operation:16:7:16:35::unsupported operand type(s) for |:INFERENCE
unsupported-binary-operation:24:23:24:32::unsupported operand type(s) for |:INFERENCE
unsupported-binary-operation:26:24:26:33::unsupported operand type(s) for |:INFERENCE
unsupported-binary-operation:28:14:28:23::unsupported operand type(s) for |:INFERENCE
unsupported-binary-operation:41:9:41:25::unsupported operand type(s) for |:INFERENCE
unsupported-binary-operation:48:36:48:45::unsupported operand type(s) for |:INFERENCE
unsupported-binary-operation:58:54:58:63::unsupported operand type(s) for |:INFERENCE
unsupported-binary-operation:60:60:60:69::unsupported operand type(s) for |:INFERENCE
unsupported-binary-operation:22:8:22:30::unsupported operand type(s) for |:INFERENCE
unsupported-binary-operation:23:7:23:35::unsupported operand type(s) for |:INFERENCE
unsupported-binary-operation:31:23:31:32::unsupported operand type(s) for |:INFERENCE
unsupported-binary-operation:33:24:33:33::unsupported operand type(s) for |:INFERENCE
unsupported-binary-operation:35:14:35:23::unsupported operand type(s) for |:INFERENCE
unsupported-binary-operation:48:9:48:25::unsupported operand type(s) for |:INFERENCE
unsupported-binary-operation:55:36:55:45::unsupported operand type(s) for |:INFERENCE
unsupported-binary-operation:65:54:65:63::unsupported operand type(s) for |:INFERENCE
unsupported-binary-operation:67:60:67:69::unsupported operand type(s) for |:INFERENCE
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@

Tests for regressions from https://github.com/PyCQA/astroid/pull/1126
"""

# pylint: disable=missing-docstring,too-few-public-methods,pointless-statement,redefined-builtin, fixme

# Disabled because of a bug with pypy 3.8 see
# https://github.com/PyCQA/pylint/pull/7918#issuecomment-1352737369
# pylint: disable=multiple-statements

from dataclasses import dataclass
from typing import Callable, Dict, List, Optional

Expand Down
12 changes: 12 additions & 0 deletions tests/functional/d/dataclass/dataclass_typecheck.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
invalid-sequence-index:38:6:38:20::Sequence index is not an int, slice, or instance with __index__:UNDEFINED
invalid-slice-index:42:10:42:19::Slice index is not an int, None, or instance with __index__:UNDEFINED
not-callable:45:0:45:14::obj.attr1 is not callable:UNDEFINED
invalid-unary-operand-type:50:6:50:16::"bad operand type for unary -: str":UNDEFINED
unsupported-membership-test:57:11:57:20::Value 'obj.attr1' doesn't support membership test:UNDEFINED
unsubscriptable-object:62:6:62:15::Value 'obj.attr1' is unsubscriptable:UNDEFINED
unsupported-assignment-operation:67:0:67:9::'obj.attr1' does not support item assignment:UNDEFINED
unsupported-delete-operation:72:4:72:13::'obj.attr1' does not support item deletion:UNDEFINED
not-context-manager:97:0:98:8::Context manager 'str' doesn't implement __enter__ and __exit__.:UNDEFINED
invalid-metaclass:105:0:105:11:Test2:Invalid metaclass 'Instance of builtins.int' used:UNDEFINED
unhashable-member:111:0:111:2::'obj.attr5' is unhashable and can't be used as a key in a dict:INFERENCE
isinstance-second-argument-not-valid-type:121:6:121:30::Second argument of isinstance is not a type:UNDEFINED
12 changes: 0 additions & 12 deletions tests/functional/d/dataclass_typecheck.txt

This file was deleted.

6 changes: 6 additions & 0 deletions tests/functional/ext/typing/typing_consider_using_alias.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,13 @@
'py-version' needs to be set to '3.7' or '3.8' and 'runtime-typing=no'.
With 'from __future__ import annotations' present.
"""

# pylint: disable=missing-docstring,invalid-name,unused-argument,line-too-long,unnecessary-direct-lambda-call

# Disabled because of a bug with pypy 3.8 see
# https://github.com/PyCQA/pylint/pull/7918#issuecomment-1352737369
# pylint: disable=multiple-statements

from __future__ import annotations

import collections
Expand Down
40 changes: 20 additions & 20 deletions tests/functional/ext/typing/typing_consider_using_alias.txt
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
consider-using-alias:16:6:16:17::'typing.Dict' will be deprecated with PY39, consider using 'dict' instead:INFERENCE
consider-using-alias:17:6:17:10::'typing.List' will be deprecated with PY39, consider using 'list' instead:INFERENCE
consider-using-alias:19:6:19:24::'typing.OrderedDict' will be deprecated with PY39, consider using 'collections.OrderedDict' instead:INFERENCE
consider-using-alias:20:6:20:22::'typing.Awaitable' will be deprecated with PY39, consider using 'collections.abc.Awaitable' instead:INFERENCE
consider-using-alias:21:6:21:21::'typing.Iterable' will be deprecated with PY39, consider using 'collections.abc.Iterable' instead:INFERENCE
consider-using-alias:22:6:22:21::'typing.Hashable' will be deprecated with PY39, consider using 'collections.abc.Hashable' instead:INFERENCE
consider-using-alias:23:6:23:27::'typing.ContextManager' will be deprecated with PY39, consider using 'contextlib.AbstractContextManager' instead:INFERENCE
consider-using-alias:24:6:24:20::'typing.Pattern' will be deprecated with PY39, consider using 're.Pattern' instead:INFERENCE
consider-using-alias:25:7:25:22::'typing.Match' will be deprecated with PY39, consider using 're.Match' instead:INFERENCE
consider-using-alias:34:9:34:13::'typing.List' will be deprecated with PY39, consider using 'list' instead:INFERENCE
consider-using-alias:36:7:36:11::'typing.Type' will be deprecated with PY39, consider using 'type' instead:INFERENCE
consider-using-alias:37:7:37:12::'typing.Tuple' will be deprecated with PY39, consider using 'tuple' instead:INFERENCE
consider-using-alias:38:7:38:15::'typing.Callable' will be deprecated with PY39, consider using 'collections.abc.Callable' instead:INFERENCE
consider-using-alias:44:74:44:78:func1:'typing.Dict' will be deprecated with PY39, consider using 'dict' instead:INFERENCE
consider-using-alias:44:16:44:20:func1:'typing.List' will be deprecated with PY39, consider using 'list' instead:INFERENCE
consider-using-alias:44:37:44:41:func1:'typing.List' will be deprecated with PY39, consider using 'list' instead:INFERENCE
consider-using-alias:44:93:44:105:func1:'typing.Tuple' will be deprecated with PY39, consider using 'tuple' instead:INFERENCE
consider-using-alias:60:12:60:16:CustomNamedTuple:'typing.List' will be deprecated with PY39, consider using 'list' instead:INFERENCE
consider-using-alias:65:12:65:16:CustomTypedDict2:'typing.List' will be deprecated with PY39, consider using 'list' instead:INFERENCE
consider-using-alias:69:12:69:16:CustomDataClass:'typing.List' will be deprecated with PY39, consider using 'list' instead:INFERENCE
consider-using-alias:22:6:22:17::'typing.Dict' will be deprecated with PY39, consider using 'dict' instead:INFERENCE
consider-using-alias:23:6:23:10::'typing.List' will be deprecated with PY39, consider using 'list' instead:INFERENCE
consider-using-alias:25:6:25:24::'typing.OrderedDict' will be deprecated with PY39, consider using 'collections.OrderedDict' instead:INFERENCE
consider-using-alias:26:6:26:22::'typing.Awaitable' will be deprecated with PY39, consider using 'collections.abc.Awaitable' instead:INFERENCE
consider-using-alias:27:6:27:21::'typing.Iterable' will be deprecated with PY39, consider using 'collections.abc.Iterable' instead:INFERENCE
consider-using-alias:28:6:28:21::'typing.Hashable' will be deprecated with PY39, consider using 'collections.abc.Hashable' instead:INFERENCE
consider-using-alias:29:6:29:27::'typing.ContextManager' will be deprecated with PY39, consider using 'contextlib.AbstractContextManager' instead:INFERENCE
consider-using-alias:30:6:30:20::'typing.Pattern' will be deprecated with PY39, consider using 're.Pattern' instead:INFERENCE
consider-using-alias:31:7:31:22::'typing.Match' will be deprecated with PY39, consider using 're.Match' instead:INFERENCE
consider-using-alias:40:9:40:13::'typing.List' will be deprecated with PY39, consider using 'list' instead:INFERENCE
consider-using-alias:42:7:42:11::'typing.Type' will be deprecated with PY39, consider using 'type' instead:INFERENCE
consider-using-alias:43:7:43:12::'typing.Tuple' will be deprecated with PY39, consider using 'tuple' instead:INFERENCE
consider-using-alias:44:7:44:15::'typing.Callable' will be deprecated with PY39, consider using 'collections.abc.Callable' instead:INFERENCE
consider-using-alias:50:74:50:78:func1:'typing.Dict' will be deprecated with PY39, consider using 'dict' instead:INFERENCE
consider-using-alias:50:16:50:20:func1:'typing.List' will be deprecated with PY39, consider using 'list' instead:INFERENCE
consider-using-alias:50:37:50:41:func1:'typing.List' will be deprecated with PY39, consider using 'list' instead:INFERENCE
consider-using-alias:50:93:50:105:func1:'typing.Tuple' will be deprecated with PY39, consider using 'tuple' instead:INFERENCE
consider-using-alias:66:12:66:16:CustomNamedTuple:'typing.List' will be deprecated with PY39, consider using 'list' instead:INFERENCE
consider-using-alias:71:12:71:16:CustomTypedDict2:'typing.List' will be deprecated with PY39, consider using 'list' instead:INFERENCE
consider-using-alias:75:12:75:16:CustomDataClass:'typing.List' will be deprecated with PY39, consider using 'list' instead:INFERENCE
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,14 @@

'py-version' needs to be set to '3.7' or '3.8' and 'runtime-typing=no'.
"""
# pylint: disable=missing-docstring,invalid-name,unused-argument,line-too-long,unsubscriptable-object,unnecessary-direct-lambda-call

# pylint: disable=missing-docstring,invalid-name,unused-argument,line-too-long,unsubscriptable-object
# pylint: disable=unnecessary-direct-lambda-call

# Disabled because of a bug with pypy 3.8 see
# https://github.com/PyCQA/pylint/pull/7918#issuecomment-1352737369
# pylint: disable=multiple-statements

import collections
import collections.abc
import typing
Expand Down
Loading