Open kloczek opened 4 days ago
Pyton 3.8 just has been EOSed month ago (https://endoflife.date/python) so I've been trying to use pyupgrade --py39-plus to check is current code ready to automatic upgrade. Looks like it is not ready to be automatically updated because it uses (upper case) List, Tuple. Please have look on https://flycoolman.com/coding/python/list-tuple-dict-vs-list-tuple-dict/
With that patch pytest fails with
Copied here patch has been generated after apply https://github.com/alexmojaki/pure_eval/pull/22
Pyton 3.8 just has been EOSed month ago (https://endoflife.date/python) so I've been trying to use pyupgrade --py39-plus to check is current code ready to automatic upgrade. Looks like it is not ready to be automatically updated because it uses (upper case) List, Tuple. Please have look on https://flycoolman.com/coding/python/list-tuple-dict-vs-list-tuple-dict/
Here is the patch generated by `pypgrade --py39-plus`
```patch --- a/pure_eval/core.py +++ b/pure_eval/core.py @@ -4,7 +4,8 @@ from collections import ChainMap, OrderedDict, deque from contextlib import suppress from types import FrameType -from typing import Any, Tuple, Iterable, List, Mapping, Dict, Union, Set +from typing import Any, Tuple, List, Dict, Union, Set +from collections.abc import Iterable, Mapping from pure_eval.my_getattr_static import getattr_static from pure_eval.utils import ( @@ -308,7 +309,7 @@ def _handle_container( self, node: Union[ast.List, ast.Tuple, ast.Set, ast.Dict] - ) -> Union[List, Tuple, Set, Dict]: + ) -> Union[list, tuple, set, dict]: """Handle container nodes, including List, Set, Tuple and Dict""" if isinstance(node, ast.Dict): elts = node.keys @@ -342,7 +343,7 @@ except TypeError: raise CannotEval - def find_expressions(self, root: ast.AST) -> Iterable[Tuple[ast.expr, Any]]: + def find_expressions(self, root: ast.AST) -> Iterable[tuple[ast.expr, Any]]: """ Find all expressions in the given tree that can be safely evaluated. This is a low level API, typically you will use `interesting_expressions_grouped`. @@ -362,7 +363,7 @@ yield node, value - def interesting_expressions_grouped(self, root: ast.AST) -> List[Tuple[List[ast.expr], Any]]: + def interesting_expressions_grouped(self, root: ast.AST) -> list[tuple[list[ast.expr], Any]]: """ Find all interesting expressions in the given tree that can be safely evaluated, grouping equivalent nodes together. @@ -422,7 +423,7 @@ return True -def group_expressions(expressions: Iterable[Tuple[ast.expr, Any]]) -> List[Tuple[List[ast.expr], Any]]: +def group_expressions(expressions: Iterable[tuple[ast.expr, Any]]) -> list[tuple[list[ast.expr], Any]]: """ Organise expression nodes and their values such that equivalent nodes are together. Two nodes are considered equivalent if they have the same structure, --- a/tests/test_core.py +++ b/tests/test_core.py @@ -73,7 +73,7 @@ foo, Foo, Foo.method, foo.method ) - check_eval("typing.List", typing, typing.List) + check_eval("typing.List", typing, list) def test_eval_dict(): @@ -445,10 +445,7 @@ def subscript_item(node): - if sys.version_info < (3, 9): - return node.slice.value - else: - return node.slice + return node.slice def test_evaluator_wrong_getitem(): --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -91,7 +91,7 @@ def test_safe_name_direct(): assert safe_name(list) == "list" - assert safe_name(typing.List) == "List" + assert safe_name(list) == "List" assert safe_name(typing.Union) == "Union" assert safe_name(typing.Optional) == "Optional" assert safe_name(3) is None ```With that patch pytest fails with