feat: add type stubs for csv and xlsx subpackages
This commit is contained in:
12
omniread/csv/__init__.pyi
Normal file
12
omniread/csv/__init__.pyi
Normal file
@@ -0,0 +1,12 @@
|
||||
from .client import BaseCsvClient, FileSystemCsvClient
|
||||
from .parser import CsvParser
|
||||
from .parser_base import CsvParserBase
|
||||
from .scraper import CsvScraper
|
||||
|
||||
__all__ = [
|
||||
"BaseCsvClient",
|
||||
"FileSystemCsvClient",
|
||||
"CsvScraper",
|
||||
"CsvParser",
|
||||
"CsvParserBase",
|
||||
]
|
||||
10
omniread/csv/client.pyi
Normal file
10
omniread/csv/client.pyi
Normal file
@@ -0,0 +1,10 @@
|
||||
from abc import ABC, abstractmethod
|
||||
from pathlib import Path
|
||||
from typing import Any
|
||||
|
||||
class BaseCsvClient(ABC):
|
||||
@abstractmethod
|
||||
def fetch(self, source: Any) -> bytes: ...
|
||||
|
||||
class FileSystemCsvClient(BaseCsvClient):
|
||||
def fetch(self, path: Path) -> bytes: ...
|
||||
8
omniread/csv/parser.pyi
Normal file
8
omniread/csv/parser.pyi
Normal file
@@ -0,0 +1,8 @@
|
||||
from omniread.core.content import Content
|
||||
|
||||
from .parser_base import CsvParserBase
|
||||
|
||||
class CsvParser(CsvParserBase[list[list[str]]]):
|
||||
def __init__(self, content: Content) -> None: ...
|
||||
def parse(self) -> list[list[str]]: ...
|
||||
def rows(self, *, skip_empty: bool = True) -> list[list[str]]: ...
|
||||
13
omniread/csv/parser_base.pyi
Normal file
13
omniread/csv/parser_base.pyi
Normal file
@@ -0,0 +1,13 @@
|
||||
from abc import abstractmethod
|
||||
from typing import Generic, TypeVar
|
||||
|
||||
from omniread.core.content import ContentType
|
||||
from omniread.core.parser import BaseParser
|
||||
|
||||
T = TypeVar("T")
|
||||
|
||||
class CsvParserBase(BaseParser[T], Generic[T]):
|
||||
supported_types: set[ContentType]
|
||||
|
||||
@abstractmethod
|
||||
def parse(self) -> T: ...
|
||||
12
omniread/csv/scraper.pyi
Normal file
12
omniread/csv/scraper.pyi
Normal file
@@ -0,0 +1,12 @@
|
||||
from collections.abc import Mapping
|
||||
from typing import Any
|
||||
|
||||
from omniread.core.content import Content
|
||||
|
||||
from .client import BaseCsvClient
|
||||
|
||||
class CsvScraper:
|
||||
def __init__(self, *, client: BaseCsvClient) -> None: ...
|
||||
def fetch(
|
||||
self, source: Any, *, metadata: Mapping[str, Any] | None = ...
|
||||
) -> Content: ...
|
||||
12
omniread/xlsx/__init__.pyi
Normal file
12
omniread/xlsx/__init__.pyi
Normal file
@@ -0,0 +1,12 @@
|
||||
from .client import BaseXlsxClient, FileSystemXlsxClient
|
||||
from .parser import XlsxParser
|
||||
from .parser_base import XlsxParserBase
|
||||
from .scraper import XlsxScraper
|
||||
|
||||
__all__ = [
|
||||
"BaseXlsxClient",
|
||||
"FileSystemXlsxClient",
|
||||
"XlsxScraper",
|
||||
"XlsxParser",
|
||||
"XlsxParserBase",
|
||||
]
|
||||
10
omniread/xlsx/client.pyi
Normal file
10
omniread/xlsx/client.pyi
Normal file
@@ -0,0 +1,10 @@
|
||||
from abc import ABC, abstractmethod
|
||||
from pathlib import Path
|
||||
from typing import Any
|
||||
|
||||
class BaseXlsxClient(ABC):
|
||||
@abstractmethod
|
||||
def fetch(self, source: Any) -> bytes: ...
|
||||
|
||||
class FileSystemXlsxClient(BaseXlsxClient):
|
||||
def fetch(self, path: Path) -> bytes: ...
|
||||
18
omniread/xlsx/parser.pyi
Normal file
18
omniread/xlsx/parser.pyi
Normal file
@@ -0,0 +1,18 @@
|
||||
import openpyxl
|
||||
|
||||
from omniread.core.content import Content
|
||||
|
||||
from .parser_base import XlsxParserBase
|
||||
|
||||
class XlsxParser(XlsxParserBase[list[list[str]]]):
|
||||
def __init__(
|
||||
self, content: Content, *, data_only: bool = True, read_only: bool = True
|
||||
) -> None: ...
|
||||
@property
|
||||
def workbook(self) -> openpyxl.Workbook: ...
|
||||
@property
|
||||
def sheet_names(self) -> list[str]: ...
|
||||
def parse(self) -> list[list[str]]: ...
|
||||
def rows(
|
||||
self, sheet: int | str | None = None, *, skip_empty: bool = True
|
||||
) -> list[list[str]]: ...
|
||||
13
omniread/xlsx/parser_base.pyi
Normal file
13
omniread/xlsx/parser_base.pyi
Normal file
@@ -0,0 +1,13 @@
|
||||
from abc import abstractmethod
|
||||
from typing import Generic, TypeVar
|
||||
|
||||
from omniread.core.content import ContentType
|
||||
from omniread.core.parser import BaseParser
|
||||
|
||||
T = TypeVar("T")
|
||||
|
||||
class XlsxParserBase(BaseParser[T], Generic[T]):
|
||||
supported_types: set[ContentType]
|
||||
|
||||
@abstractmethod
|
||||
def parse(self) -> T: ...
|
||||
12
omniread/xlsx/scraper.pyi
Normal file
12
omniread/xlsx/scraper.pyi
Normal file
@@ -0,0 +1,12 @@
|
||||
from collections.abc import Mapping
|
||||
from typing import Any
|
||||
|
||||
from omniread.core.content import Content
|
||||
|
||||
from .client import BaseXlsxClient
|
||||
|
||||
class XlsxScraper:
|
||||
def __init__(self, *, client: BaseXlsxClient) -> None: ...
|
||||
def fetch(
|
||||
self, source: Any, *, metadata: Mapping[str, Any] | None = ...
|
||||
) -> Content: ...
|
||||
@@ -90,7 +90,7 @@ Versions = "https://git.aetoskia.com/aetos/omniread/tags"
|
||||
packages = { find = { include = ["omniread*"] } }
|
||||
|
||||
[tool.setuptools.package-data]
|
||||
omniread = ["py.typed"]
|
||||
omniread = ['py.typed', '\.pyi?$']
|
||||
|
||||
|
||||
[tool.pytest.ini_options]
|
||||
|
||||
Reference in New Issue
Block a user