Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/scripts/conformance-client.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
"""Conformance client for python-tuf, part of tuf-conformance"""

# Copyright 2024 tuf-conformance contributors
Expand Down
2 changes: 1 addition & 1 deletion examples/client/client
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
"""TUF Client Example"""

# Copyright 2012 - 2017, New York University and the TUF contributors
Expand Down
2 changes: 1 addition & 1 deletion examples/repository/repo
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# Copyright 2021-2022 python-tuf contributors
# SPDX-License-Identifier: MIT OR Apache-2.0

Expand Down
2 changes: 1 addition & 1 deletion examples/uploader/uploader
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# Copyright 2021-2022 python-tuf contributors
# SPDX-License-Identifier: MIT OR Apache-2.0

Expand Down
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ ignore = [
# Rulesets we do not use at this moment
"COM",
"EM",
"FA",
"FIX",
"FBT",
"PERF",
Expand Down
2 changes: 1 addition & 1 deletion tests/simple_server.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3

# Copyright 2012 - 2017, New York University and the TUF contributors
# SPDX-License-Identifier: MIT OR Apache-2.0
Expand Down
5 changes: 3 additions & 2 deletions tests/test_updater_fetch_target.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@
target files storing/loading from cache.
"""

from __future__ import annotations

import os
import sys
import tempfile
import unittest
from dataclasses import dataclass
from typing import Optional

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

# set dump_dir to trigger repository state dumps
dump_dir: Optional[str] = None
dump_dir: str | None = None

def setUp(self) -> None:
self.temp_dir = tempfile.TemporaryDirectory()
Expand Down
12 changes: 8 additions & 4 deletions tests/test_updater_top_level_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,16 @@

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

from __future__ import annotations

import builtins
import datetime
import os
import sys
import tempfile
import unittest
from collections.abc import Iterable
from datetime import timezone
from typing import Optional
from typing import TYPE_CHECKING
from unittest.mock import MagicMock, call, patch

import freezegun
Expand All @@ -37,13 +38,16 @@
)
from tuf.ngclient import Updater

if TYPE_CHECKING:
from collections.abc import Iterable


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

# set dump_dir to trigger repository state dumps
dump_dir: Optional[str] = None
dump_dir: str | None = None

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

def _assert_content_equals(
self, role: str, version: Optional[int] = None
self, role: str, version: int | None = None
) -> None:
"""Assert that local file content is the expected"""
expected_content = self.sim.fetch_metadata(role, version)
Expand Down
5 changes: 3 additions & 2 deletions tuf/api/serialization/json.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@
# We should not have shadowed stdlib json but that milk spilled already
# ruff: noqa: A005

from __future__ import annotations

import json
from typing import Optional

from securesystemslib.formats import encode_canonical

Expand Down Expand Up @@ -56,7 +57,7 @@ class JSONSerializer(MetadataSerializer):

"""

def __init__(self, compact: bool = False, validate: Optional[bool] = False):
def __init__(self, compact: bool = False, validate: bool | None = False):
self.compact = compact
self.validate = validate

Expand Down
5 changes: 3 additions & 2 deletions tuf/ngclient/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@

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

from __future__ import annotations

from dataclasses import dataclass
from enum import Flag, unique
from typing import Optional


@unique
Expand Down Expand Up @@ -52,4 +53,4 @@ class UpdaterConfig:
targets_max_length: int = 5000000 # bytes
prefix_targets_with_hash: bool = True
envelope_type: EnvelopeType = EnvelopeType.METADATA
app_user_agent: Optional[str] = None
app_user_agent: str | None = None
7 changes: 4 additions & 3 deletions verify_release
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3

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

from __future__ import annotations

import argparse
import json
import os
import subprocess
import sys
from filecmp import cmp
from tempfile import TemporaryDirectory
from typing import Optional

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


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