Skip to content

Commit

Permalink
Fixed docs building
Browse files Browse the repository at this point in the history
Changed | to Union or Optional as sphinx cannot handle it
Changed list and dict to List and Dict
Changed tuple to Tuple

fixed docs
  • Loading branch information
midnightercz committed May 3, 2024
1 parent e88ea16 commit d41ebff
Show file tree
Hide file tree
Showing 29 changed files with 292 additions and 278 deletions.
27 changes: 27 additions & 0 deletions docs/source/item_processor.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
Item Processor
==============

Class which process input push items and based on their metadata produce various information
needed for the push process.

.. py.module pubtools._quay.item_processor

.. autoclass:: SignEntry
:members:

.. autoclass:: ManifestArchDigest
:members:

.. autoclass:: ContentExtractor
:members:

.. autoclass:: ReferenceProcessorInternal
:members:

.. autoclass:: ReferenceProcessorExternal
:members:

.. autoclass ItemProcessor
:members:

"""
6 changes: 3 additions & 3 deletions docs/source/modules_reference.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ API reference to modules used by pubtools-quay. Isolated usage outside of pubtoo
quay_api_client
quay_client
quay_session
signature_handler
signature_remover
item_processor
signer_wrapper
security_manifest_pusher
tag_docker
utilities
exceptions
exceptions
36 changes: 0 additions & 36 deletions docs/source/signature_handler.rst

This file was deleted.

18 changes: 0 additions & 18 deletions docs/source/signature_remover.rst

This file was deleted.

20 changes: 20 additions & 0 deletions docs/source/signer_wrapper.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
Signer Wrapper
==============

Set of signing wrappers which wraps functionality of pubtools-sign projects and provides extra methods needed for the signign process.

.. py:module:: pubtools._quay.signer_wrapper
.. autoclass:: MsgSignerSettingsSchema
:members:

.. autoclass:: SignerWrapper
:members:

.. autoclass:: MsgSignerWrapper
:members:

.. autoclass:: CosignSignerSettingsSchema
:members:

.. autoclass:: CosignSignerWrapper
6 changes: 3 additions & 3 deletions pubtools/_quay/clear_repo.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import argparse
import logging
import os
from typing import Any, Dict, List, cast
from typing import Any, Dict, List, cast, Optional

from pubtools.pluggy import task_context, pm

Expand Down Expand Up @@ -90,7 +90,7 @@
}


def clear_repositories(repositories: str, settings: dict[str, Any]) -> None:
def clear_repositories(repositories: str, settings: Dict[str, Any]) -> None:
"""
Clear Quay repository.
Expand Down Expand Up @@ -178,7 +178,7 @@ def setup_args() -> argparse.ArgumentParser:
return setup_arg_parser(CLEAR_REPO_ARGS)


def clear_repositories_main(sysargs: list[str] | None = None) -> None:
def clear_repositories_main(sysargs: Optional[List[str]] = None) -> None:
"""Entrypoint for clearing repositories."""
logging.basicConfig(level=logging.INFO)

Expand Down
52 changes: 26 additions & 26 deletions pubtools/_quay/command_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import time
import textwrap
from types import TracebackType
from typing import Any, Optional, Type, Generator
from typing import Any, Optional, Type, Generator, List, Dict, Tuple
from typing_extensions import Self

import docker
Expand Down Expand Up @@ -61,15 +61,15 @@ def __exit__(
def _run_cmd(
self,
cmd: str,
err_msg: str | None = None,
err_msg: Optional[str] = None,
tolerate_err: bool = False,
stdin: str | None = None,
) -> tuple[str, str]:
stdin: Optional[str] = None,
) -> Tuple[str, str]:
"""Run a bash command."""
raise NotImplementedError # pragma: no cover"

def skopeo_login(
self, host: str = "quay.io", username: str | None = None, password: str | None = None
self, host: str = "quay.io", username: Optional[str] = None, password: Optional[str] = None
) -> None:
"""
Attempt to login to Quay if no login credentials are present.
Expand Down Expand Up @@ -105,7 +105,7 @@ def skopeo_login(
"STDOUT: '{0}', STDERR: '{1}'".format(out, err)
)

def tag_images(self, source_ref: str, dest_refs: list[str], all_arch: bool = False) -> None:
def tag_images(self, source_ref: str, dest_refs: List[str], all_arch: bool = False) -> None:
"""
Copy image from source to destination(s) using skopeo.
Expand Down Expand Up @@ -157,7 +157,7 @@ def skopeo_inspect(self, image_ref: str, raw: bool = False) -> Any:
class LocalExecutor(Executor):
"""Run commands locally."""

def __init__(self, params: dict[str, Any] = {}) -> None:
def __init__(self, params: Dict[str, Any] = {}) -> None:
"""
Initialize.
Expand All @@ -175,10 +175,10 @@ def __init__(self, params: dict[str, Any] = {}) -> None:
def _run_cmd(
self,
cmd: str,
err_msg: str | None = None,
err_msg: Optional[str] = None,
tolerate_err: bool = False,
stdin: str | None = None,
) -> tuple[str, str]:
stdin: Optional[str] = None,
) -> Tuple[str, str]:
"""
Run a command locally.
Expand Down Expand Up @@ -215,10 +215,10 @@ class RemoteExecutor(Executor):
def __init__(
self,
hostname: str,
username: str | None = None,
key_filename: str | None = None,
password: str | None = None,
port: int | None = None,
username: Optional[str] = None,
key_filename: Optional[str] = None,
password: Optional[str] = None,
port: Optional[int] = None,
accept_unknown_host: bool = True,
) -> None:
"""
Expand Down Expand Up @@ -253,10 +253,10 @@ def __init__(
def _run_cmd(
self,
cmd: str,
err_msg: str | None = None,
err_msg: Optional[str] = None,
tolerate_err: bool = False,
stdin: str | None = None,
) -> tuple[str, str]:
stdin: Optional[str] = None,
) -> Tuple[str, str]:
"""
Run a command remotely via SSH.
Expand Down Expand Up @@ -310,11 +310,11 @@ def __init__(
self,
image: str,
base_url: str = "unix://var/run/docker.sock",
timeout: int | None = None,
timeout: Optional[int] = None,
verify_tls: bool = False,
cert_path: str | None = None,
registry_username: str | None = None,
registry_password: str | None = None,
cert_path: Optional[str] = None,
registry_username: Optional[str] = None,
registry_password: Optional[str] = None,
) -> None:
"""
Initialize.
Expand All @@ -340,7 +340,7 @@ def __init__(
"""
self.image = image

