33Arc."""
44
55# External dependencies
6- from __future__ import division , absolute_import , print_function
6+ from __future__ import annotations
77import re
88try :
99 from collections .abc import MutableSequence # noqa
4040except NameError :
4141 pass
4242
43+
4344COMMANDS = set ('MmZzLlHhVvCcSsQqTtAa' )
4445UPPERCASE = set ('MZLHVCSQTA' )
4546
@@ -602,15 +603,15 @@ def __init__(self, start, end):
602603 self .start = start
603604 self .end = end
604605
605- def __hash__ (self ):
606+ def __hash__ (self ) -> int :
606607 return hash ((self .start , self .end ))
607608
608609 def __repr__ (self ):
609610 return 'Line(start=%s, end=%s)' % (self .start , self .end )
610611
611612 def __eq__ (self , other ):
612613 if not isinstance (other , Line ):
613- return NotImplemented
614+ return False
614615 return self .start == other .start and self .end == other .end
615616
616617 def __ne__ (self , other ):
@@ -874,7 +875,7 @@ def __init__(self, start, control, end):
874875 # used to know if self._length needs to be updated
875876 self ._length_info = {'length' : None , 'bpoints' : None }
876877
877- def __hash__ (self ):
878+ def __hash__ (self ) -> int :
878879 return hash ((self .start , self .control , self .end ))
879880
880881 def __repr__ (self ):
@@ -883,7 +884,7 @@ def __repr__(self):
883884
884885 def __eq__ (self , other ):
885886 if not isinstance (other , QuadraticBezier ):
886- return NotImplemented
887+ return False
887888 return self .start == other .start and self .end == other .end \
888889 and self .control == other .control
889890
@@ -1145,7 +1146,7 @@ def __init__(self, start, control1, control2, end):
11451146 self ._length_info = {'length' : None , 'bpoints' : None , 'error' : None ,
11461147 'min_depth' : None }
11471148
1148- def __hash__ (self ):
1149+ def __hash__ (self ) -> int :
11491150 return hash ((self .start , self .control1 , self .control2 , self .end ))
11501151
11511152 def __repr__ (self ):
@@ -1154,7 +1155,7 @@ def __repr__(self):
11541155
11551156 def __eq__ (self , other ):
11561157 if not isinstance (other , CubicBezier ):
1157- return NotImplemented
1158+ return False
11581159 return self .start == other .start and self .end == other .end \
11591160 and self .control1 == other .control1 \
11601161 and self .control2 == other .control2
@@ -1493,8 +1494,12 @@ def __init__(self, start, radius, rotation, large_arc, sweep, end,
14931494 # Derive derived parameters
14941495 self ._parameterize ()
14951496
1496- def __hash__ (self ):
1497- return hash ((self .start , self .radius , self .rotation , self .large_arc , self .sweep , self .end ))
1497+ def apoints (self ) -> tuple [complex , complex , float , bool , bool , complex ]:
1498+ """Analog of the Bezier path method, .bpoints(), for Arc objects."""
1499+ return self .start , self .radius , self .rotation , self .large_arc , self .sweep , self .end
1500+
1501+ def __hash__ (self ) -> int :
1502+ return hash (self .apoints ())
14981503
14991504 def __repr__ (self ):
15001505 params = (self .start , self .radius , self .rotation ,
@@ -1504,7 +1509,7 @@ def __repr__(self):
15041509
15051510 def __eq__ (self , other ):
15061511 if not isinstance (other , Arc ):
1507- return NotImplemented
1512+ return False
15081513 return self .start == other .start and self .end == other .end \
15091514 and self .radius == other .radius \
15101515 and self .rotation == other .rotation \
@@ -2494,8 +2499,13 @@ def __init__(self, *segments, **kw):
24942499 if 'tree_element' in kw :
24952500 self ._tree_element = kw ['tree_element' ]
24962501
2497- def __hash__ (self ):
2498- return hash ((tuple (self ._segments ), self ._closed ))
2502+ def __hash__ (self ) -> int :
2503+
2504+ def _pointify (segment ):
2505+ return segment .apoints () if isinstance (segment , Arc ) else segment .bpoints ()
2506+
2507+ pts = tuple (x for segment in self ._segments for x in _pointify (segment ))
2508+ return hash (pts + (self ._closed ,))
24992509
25002510 def __getitem__ (self , index ):
25012511 return self ._segments [index ]
@@ -2543,7 +2553,7 @@ def __repr__(self):
25432553
25442554 def __eq__ (self , other ):
25452555 if not isinstance (other , Path ):
2546- return NotImplemented
2556+ return False
25472557 if len (self ) != len (other ):
25482558 return False
25492559 for s , o in zip (self ._segments , other ._segments ):
0 commit comments