Skip to content

Type definitions

Type definitions used in lintkit.

Note

This module is mostly used internally, unlikely to be directly useful for linter creators.

lintkit.type_definitions.Output module-attribute

Output = Callable[[str, int, str, Path | None, int | None, int | None, int | None, int | None], None]

Type of function which is used to output errors.

Info

See lintkit.output and lintkit.settings.output for more information.

Tip

Custom output functions should follow this signature.

lintkit.type_definitions.GetItem

Bases: Protocol

Protocol used to type objects with __getitem__ and __contains__.

lintkit.type_definitions.GetItem.__getitem__

__getitem__(key)

Signature of __getitem__ method.

Parameters:

Name Type Description Default
key Hashable

Key to get the value for (must implement Hashable interface).

required

Returns:

Type Description
Any

Value for the key.

Source code in src/lintkit/type_definitions.py
def __getitem__(self, key: Hashable) -> typing.Any:
    """Signature of `__getitem__` method.

    Args:
        key:
            Key to get the value for (must implement `Hashable` interface).

    Returns:
        Value for the key.

    """

lintkit.type_definitions.GetItem.__contains__

__contains__(key)

Signature of __contains__ method.

Parameters:

Name Type Description Default
key Hashable

Key to check for (must implement Hashable interface).

required

Returns:

Type Description
bool

True if the key is in the object, False otherwise.

Source code in src/lintkit/type_definitions.py
def __contains__(self, key: Hashable) -> bool:
    """Signature of `__contains__` method.

    Args:
        key:
            Key to check for (must implement `Hashable` interface).

    Returns:
        True if the key is in the object, False otherwise.

    """
    # Dummy return value, necessary to due pyright checks
    return True