2022-08-14 22:01:28 +02:00
|
|
|
"""
|
2022-08-25 13:46:19 +02:00
|
|
|
This module contains type definitions to ease the usage of the API and its documentation.
|
|
|
|
|
|
|
|
Some types are somewhat complex, and it is easier to use a single word/reference instead of a complex typing construct.
|
2022-08-14 22:01:28 +02:00
|
|
|
"""
|
|
|
|
import csv
|
2022-08-15 19:32:09 +02:00
|
|
|
from typing import Any, Callable, Dict, Optional, Type
|
2022-08-14 22:01:28 +02:00
|
|
|
|
2022-08-15 19:32:09 +02:00
|
|
|
DataCast = Callable[[str], Any]
|
2022-08-25 13:46:19 +02:00
|
|
|
"""
|
|
|
|
A :class:`DataCast` describes how a data casting callable must be implemented. It requires one parameter of the type
|
|
|
|
:class:`str` and can return anything that is required.
|
|
|
|
"""
|
|
|
|
|
2022-08-14 22:01:28 +02:00
|
|
|
DataCastDict = Dict[str, DataCast]
|
2022-08-25 13:46:19 +02:00
|
|
|
"""
|
|
|
|
A :class:`DataCastDict` describes how a dictionary of data casting callables must look like. The key is a :class:`str`
|
|
|
|
describing the column name, the value is a :class:`DataCast`.
|
|
|
|
"""
|
|
|
|
|
2022-08-15 19:32:09 +02:00
|
|
|
DataCasts = Optional[DataCastDict]
|
2022-08-25 13:46:19 +02:00
|
|
|
"""
|
|
|
|
The :class:`DataCasts` type describes the type of the `data_casts` parameter of the
|
|
|
|
:meth:`~pytest_csv_params.decorator.csv_params` decorator. An optional :class:`DataCastDict`.
|
|
|
|
"""
|
2022-08-14 22:01:28 +02:00
|
|
|
|
|
|
|
BaseDir = Optional[str]
|
2022-08-25 13:46:19 +02:00
|
|
|
"""
|
|
|
|
The :class:`BaseDir` describes the type of the `base_dir` parameter of the
|
|
|
|
:meth:`~pytest_csv_params.decorator.csv_params` decorator to search for non-absolute CSV files. It is simply an optional
|
|
|
|
:class:`str`.
|
|
|
|
"""
|
|
|
|
|
2022-08-14 22:01:28 +02:00
|
|
|
IdColName = Optional[str]
|
2022-08-25 13:46:19 +02:00
|
|
|
"""
|
|
|
|
The :class:`IdColName` describes the type of the `id_col` parameter of the
|
|
|
|
:meth:`~pytest_csv_params.decorator.csv_params` decorator to name the ID column from a CSV file. It is simply an
|
|
|
|
optional :class:`str`.
|
|
|
|
"""
|
2022-08-14 22:01:28 +02:00
|
|
|
|
|
|
|
DataFile = str
|
2022-08-25 13:46:19 +02:00
|
|
|
"""
|
|
|
|
The :class:`DataFile` describes the type if the `data_file` parameter of the
|
|
|
|
:meth:`~pytest_csv_params.decorator.csv_params` decorator to define the CSV file to use. It is an obligatory
|
|
|
|
:class:`str`.
|
|
|
|
"""
|
2022-08-14 22:01:28 +02:00
|
|
|
|
|
|
|
CsvDialect = Type[csv.Dialect]
|
2022-08-25 13:46:19 +02:00
|
|
|
"""
|
|
|
|
The :class:`CsvDialect` describes the type of the `dialect` parameter of the
|
|
|
|
:meth:`~pytest_csv_params.decorator.csv_params` decorator. It is required, but it has an default value in
|
|
|
|
:class:`pytest_csv_params.dialect.CsvParamsDefaultDialect`.
|
|
|
|
"""
|
2022-08-17 11:26:23 +02:00
|
|
|
|
|
|
|
HeaderRenamesDict = Dict[str, str]
|
2022-08-25 13:46:19 +02:00
|
|
|
"""
|
|
|
|
The :class:`HeaderRenamesDict` describes how a dictionary of header renames must look. Keys and values must both be of
|
|
|
|
type :class:`str`.
|
|
|
|
"""
|
|
|
|
|
2022-08-17 11:26:23 +02:00
|
|
|
HeaderRenames = Optional[HeaderRenamesDict]
|
2022-08-25 13:46:19 +02:00
|
|
|
"""
|
|
|
|
The :class:`HeaderRenames` describes the type of the `header_renames` parameter of the
|
|
|
|
:meth:`~pytest_csv_params.decorator.csv_params` decorator. It is just an optional :class:`HeaderRenamesDict`.
|
|
|
|
"""
|