From 4238a8aef5d2ca66ddea05bcf1730a47930bcd9b Mon Sep 17 00:00:00 2001 From: KV Date: Tue, 10 Oct 2023 22:30:38 +0200 Subject: [PATCH] Avoid wrong function name in warnings --- src/wireviz/wv_graphviz.py | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/src/wireviz/wv_graphviz.py b/src/wireviz/wv_graphviz.py index e1c5d036..3355548e 100644 --- a/src/wireviz/wv_graphviz.py +++ b/src/wireviz/wv_graphviz.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- import re +import warnings from itertools import zip_longest from typing import Any, List, Optional, Tuple, Union @@ -580,15 +581,9 @@ def typecheck(name: str, value: Any, expect: type) -> None: f'( +)?{attr}=("[^"]*"|[^] ]*)(?(1)| *)', "", entry ) if n_subs < 1: - print( - "Harness.create_graph() warning: " - f"{attr} not found in {keyword}!" - ) + warnings.warn(f"tweak: {attr} not found in {keyword}!") elif n_subs > 1: - print( - "Harness.create_graph() warning: " - f"{attr} removed {n_subs} times in {keyword}!" - ) + warnings.warn(f"tweak: {attr} removed {n_subs} times in {keyword}!") continue if len(value) == 0 or " " in value: @@ -601,10 +596,7 @@ def typecheck(name: str, value: Any, expect: type) -> None: # If attr not found, then append it entry = re.sub(r"\]$", f" {attr}={value}]", entry) elif n_subs > 1: - print( - "Harness.create_graph() warning: " - f"{attr} overridden {n_subs} times in {keyword}!" - ) + warnings.warn(f"tweak: {attr} overridden {n_subs} times in {keyword}!") dot.body[i] = entry