Skip to content

Commit 8c12b1d

Browse files
committed
Prefer parsing tolerance as int instead of float
1 parent b066651 commit 8c12b1d

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

Diff for: pytest_mpl/plugin.py

+7-2
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
from pytest_mpl.summary.html import generate_summary_basic_html, generate_summary_html
4646

4747
DEFAULT_STYLE = "classic"
48-
DEFAULT_TOLERANCE: float = 2
48+
DEFAULT_TOLERANCE = 2
4949
DEFAULT_BACKEND = "agg"
5050

5151
SUPPORTED_FORMATS = {"html", "json", "basic-html"}
@@ -230,7 +230,12 @@ def get_cli_or_ini(name, default=None):
230230
hash_library = get_cli_or_ini("mpl-hash-library")
231231
_hash_library_from_cli = bool(config.getoption("--mpl-hash-library")) # for backwards compatibility
232232

233-
default_tolerance = float(get_cli_or_ini("mpl-default-tolerance", DEFAULT_TOLERANCE))
233+
default_tolerance = get_cli_or_ini("mpl-default-tolerance", DEFAULT_TOLERANCE)
234+
if isinstance(default_tolerance, str):
235+
if default_tolerance.isdigit(): # prefer int if possible
236+
default_tolerance = int(default_tolerance)
237+
else:
238+
default_tolerance = float(default_tolerance)
234239
default_style = get_cli_or_ini("mpl-default-style", DEFAULT_STYLE)
235240
default_backend = get_cli_or_ini("mpl-default-backend", DEFAULT_BACKEND)
236241

0 commit comments

Comments
 (0)