Skip to content

Commit

Permalink
Run pyupgrade --py39-plus on all files
Browse files Browse the repository at this point in the history
  • Loading branch information
nicoddemus committed Dec 12, 2024
1 parent 8f7afd4 commit d5e398b
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 19 deletions.
3 changes: 1 addition & 2 deletions src/pytest_rich/capture.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
from datetime import datetime
from datetime import timezone
from pathlib import Path
from typing import Tuple

from rich.console import Console

Expand All @@ -28,7 +27,7 @@ def save_terminal_output(console: Console, arg: str) -> None:
save_func(f"{filename}.{filetype}")


def _get_filename_from_arg(arg: str) -> Tuple[str, str]:
def _get_filename_from_arg(arg: str) -> tuple[str, str]:
"""
Get filename from command line argument.
Expand Down
2 changes: 1 addition & 1 deletion src/pytest_rich/header.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import sys
from typing import Iterable
from collections.abc import Iterable
from typing import Union

import pytest
Expand Down
17 changes: 7 additions & 10 deletions src/pytest_rich/terminal.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
import warnings
from collections import defaultdict
from collections.abc import Sequence
from pathlib import Path
from typing import Dict
from typing import List
from typing import Literal
from typing import Optional
from typing import Sequence
from typing import Tuple
from typing import Union

import attr
Expand Down Expand Up @@ -43,11 +40,11 @@ def __attrs_post_init__(self):
self.runtest_progress: Optional[Progress] = None
self.total_items_collected = 0
self.total_items_completed = 0
self.items_per_file: Dict[Path, List[pytest.Item]] = {}
self.status_per_item: Dict[str, RichTerminalReporter.Status] = {}
self.items: Dict[str, pytest.Item] = {}
self.runtest_tasks_per_file: Dict[Path, TaskID] = {}
self.categorized_reports: Dict[str, List[pytest.TestReport]] = defaultdict(list)
self.items_per_file: dict[Path, list[pytest.Item]] = {}
self.status_per_item: dict[str, RichTerminalReporter.Status] = {}
self.items: dict[str, pytest.Item] = {}
self.runtest_tasks_per_file: dict[Path, TaskID] = {}
self.categorized_reports: dict[str, list[pytest.TestReport]] = defaultdict(list)
self.summary: Optional[Live] = None
self.total_duration: float = 0
self.console.record = self.config.getoption("rich_capture") is not None
Expand Down Expand Up @@ -109,7 +106,7 @@ def pytest_deselected(self, items: Sequence[pytest.Item]) -> None: ...
def pytest_plugin_registered(self, plugin) -> None: ...

def pytest_runtest_logstart(
self, nodeid: str, location: Tuple[str, Optional[int], str]
self, nodeid: str, location: tuple[str, Optional[int], str]
) -> None:
if self.runtest_progress is None:
self.runtest_progress = Progress(SpinnerColumn(), "{task.description}")
Expand Down
9 changes: 3 additions & 6 deletions src/pytest_rich/traceback.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import ast
from typing import Dict
from collections.abc import Sequence
from typing import Optional
from typing import Sequence

import attr
from _pytest._code.code import ExceptionChainRepr
Expand Down Expand Up @@ -114,7 +113,7 @@ def _render_chain(
path_highlighter = PathHighlighter()
repr_highlighter = ReprHighlighter()
theme = self.get_theme()
code_cache: Dict[str, str] = {}
code_cache: dict[str, str] = {}

def read_code(filename: str) -> str:
"""
Expand All @@ -128,9 +127,7 @@ def read_code(filename: str) -> str:
"""
code = code_cache.get(filename)
if not code:
with open(
filename, "rt", encoding="utf-8", errors="replace"
) as code_file:
with open(filename, encoding="utf-8", errors="replace") as code_file:
code = code_file.read()
code_cache[filename] = code
return code
Expand Down

0 comments on commit d5e398b

Please sign in to comment.