On this page
  1. typing.Collection
  2. Import
  3. Signature & Overview
  4. Usage
  5. Gotchas
  6. REPL Inspect

typing.Collection

Prev: typing.clear_overloads | Up: typing | Next: typing.Concatenate
Rel: typing.AbstractSet, typing.Annotated, typing.Any, typing.assert_never
Ref: docs.python.org — typing.Collection
Tags: #public #python3 #stdlib #typing


Import

import typing
from typing import Collection

Signature & Overview

typing.Collection(*args, **kwargs)

Deprecated alias to collections.abc.Collection.

Usage

from typing import Collection

def is_nonempty(items: Collection[int]) -> bool:
    return len(items) > 0

assert is_nonempty([1, 2]) and is_nonempty({1})

Gotchas

REPL Inspect

from typing import Collection
help(Collection)

Linked from

Related notes