view mercurial/interfaces/status.py @ 52654:f19a3f1437f3

pyupgrade: drop `coding=UTF-8` comments PEP-3120[1] (Python 3.0 in 2007) says that UTF-8 is the default encoding. That should be long enough ago that no reasonable editor would trip over this, and certainly any supported version of Python won't. The comments were probably harmless, but as `pyupgrade` has no mechanism to disable this change, omitting this change makes it unusable as a code checking tool, and makes it a pain to use occasionally to upgrade the source (since these changes would need to be manually reverted). [1] https://peps.python.org/pep-3120/
author Matt Harbison <matt_harbison@yahoo.com>
date Tue, 07 Jan 2025 16:46:21 -0500
parents f5d134e57f51
children
line wrap: on
line source

# status.py - Type annotations for status related objects
#
# Copyright Matt Harbison <mharbison72@gmail.com>
#
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2 or any later version.

from __future__ import annotations

import abc

from typing import (
    Iterator,
    Protocol,
)


class Status(Protocol):
    """Struct with a list of files per status.

    The 'deleted', 'unknown' and 'ignored' properties are only
    relevant to the working copy.
    """

    modified: list[bytes]
    """The list of files with modifications."""

    added: list[bytes]
    """The list of files that started being tracked."""

    removed: list[bytes]
    """The list of files that stopped being tracked."""

    deleted: list[bytes]
    """The list of files in the working directory that are deleted from the
    file system (but not in the removed state)."""

    unknown: list[bytes]
    """The list of files in the working directory that are not tracked."""

    ignored: list[bytes]
    """The list of files in the working directory that are ignored."""

    clean: list[bytes]
    """The list of files that are not in any other state."""

    @abc.abstractmethod
    def __iter__(self) -> Iterator[list[bytes]]:
        """Iterates over each of the categories of file lists."""

    @abc.abstractmethod
    def __repr__(self) -> str:
        """Creates a string representation of the file lists."""