Skip to content

Commit

Permalink
overload to_json (#2005)
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcoGorelli committed Dec 7, 2021
1 parent c70b5d4 commit 090bb7e
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions py-polars/polars/internals/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -683,10 +683,41 @@ def to_dict(
else:
return {s.name: s.to_list() for s in self}

@tp.overload
def to_json(
self,
file: Optional[Union[BytesIO, str, Path]] = ...,
pretty: bool = ...,
*,
to_string: Literal[True],
) -> str:
...

@tp.overload
def to_json(
self,
file: Optional[Union[BytesIO, str, Path]] = ...,
pretty: bool = ...,
*,
to_string: Literal[False] = ...,
) -> None:
...

@tp.overload
def to_json(
self,
file: Optional[Union[BytesIO, str, Path]] = ...,
pretty: bool = ...,
*,
to_string: bool = ...,
) -> Optional[str]:
...

def to_json(
self,
file: Optional[Union[BytesIO, str, Path]] = None,
pretty: bool = False,
*,
to_string: bool = False,
) -> Optional[str]:
"""
Expand Down

0 comments on commit 090bb7e

Please sign in to comment.