kwargs: dict[Any, Any] = {}
kwargs: Dict[Any, Any] = {}
kwargs["base_url"] = base_url
kwargs["version"] = "auto"
if timeout:
Expand Down Expand Up @@ -382,10 +382,10 @@ def __exit__(
def _run_cmd(
self,
cmd: str,
err_msg: str | None = None,
err_msg: Optional[str] = None,
tolerate_err: bool = False,
stdin: str | None = None,
) -> tuple[str, str]:
stdin: Optional[str] = None,
) -> Tuple[str, str]:
"""
Run a command locally.
Expand Down Expand Up @@ -456,7 +456,7 @@ def _add_file(self, data: str, file_name: str) -> None:
raise RuntimeError("File was not successfully added to the container")

def skopeo_login(
self, host: str = "quay.io", username: str | None = None, password: str | None = None
self, host: str = "quay.io", username: Optional[str] = None, password: Optional[str] = None
) -> None:
"""
Attempt to login to Quay if no login credentials are present.
Expand Down
12 changes: 6 additions & 6 deletions pubtools/_quay/container_image_pusher.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import logging
from concurrent import futures
from concurrent.futures.thread import ThreadPoolExecutor
from typing import Any, cast
from typing import Any, cast, Dict, Optional, Union


import requests
Expand Down Expand Up @@ -33,7 +33,7 @@ class ContainerImagePusher:
No validation is performed, push items are expected to be correct.
"""

def __init__(self, push_items: list[Any], target_settings: dict[str, Any]) -> None:
def __init__(self, push_items: list[Any], target_settings: Dict[str, Any]) -> None:
"""
Initialize.
Expand All @@ -47,8 +47,8 @@ def __init__(self, push_items: list[Any], target_settings: dict[str, Any]) -> No
self.target_settings = target_settings

self.quay_host = self.target_settings.get("quay_host", "quay.io").rstrip("/")
self._src_quay_client: QuayClient | None = None
self._dest_quay_client: QuayClient | None = None
self._src_quay_client: Optional[QuayClient] = None
self._dest_quay_client: Optional[QuayClient] = None

@property
def src_quay_client(self) -> QuayClient:
Expand All @@ -74,7 +74,7 @@ def dest_quay_client(self) -> QuayClient:

@classmethod
def run_tag_images(
cls, source_ref: str, dest_refs: list[str], all_arch: bool, target_settings: dict[str, Any]
cls, source_ref: str, dest_refs: list[str], all_arch: bool, target_settings: Dict[str, Any]
) -> None:
"""
Prepare the "tag images" entrypoint with all the necessary arguments and run it.
Expand Down Expand Up @@ -248,7 +248,7 @@ def copy_multiarch_push_item(self, push_item: Any, source_ml: ManifestList) -> N
)
try:
dest_ml = cast(
Manifest | ManifestList, self.dest_quay_client.get_manifest(dest_ref)
Union[Manifest, ManifestList], self.dest_quay_client.get_manifest(dest_ref)
)
if dest_ml.get("mediaType") != QuayClient.MANIFEST_LIST_TYPE:
LOG.warning(
Expand Down
9 changes: 5 additions & 4 deletions pubtools/_quay/hooks.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import sys
from typing import List

from pubtools.pluggy import pm, hookspec

Expand All @@ -7,7 +8,7 @@


@hookspec
def quay_repositories_cleared(repository_ids: list[str]) -> None:
def quay_repositories_cleared(repository_ids: List[str]) -> None:
"""Invoked after repositories have been cleared on Quay.
:param repository_ids: ID of each cleared repository.
Expand All @@ -16,7 +17,7 @@ def quay_repositories_cleared(repository_ids: list[str]) -> None:


@hookspec
def quay_repositories_removed(repository_ids: list[str]) -> None:
def quay_repositories_removed(repository_ids: List[str]) -> None:
"""Invoked after repositories have been removed from Quay.
:param repository_ids: ID of each removed repository.
Expand All @@ -25,7 +26,7 @@ def quay_repositories_removed(repository_ids: list[str]) -> None:


@hookspec
def quay_images_tagged(source_ref: str, dest_refs: list[str]) -> None:
def quay_images_tagged(source_ref: str, dest_refs: List[str]) -> None:
"""Invoked after tagging image(s) on Quay.
:param source_ref: Source image reference.
Expand All @@ -36,7 +37,7 @@ def quay_images_tagged(source_ref: str, dest_refs: list[str]) -> None:


@hookspec
def quay_images_untagged(untag_refs: list[str], lost_refs: list[str]) -> None:
def quay_images_untagged(untag_refs: List[str], lost_refs: List[str]) -> None:
"""Invoked after untagging image(s) on Quay.
:param untag_refs: Image references for which tags were removed.
Expand Down
Loading

0 comments on commit d41ebff

Please sign in to comment.