File tree Expand file tree Collapse file tree 1 file changed +18
-10
lines changed
Expand file tree Collapse file tree 1 file changed +18
-10
lines changed Original file line number Diff line number Diff line change @@ -860,14 +860,18 @@ def set_weight(self, weight):
860860 """
861861 if weight is None :
862862 weight = rcParams ['font.weight' ]
863+ if weight in weight_dict :
864+ self ._weight = weight
865+ return
863866 try :
864867 weight = int (weight )
865- if weight < 0 or weight > 1000 :
866- raise ValueError ()
867868 except ValueError :
868- if weight not in weight_dict :
869- raise ValueError ("weight is invalid" )
870- self ._weight = weight
869+ pass
870+ else :
871+ if 0 <= weight <= 1000 :
872+ self ._weight = weight
873+ return
874+ raise ValueError (f"{ weight = } is invalid" )
871875
872876 def set_stretch (self , stretch ):
873877 """
@@ -882,14 +886,18 @@ def set_stretch(self, stretch):
882886 """
883887 if stretch is None :
884888 stretch = rcParams ['font.stretch' ]
889+ if stretch in stretch_dict :
890+ self ._stretch = stretch
891+ return
885892 try :
886893 stretch = int (stretch )
887- if stretch < 0 or stretch > 1000 :
888- raise ValueError ()
889894 except ValueError as err :
890- if stretch not in stretch_dict :
891- raise ValueError ("stretch is invalid" ) from err
892- self ._stretch = stretch
895+ pass
896+ else :
897+ if 0 <= stretch <= 1000 :
898+ self ._stretch = stretch
899+ return
900+ raise ValueError (f"{ stretch = } is invalid" )
893901
894902 def set_size (self , size ):
895903 """
You can’t perform that action at this time.
0 commit comments