Skip to content

Commit d1a7029

Browse files
committed
chore: pyupgrade --py39-plus
1 parent 74597af commit d1a7029

File tree

13 files changed

+38
-33
lines changed

13 files changed

+38
-33
lines changed

src/scriv/config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,7 @@ def read_file_value(self, file_name: str) -> str:
434434
return value
435435

436436

437-
def convert_list(val: str) -> List[str]:
437+
def convert_list(val: str) -> list[str]:
438438
"""
439439
Convert a string value from a config into a list of strings.
440440

src/scriv/format.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
# When collecting changelog fragments, we group them by their category into
99
# Sections. A SectionDict maps category names to a list of the paragraphs in
1010
# that section. For projects not using categories, the key will be None.
11-
SectionDict = Dict[Optional[str], List[str]]
11+
SectionDict = dict[Optional[str], list[str]]
1212

1313

1414
class FormatTools(abc.ABC):

src/scriv/github.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22

33
import logging
44
import os
5-
from typing import Any, Dict, Iterable
5+
from typing import Any, Dict
6+
from collections.abc import Iterable
67

78
import requests
89

@@ -24,7 +25,7 @@ def check_ok(resp):
2425
resp.raise_for_status()
2526

2627

27-
def auth_headers() -> Dict[str, str]:
28+
def auth_headers() -> dict[str, str]:
2829
"""
2930
Get the authorization headers needed for GitHub.
3031
@@ -37,7 +38,7 @@ def auth_headers() -> Dict[str, str]:
3738
return headers
3839

3940

40-
def github_paginated(url: str) -> Iterable[Dict[str, Any]]:
41+
def github_paginated(url: str) -> Iterable[dict[str, Any]]:
4142
"""
4243
Get all the results from a paginated GitHub url.
4344
"""
@@ -54,7 +55,7 @@ def github_paginated(url: str) -> Iterable[Dict[str, Any]]:
5455
RELEASES_URL = "https://api.github.com/repos/{repo}/releases"
5556

5657

57-
def get_releases(repo: str) -> Dict[str, Dict[str, Any]]:
58+
def get_releases(repo: str) -> dict[str, dict[str, Any]]:
5859
"""
5960
Get all the releases from a name/project repo.
6061
@@ -66,7 +67,7 @@ def get_releases(repo: str) -> Dict[str, Dict[str, Any]]:
6667
return releases
6768

6869

69-
def create_release(repo: str, release_data: Dict[str, Any]) -> None:
70+
def create_release(repo: str, release_data: dict[str, Any]) -> None:
7071
"""
7172
Create a GitHub release.
7273
@@ -89,7 +90,7 @@ def create_release(repo: str, release_data: Dict[str, Any]) -> None:
8990

9091

9192
def update_release(
92-
release: Dict[str, Any], release_data: Dict[str, Any]
93+
release: dict[str, Any], release_data: dict[str, Any]
9394
) -> None:
9495
"""
9596
Update a GitHub release.

src/scriv/gitinfo.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ def git_rm(filename: Path) -> None:
8282
sys.exit(ret)
8383

8484

85-
def get_github_repos() -> Set[str]:
85+
def get_github_repos() -> set[str]:
8686
"""
8787
Find the GitHub name/repos for this project.
8888

src/scriv/linkcheck.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import concurrent.futures
44
import logging
5-
from typing import Iterable
5+
from collections.abc import Iterable
66

77
import markdown_it
88
import requests

src/scriv/literals.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
import ast
66
import configparser
77
import os.path
8-
from typing import Any, MutableMapping, Optional
8+
from typing import Any, Optional
9+
from collections.abc import MutableMapping
910

1011
from .exceptions import ScrivException
1112
from .optional import tomllib, yaml

src/scriv/scriv.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
import re
77
import textwrap
88
from pathlib import Path
9-
from typing import Iterable, List, Optional
9+
from typing import List, Optional
10+
from collections.abc import Iterable
1011

1112
import jinja2
1213

@@ -37,7 +38,7 @@ def new_fragment(self) -> Fragment:
3738
content=_new_fragment_content(self.config),
3839
)
3940

40-
def fragments_to_combine(self) -> List[Fragment]:
41+
def fragments_to_combine(self) -> list[Fragment]:
4142
"""Get the list of fragments to combine."""
4243
return [Fragment(path=path) for path in _files_to_combine(self.config)]
4344

@@ -94,7 +95,7 @@ def _new_fragment_content(config: Config) -> str:
9495
).render(config=config)
9596

9697

97-
def _files_to_combine(config: Config) -> List[Path]:
98+
def _files_to_combine(config: Config) -> list[Path]:
9899
"""
99100
Find all the fragment file paths to be combined.
100101

src/scriv/shell.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@
66
from typing import List, Tuple, Union
77

88
# The return value of run_command.
9-
CmdResult = Tuple[bool, str]
9+
CmdResult = tuple[bool, str]
1010

1111
logger = logging.getLogger(__name__)
1212

1313

14-
def run_command(cmd: Union[str, List[str]]) -> CmdResult:
14+
def run_command(cmd: Union[str, list[str]]) -> CmdResult:
1515
"""
1616
Run a command line (with no shell).
1717
@@ -38,7 +38,7 @@ def run_command(cmd: Union[str, List[str]]) -> CmdResult:
3838
return proc.returncode == 0, output
3939

4040

41-
def run_simple_command(cmd: Union[str, List[str]]) -> str:
41+
def run_simple_command(cmd: Union[str, list[str]]) -> str:
4242
"""
4343
Run a command and return its output, or "" if it fails.
4444
"""

src/scriv/util.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
import logging
88
import re
99
import sys
10-
from typing import Dict, Optional, Sequence, Tuple, TypeVar
10+
from typing import Dict, Optional, Tuple, TypeVar
11+
from collections.abc import Sequence
1112

1213
import click_log
1314

@@ -18,8 +19,8 @@
1819

1920

2021
def order_dict(
21-
d: Dict[Optional[K], T], keys: Sequence[Optional[K]]
22-
) -> Dict[Optional[K], T]:
22+
d: dict[K | None, T], keys: Sequence[K | None]
23+
) -> dict[K | None, T]:
2324
"""
2425
Produce an OrderedDict of `d`, but with the keys in `keys` order.
2526
@@ -40,7 +41,7 @@ def order_dict(
4041
return with_order
4142

4243

43-
def partition_lines(text: str, marker: str) -> Tuple[str, str, str]:
44+
def partition_lines(text: str, marker: str) -> tuple[str, str, str]:
4445
"""
4546
Split `text` by lines, similar to str.partition.
4647
@@ -102,7 +103,7 @@ def __hash__(self):
102103
return hash(self.vtext.lstrip("v"))
103104

104105
@classmethod
105-
def from_text(cls, text: str) -> Optional[Version]:
106+
def from_text(cls, text: str) -> Version | None:
106107
"""Find a version number in a text string."""
107108
m = re.search(VERSION_REGEX, text)
108109
if m:

tests/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import sys
55
import traceback
66
from pathlib import Path
7-
from typing import Iterable
7+
from collections.abc import Iterable
88

99
import pytest
1010
import responses

0 commit comments

Comments
 (0)