-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add type hints to CleverCSV This commit adds type hints to CleverCSV and enables static type checking with MyPy. An attempt was made to keep the changes minimal, in order to change only the code needed to get MyPy to pass. As can be seen, this already required a large number of changes to the code. It is also clear that certain design decisions could be reevaluated to make the type checking smoother (e.g., requiring @overload is not ideal). Such improvements are left for future work.
- Loading branch information
Showing
44 changed files
with
1,992 additions
and
261 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
VERSION = (0, 8, 0) | ||
from typing import Tuple | ||
|
||
__version__ = ".".join(map(str, VERSION)) | ||
VERSION: Tuple[int, int, int] = (0, 8, 0) | ||
|
||
__version__: str = ".".join(map(str, VERSION)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# -*- 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 Type | ||
from typing import Union | ||
|
||
from clevercsv.dialect import SimpleDialect | ||
|
||
AnyPath = Union[str, bytes, "os.PathLike[str]", "os.PathLike[bytes]"] | ||
_OpenFile = Union[AnyPath, int] | ||
_DictRow = Mapping[str, Any] | ||
_DialectLike = Union[str, csv.Dialect, Type[csv.Dialect], SimpleDialect] | ||
|
||
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", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
from typing import Optional | ||
|
||
def base_abstraction( | ||
data: str, | ||
delimiter: Optional[str], | ||
quotechar: Optional[str], | ||
escapechar: Optional[str], | ||
) -> str: ... | ||
def c_merge_with_quotechar(data: str) -> str: ... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.