File: _types.py

package info (click to toggle)
python-clevercsv 0.8.4%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,080 kB
  • sloc: python: 6,211; ansic: 870; makefile: 90
file content (60 lines) | stat: -rw-r--r-- 1,262 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# -*- coding: utf-8 -*-

from __future__ import annotations

import csv
import os
import sys

from typing import TYPE_CHECKING
from typing import Any
from typing import Mapping
from typing import TypeVar
from typing import Union

import _csv

from clevercsv.dialect import SimpleDialect

AnyPath = Union[str, bytes, "os.PathLike[str]", "os.PathLike[bytes]"]
StrPath = Union[str, "os.PathLike[str]"]
_OpenFile = Union[AnyPath, int]
_DictRow = Mapping[str, Any]
_DialectLike = Union[
    str,
    csv.Dialect,
    _csv.Dialect,
    type[_csv.Dialect],
    SimpleDialect,
]
_T = TypeVar("_T")

if sys.version_info >= (3, 8):
    from typing import Dict as _DictReadMapping
else:
    from collections import OrderedDict as _DictReadMapping


if TYPE_CHECKING:
    from _typeshed import FileDescriptorOrPath  # NOQA
    from _typeshed import SupportsIter  # NOQA
    from _typeshed import SupportsWrite  # NOQA

    __all__ = [
        "SupportsWrite",
        "SupportsIter",
        "FileDescriptorOrPath",
        "AnyPath",
        "_OpenFile",
        "_DictRow",
        "_DialectLike",
        "_DictReadMapping",
    ]
else:
    __all__ = [
        "AnyPath",
        "_OpenFile",
        "_DictRow",
        "_DialectLike",
        "_DictReadMapping",
    ]