Skip to content

Commit

Permalink
Prefer parsing tolerance as int instead of float
Browse files Browse the repository at this point in the history
  • Loading branch information
ConorMacBride committed May 29, 2023
1 parent b066651 commit 8c12b1d
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions pytest_mpl/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
from pytest_mpl.summary.html import generate_summary_basic_html, generate_summary_html

DEFAULT_STYLE = "classic"
DEFAULT_TOLERANCE: float = 2
DEFAULT_TOLERANCE = 2
DEFAULT_BACKEND = "agg"

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

default_tolerance = float(get_cli_or_ini("mpl-default-tolerance", DEFAULT_TOLERANCE))
default_tolerance = get_cli_or_ini("mpl-default-tolerance", DEFAULT_TOLERANCE)
if isinstance(default_tolerance, str):
if default_tolerance.isdigit(): # prefer int if possible
default_tolerance = int(default_tolerance)
else:
default_tolerance = float(default_tolerance)
default_style = get_cli_or_ini("mpl-default-style", DEFAULT_STYLE)
default_backend = get_cli_or_ini("mpl-default-backend", DEFAULT_BACKEND)

Expand Down

0 comments on commit 8c12b1d

Please sign in to comment.