Merge pull request #8 from Parnassius/pathlike

Use `os.PathLike` for file names
This commit is contained in:
timrid 2022-01-09 12:48:27 +01:00 committed by GitHub
commit ba31334a33
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,5 +1,6 @@
import enum
import io
import os
import sys
import typing as t
@ -25,6 +26,7 @@ from construct.lib import (
# - Higher Kinded Types: https://sobolevn.me/2020/10/higher-kinded-types-in-python
StreamType = t.BinaryIO
FilenameType = t.Union[str, bytes, os.PathLike[str], os.PathLike[bytes]]
PathType = str
ContextKWType = t.Any
@ -97,18 +99,24 @@ class Construct(t.Generic[ParsedType, BuildTypes]):
def parse_stream(
self, stream: StreamType, **contextkw: ContextKWType
) -> ParsedType: ...
def parse_file(self, filename: str, **contextkw: ContextKWType) -> ParsedType: ...
def parse_file(
self, filename: FilenameType, **contextkw: ContextKWType
) -> ParsedType: ...
def build(self, obj: BuildTypes, **contextkw: ContextKWType) -> bytes: ...
def build_stream(
self, obj: BuildTypes, stream: StreamType, **contextkw: ContextKWType
) -> bytes: ...
def build_file(
self, obj: BuildTypes, filename: str, **contextkw: ContextKWType
self, obj: BuildTypes, filename: FilenameType, **contextkw: ContextKWType
) -> bytes: ...
def sizeof(self, **contextkw: ContextKWType) -> int: ...
def compile(self, filename: str = ...) -> Construct[ParsedType, BuildTypes]: ...
def benchmark(self, sampledata: bytes, filename: str = ...) -> str: ...
def export_ksy(self, schemaname: str = ..., filename: str = ...) -> str: ...
def compile(
self, filename: FilenameType = ...
) -> Construct[ParsedType, BuildTypes]: ...
def benchmark(self, sampledata: bytes, filename: FilenameType = ...) -> str: ...
def export_ksy(
self, schemaname: str = ..., filename: FilenameType = ...
) -> str: ...
def __rtruediv__(
self, name: t.Optional[t.AnyStr]
) -> Renamed[ParsedType, BuildTypes]: ...