Type annotation fix + subsequent pyupgrade, autoflake

This commit is contained in:
Isaac Virshup 2023-07-18 11:59:20 +02:00
parent d4c62de2dd
commit 5c29a82738
1 changed files with 6 additions and 7 deletions

View File

@ -1,3 +1,5 @@
from __future__ import annotations
import importlib import importlib
import io import io
import operator import operator
@ -7,10 +9,7 @@ import sys
import textwrap import textwrap
from pathlib import Path from pathlib import Path
from typing import Any from typing import Any
from typing import Dict
from typing import Tuple
from typing import TYPE_CHECKING from typing import TYPE_CHECKING
from typing import Union
import _pytest._code import _pytest._code
import pytest import pytest
@ -802,7 +801,7 @@ raise ValueError()
) )
excinfo = pytest.raises(ValueError, mod.entry) excinfo = pytest.raises(ValueError, mod.entry)
styles: Tuple[_TracebackStyle, ...] = ("long", "short") styles: tuple[_TracebackStyle, ...] = ("long", "short")
for style in styles: for style in styles:
p = FormattedExcinfo(style=style) p = FormattedExcinfo(style=style)
reprtb = p.repr_traceback(excinfo) reprtb = p.repr_traceback(excinfo)
@ -929,7 +928,7 @@ raise ValueError()
) )
excinfo = pytest.raises(ValueError, mod.entry) excinfo = pytest.raises(ValueError, mod.entry)
styles: Tuple[_TracebackStyle, ...] = ("short", "long", "no") styles: tuple[_TracebackStyle, ...] = ("short", "long", "no")
for style in styles: for style in styles:
for showlocals in (True, False): for showlocals in (True, False):
repr = excinfo.getrepr(style=style, showlocals=showlocals) repr = excinfo.getrepr(style=style, showlocals=showlocals)
@ -1091,7 +1090,7 @@ raise ValueError()
for funcargs in (True, False) for funcargs in (True, False)
], ],
) )
def test_format_excinfo(self, reproptions: Dict[str, Any]) -> None: def test_format_excinfo(self, reproptions: dict[str, Any]) -> None:
def bar(): def bar():
assert False, "some error" assert False, "some error"
@ -1399,7 +1398,7 @@ raise ValueError()
@pytest.mark.parametrize("encoding", [None, "utf8", "utf16"]) @pytest.mark.parametrize("encoding", [None, "utf8", "utf16"])
def test_repr_traceback_with_unicode(style, encoding): def test_repr_traceback_with_unicode(style, encoding):
if encoding is None: if encoding is None:
msg: Union[str, bytes] = "" msg: str | bytes = ""
else: else:
msg = "".encode(encoding) msg = "".encode(encoding)
try: try: