Skip to content

Commit ee84479

Browse files
committed
add some type hints
1 parent 4fb6df4 commit ee84479

File tree

3 files changed

+28
-24
lines changed

3 files changed

+28
-24
lines changed

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License (MIT)
22

3-
Copyright (c) 2010-2020 Nico Schlömer
3+
Copyright (c) 2010-2021 Nico Schlömer
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

doc/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
# -- Project information -----------------------------------------------------
2020

2121
project = "tikzplotlib"
22-
copyright = "2010-2020, Nico Schlömer"
22+
copyright = "2010-2021, Nico Schlömer"
2323
author = "Nico Schlömer"
2424

2525
# https://packaging.python.org/single_source_version/

tikzplotlib/_save.py

Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import pathlib
44
import tempfile
55
import warnings
6+
from typing import List, Optional, Set, Union
67

78
import matplotlib as mpl
89
import matplotlib.pyplot as plt
@@ -17,26 +18,26 @@
1718

1819
def get_tikz_code(
1920
figure="gcf",
20-
filepath=None,
21-
axis_width=None,
22-
axis_height=None,
23-
textsize=10.0,
24-
tex_relative_path_to_data=None,
25-
externalize_tables=False,
26-
override_externals=False,
27-
strict=False,
28-
wrap=True,
29-
add_axis_environment=True,
30-
extra_axis_parameters=None,
31-
extra_groupstyle_parameters={},
32-
extra_tikzpicture_parameters=None,
33-
dpi=None,
34-
show_info=False,
35-
include_disclaimer=True,
36-
standalone=False,
37-
float_format=".15g",
38-
table_row_sep="\n",
39-
flavor="latex",
21+
filepath: Optional[Union[str, pathlib.Path]] = None,
22+
axis_width: Optional[str] = None,
23+
axis_height: Optional[str] = None,
24+
textsize: float = 10.0,
25+
tex_relative_path_to_data: Optional[str] = None,
26+
externalize_tables: bool = False,
27+
override_externals: bool = False,
28+
strict: bool = False,
29+
wrap: bool = True,
30+
add_axis_environment: bool = True,
31+
extra_axis_parameters: Optional[Union[List, Set]] = None,
32+
extra_groupstyle_parameters: dict = {},
33+
extra_tikzpicture_parameters: Optional[Union[List, Set]] = None,
34+
dpi: Optional[int] = None,
35+
show_info: bool = False,
36+
include_disclaimer: bool = True,
37+
standalone: bool = False,
38+
float_format: str = ".15g",
39+
table_row_sep: str = "\n",
40+
flavor: str = "latex",
4041
):
4142
"""Main function. Here, the recursion into the image starts and the
4243
contents are picked up. The actual file gets written in this routine.
@@ -156,11 +157,12 @@ def get_tikz_code(
156157
if filepath:
157158
filepath = pathlib.Path(filepath)
158159
data["output dir"] = filepath.parent
160+
data["base name"] = filepath.stem
159161
else:
160162
directory = tempfile.mkdtemp()
161163
data["output dir"] = pathlib.Path(directory)
164+
data["base name"] = "tmp"
162165

163-
data["base name"] = filepath.stem if filepath else "tmp"
164166
data["strict"] = strict
165167
data["tikz libs"] = set()
166168
data["pgfplots libs"] = set()
@@ -239,7 +241,9 @@ def get_tikz_code(
239241
return code
240242

241243

242-
def save(filepath, *args, encoding=None, **kwargs):
244+
def save(
245+
filepath: Union[str, pathlib.Path], *args, encoding: Optional[str] = None, **kwargs
246+
):
243247
"""Same as `get_tikz_code()`, but actually saves the code to a file.
244248
245249
:param filepath: The file to which the TikZ output will be written.

0 commit comments

Comments
 (0)