@@ -781,13 +781,29 @@ def validate_cycler(s):
781
781
else :
782
782
raise ValueError ("object was not a string or Cycler instance: %s" % s )
783
783
784
- unknowns = cycler_inst .keys - (set (_prop_validators .keys ()) |
785
- set (_prop_aliases .keys ()))
784
+ unknowns = cycler_inst .keys - (set (_prop_validators ) | set (_prop_aliases ))
786
785
if unknowns :
787
786
raise ValueError ("Unknown artist properties: %s" % unknowns )
788
787
789
788
# Not a full validation, but it'll at least normalize property names
790
789
# A fuller validation would require v0.10 of cycler.
790
+ checker = set ()
791
+ for prop in cycler_inst .keys :
792
+ norm_prop = _prop_aliases .get (prop , prop )
793
+ if norm_prop != prop and norm_prop in cycler_inst .keys :
794
+ raise ValueError ("Cannot specify both '{0}' and alias '{1}'"
795
+ " in the same prop_cycle" .format (norm_prop , prop ))
796
+ if norm_prop in checker :
797
+ raise ValueError ("Another property was already aliased to '{0}'."
798
+ " Collision normalizing '{1}'." .format (norm_prop ,
799
+ prop ))
800
+ checker .update ([norm_prop ])
801
+
802
+ # This is just an extra-careful check, just in case there is some
803
+ # edge-case I haven't thought of.
804
+ assert len (checker ) == len (cycler_inst .keys )
805
+
806
+ # Now, it should be safe to mutate this cycler
791
807
for prop in cycler_inst .keys :
792
808
norm_prop = _prop_aliases .get (prop , prop )
793
809
cycler_inst .change_key (prop , norm_prop )
0 commit comments