Skip to content

Commit 9463936

Browse files
committed
Enable FA (future annotations) linting ruleset
Signed-off-by: pakagronglb <[email protected]>
1 parent b084885 commit 9463936

File tree

6 files changed

+23
-22
lines changed

6 files changed

+23
-22
lines changed

pyproject.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@ ignore = [
8181
# Rulesets we do not use at this moment
8282
"COM",
8383
"EM",
84-
"FA",
8584
"FIX",
8685
"FBT",
8786
"PERF",

tests/test_updater_fetch_target.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,13 @@
55
target files storing/loading from cache.
66
"""
77

8+
from __future__ import annotations
9+
810
import os
911
import sys
1012
import tempfile
1113
import unittest
1214
from dataclasses import dataclass
13-
from typing import Optional
1415

1516
from tests import utils
1617
from tests.repository_simulator import RepositorySimulator
@@ -30,7 +31,7 @@ class TestFetchTarget(unittest.TestCase):
3031
"""Test ngclient downloading and caching target files."""
3132

3233
# set dump_dir to trigger repository state dumps
33-
dump_dir: Optional[str] = None
34+
dump_dir: str | None = None
3435

3536
def setUp(self) -> None:
3637
self.temp_dir = tempfile.TemporaryDirectory()

tests/test_updater_top_level_update.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,16 @@
33

44
"""Test ngclient Updater top-level metadata update workflow"""
55

6+
from __future__ import annotations
7+
68
import builtins
79
import datetime
810
import os
911
import sys
1012
import tempfile
1113
import unittest
12-
from collections.abc import Iterable
1314
from datetime import timezone
14-
from typing import Optional
15+
from typing import TYPE_CHECKING
1516
from unittest.mock import MagicMock, call, patch
1617

1718
import freezegun
@@ -37,13 +38,16 @@
3738
)
3839
from tuf.ngclient import Updater
3940

41+
if TYPE_CHECKING:
42+
from collections.abc import Iterable
43+
4044

4145
class TestRefresh(unittest.TestCase):
4246
"""Test update of top-level metadata following
4347
'Detailed client workflow' in the specification."""
4448

4549
# set dump_dir to trigger repository state dumps
46-
dump_dir: Optional[str] = None
50+
dump_dir: str | None = None
4751

4852
past_datetime = datetime.datetime.now(timezone.utc).replace(
4953
microsecond=0
@@ -109,7 +113,7 @@ def _assert_files_exist(self, roles: Iterable[str]) -> None:
109113
self.assertListEqual(sorted(found_files), sorted(expected_files))
110114

111115
def _assert_content_equals(
112-
self, role: str, version: Optional[int] = None
116+
self, role: str, version: int | None = None
113117
) -> None:
114118
"""Assert that local file content is the expected"""
115119
expected_content = self.sim.fetch_metadata(role, version)

tuf/api/serialization/json.py

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,13 @@
11
# Copyright New York University and the TUF contributors
22
# SPDX-License-Identifier: MIT OR Apache-2.0
33

4-
"""``tuf.api.serialization.json`` module provides concrete implementations to
5-
serialize and deserialize TUF role metadata to and from the JSON wireline
6-
format for transportation, and to serialize the 'signed' part of TUF role
7-
metadata to the OLPC Canonical JSON format for signature generation and
8-
verification.
9-
"""
10-
11-
# We should not have shadowed stdlib json but that milk spilled already
4+
"""JSON de/serialization code."""
5+
126
# ruff: noqa: A005
137

8+
from __future__ import annotations
9+
1410
import json
15-
from typing import Optional
1611

1712
from securesystemslib.formats import encode_canonical
1813

@@ -56,7 +51,7 @@ class JSONSerializer(MetadataSerializer):
5651
5752
"""
5853

59-
def __init__(self, compact: bool = False, validate: Optional[bool] = False):
54+
def __init__(self, compact: bool = False, validate: bool | None = False):
6055
self.compact = compact
6156
self.validate = validate
6257

tuf/ngclient/config.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@
33

44
"""Configuration options for ``Updater`` class."""
55

6+
from __future__ import annotations
7+
68
from dataclasses import dataclass
79
from enum import Flag, unique
8-
from typing import Optional
910

1011

1112
@unique
@@ -52,4 +53,4 @@ class UpdaterConfig:
5253
targets_max_length: int = 5000000 # bytes
5354
prefix_targets_with_hash: bool = True
5455
envelope_type: EnvelopeType = EnvelopeType.METADATA
55-
app_user_agent: Optional[str] = None
56+
app_user_agent: str | None = None

verify_release

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env python
1+
#!/usr/bin/env python3
22

33
# Copyright 2022, TUF contributors
44
# SPDX-License-Identifier: MIT OR Apache-2.0
@@ -9,14 +9,15 @@ Builds a release from current commit and verifies that the release artifacts
99
on GitHub and PyPI match the built release artifacts.
1010
"""
1111

12+
from __future__ import annotations
13+
1214
import argparse
1315
import json
1416
import os
1517
import subprocess
1618
import sys
1719
from filecmp import cmp
1820
from tempfile import TemporaryDirectory
19-
from typing import Optional
2021

2122
try:
2223
import build as _ # type: ignore[import-not-found] # noqa: F401
@@ -148,7 +149,7 @@ def verify_pypi_release(version: str, compare_dir: str) -> bool:
148149

149150

150151
def sign_release_artifacts(
151-
version: str, build_dir: str, key_id: Optional[str] = None
152+
version: str, build_dir: str, key_id: str | None = None
152153
) -> None:
153154
"""Sign built release artifacts with gpg and write signature files to cwd"""
154155
sdist = f"{PYPI_PROJECT}-{version}.tar.gz"

0 commit comments

Comments
 (0)