Module continuous_delivery_scripts.plugins.python

Plugin for Python projects.

Classes

class Python
Expand source code
class Python(BaseLanguage):
    """Specific actions for a Python project."""

    def get_related_language(self) -> str:
        """Gets related language."""
        return str(get_language_from_file_name(__file__))

    def package_software(self, mode: CommitType, version: str) -> None:
        """Packages the software into a wheel."""
        super().package_software(mode, version)
        _create_wheel()

    def release_package_to_repository(self, mode: CommitType, version: str) -> None:
        """Releases to PyPI."""
        super().release_package_to_repository(mode, version)
        _release_to_pypi()

    def check_credentials(self) -> None:
        """Checks Twine credentials."""
        super().check_credentials()
        # Checks that twine username is defined
        configuration.get_value(ENVVAR_TWINE_USERNAME)
        # Checks that twine password is defined
        configuration.get_value(ENVVAR_TWINE_PASSWORD)

    def generate_code_documentation(self, output_directory: Path, module_to_document: str) -> None:
        """Generates code documentation."""
        super().generate_code_documentation(output_directory, module_to_document)
        _generate_pdoc_in_correct_structure(module_to_document, output_directory)

    def can_add_licence_headers(self) -> bool:
        """States that licence headers can be added."""
        return True

    def can_get_project_metadata(self) -> bool:
        """States whether project metadata can be retrieved."""
        # FIXME Comment out retrieving project metadata as deprecated
        # (SetuptoolsDeprecationWarning: License classifiers are deprecated)
        return False

    def get_secret_registry_exclude_files(self) -> List[str]:
        """Gets additional detect-secrets exclude patterns for Python projects."""
        return [
            r".*Pipfile\.lock$",
            r".*poetry\.lock$",
            r".*uv\.lock$",
            r".*pdm\.lock$",
            r".*version\.py$",
            r"^\.circleci[\\/].*",
            r"^workflows/.*",
            r"^\.github[\\/]workflows[\\/].*",
        ]

    def should_include_spdx_in_package(self) -> bool:
        """States whether the SPDX documents should be included in the package."""
        # FIXME Comment out SPDX package as no longer working
        return False

    def get_current_spdx_project(self) -> Optional["SpdxProject"]:
        """Gets the current SPDX description."""
        return _get_current_spdx_project()

Specific actions for a Python project.

Ancestors

Methods

def can_add_licence_headers(self) ‑> bool
Expand source code
def can_add_licence_headers(self) -> bool:
    """States that licence headers can be added."""
    return True

States that licence headers can be added.

def check_credentials(self) ‑> None
Expand source code
def check_credentials(self) -> None:
    """Checks Twine credentials."""
    super().check_credentials()
    # Checks that twine username is defined
    configuration.get_value(ENVVAR_TWINE_USERNAME)
    # Checks that twine password is defined
    configuration.get_value(ENVVAR_TWINE_PASSWORD)

Checks Twine credentials.

def generate_code_documentation(self, output_directory: pathlib.Path, module_to_document: str) ‑> None
Expand source code
def generate_code_documentation(self, output_directory: Path, module_to_document: str) -> None:
    """Generates code documentation."""
    super().generate_code_documentation(output_directory, module_to_document)
    _generate_pdoc_in_correct_structure(module_to_document, output_directory)

Generates code documentation.

def get_current_spdx_project(self) ‑> SpdxProject | None
Expand source code
def get_current_spdx_project(self) -> Optional["SpdxProject"]:
    """Gets the current SPDX description."""
    return _get_current_spdx_project()

Gets the current SPDX description.

Expand source code
def get_related_language(self) -> str:
    """Gets related language."""
    return str(get_language_from_file_name(__file__))

Gets related language.

def get_secret_registry_exclude_files(self) ‑> List[str]
Expand source code
def get_secret_registry_exclude_files(self) -> List[str]:
    """Gets additional detect-secrets exclude patterns for Python projects."""
    return [
        r".*Pipfile\.lock$",
        r".*poetry\.lock$",
        r".*uv\.lock$",
        r".*pdm\.lock$",
        r".*version\.py$",
        r"^\.circleci[\\/].*",
        r"^workflows/.*",
        r"^\.github[\\/]workflows[\\/].*",
    ]

Gets additional detect-secrets exclude patterns for Python projects.

def package_software(self,
mode: CommitType,
version: str) ‑> None
Expand source code
def package_software(self, mode: CommitType, version: str) -> None:
    """Packages the software into a wheel."""
    super().package_software(mode, version)
    _create_wheel()

Packages the software into a wheel.

def release_package_to_repository(self,
mode: CommitType,
version: str) ‑> None
Expand source code
def release_package_to_repository(self, mode: CommitType, version: str) -> None:
    """Releases to PyPI."""
    super().release_package_to_repository(mode, version)
    _release_to_pypi()

Releases to PyPI.

Inherited members