1616from ..restrictions .packages import AndRestriction as PkgAndRestriction
1717from ..restrictions .packages import Conditional
1818from ..restrictions .values import ContainmentMatch
19- from . import cpv
19+ from . import cpv , errors , restricts
2020from . import eapi as eapi_mod
21- from . import errors , restricts
2221
2322# namespace compatibility...
2423MalformedAtom = errors .MalformedAtom
@@ -95,7 +94,6 @@ def __init__(self, atom: str, negate_vers: bool = False, eapi: str = "-1"):
9594 if not atom :
9695 raise errors .MalformedAtom (atom )
9796
98- sf = object .__setattr__
9997 orig_atom = atom
10098 override_kls = False
10199 use_start = atom .find ("[" )
@@ -116,7 +114,7 @@ def __init__(self, atom: str, negate_vers: bool = False, eapi: str = "-1"):
116114 raise errors .MalformedAtom (orig_atom , "use restriction isn't completed" )
117115 elif use_end != len (atom ) - 1 :
118116 raise errors .MalformedAtom (orig_atom , "trailing garbage after use dep" )
119- sf ( self , " use" , tuple (sorted (atom [use_start + 1 : use_end ].split ("," ) )))
117+ self . use = tuple (sorted (atom [use_start + 1 : use_end ].split ("," )))
120118 for x in self .use :
121119 # stripped purely for validation reasons
122120 try :
@@ -152,10 +150,10 @@ def __init__(self, atom: str, negate_vers: bool = False, eapi: str = "-1"):
152150 except IndexError :
153151 raise errors .MalformedAtom (orig_atom , "empty use dep detected" )
154152 if override_kls :
155- sf ( self , " __class__" , transitive_use_atom )
153+ self . __class__ = transitive_use_atom
156154 atom = atom [0 :use_start ] + atom [use_end + 1 :]
157155 else :
158- sf ( self , " use" , None )
156+ self . use = None
159157 if slot_start != - 1 :
160158 i2 = atom .find ("::" , slot_start )
161159 if i2 != - 1 :
@@ -173,9 +171,9 @@ def __init__(self, atom: str, negate_vers: bool = False, eapi: str = "-1"):
173171 f"repo_id may contain only [a-Z0-9_-/], found { repo_id !r} " ,
174172 )
175173 atom = atom [:i2 ]
176- sf ( self , " repo_id" , repo_id )
174+ self . repo_id = repo_id
177175 else :
178- sf ( self , " repo_id" , None )
176+ self . repo_id = None
179177 # slot dep.
180178 slot = atom [slot_start + 1 :]
181179 slot_operator = subslot = None
@@ -230,17 +228,12 @@ def __init__(self, atom: str, negate_vers: bool = False, eapi: str = "-1"):
230228 if len (slots ) == 2 :
231229 slot , subslot = slots
232230
233- sf (self , "slot_operator" , slot_operator )
234- sf (self , "slot" , slot )
235- sf (self , "subslot" , subslot )
231+ self .slot_operator , self .slot , self .subslot = slot_operator , slot , subslot
236232 atom = atom [:slot_start ]
237233 else :
238- sf (self , "slot_operator" , None )
239- sf (self , "slot" , None )
240- sf (self , "subslot" , None )
241- sf (self , "repo_id" , None )
234+ self .slot_operator = self .slot = self .subslot = self .repo_id = None
242235
243- sf ( self , " blocks" , atom [0 ] == "!" )
236+ self . blocks = atom [0 ] == "!"
244237 if self .blocks :
245238 atom = atom [1 :]
246239 # hackish/slow, but lstrip doesn't take a 'prune this many' arg
@@ -251,32 +244,32 @@ def __init__(self, atom: str, negate_vers: bool = False, eapi: str = "-1"):
251244 f"strong blockers are not supported in EAPI { eapi } "
252245 )
253246 atom = atom [1 :]
254- sf ( self , " blocks_strongly" , True )
247+ self . blocks_strongly = True
255248 else :
256- sf ( self , " blocks_strongly" , False )
249+ self . blocks_strongly = False
257250 else :
258- sf ( self , " blocks_strongly" , False )
251+ self . blocks_strongly = False
259252
260253 if atom [0 ] in ("<" , ">" ):
261254 if atom [1 ] == "=" :
262- sf ( self , "op" , atom [:2 ])
255+ self . op = atom [:2 ]
263256 atom = atom [2 :]
264257 else :
265- sf ( self , "op" , atom [0 ])
258+ self . op = atom [0 ]
266259 atom = atom [1 :]
267260 elif atom [0 ] == "=" :
268261 if atom [- 1 ] == "*" :
269- sf ( self , "op" , "=*" )
262+ self . op = "=*"
270263 atom = atom [1 :- 1 ]
271264 else :
272265 atom = atom [1 :]
273- sf ( self , "op" , "=" )
266+ self . op = "="
274267 elif atom [0 ] == "~" :
275- sf ( self , "op" , "~" )
268+ self . op = "~"
276269 atom = atom [1 :]
277270 else :
278- sf ( self , "op" , "" )
279- sf ( self , " cpvstr" , atom )
271+ self . op = ""
272+ self . cpvstr = atom
280273
281274 if self .slot is not None and not eapi_obj .options .has_slot_deps :
282275 raise errors .MalformedAtom (
@@ -295,7 +288,7 @@ def __init__(self, atom: str, negate_vers: bool = False, eapi: str = "-1"):
295288 orig_atom , f"repo_id atoms aren't supported for EAPI { eapi } "
296289 )
297290 try :
298- sf ( self , " _cpv" , cpv .CPV (self .cpvstr , versioned = bool (self .op ) ))
291+ self . _cpv = cpv .CPV (self .cpvstr , versioned = bool (self .op ))
299292 except errors .InvalidCPV as e :
300293 raise errors .MalformedAtom (orig_atom ) from e
301294
@@ -308,8 +301,9 @@ def __init__(self, atom: str, negate_vers: bool = False, eapi: str = "-1"):
308301 )
309302 elif self .version is not None :
310303 raise errors .MalformedAtom (orig_atom , "versioned atom requires an operator" )
311- sf (self , "_hash" , hash (orig_atom ))
312- sf (self , "negate_vers" , negate_vers )
304+
305+ self ._hash = hash (orig_atom )
306+ self .negate_vers = negate_vers
313307
314308 __getattr__ = klass .GetAttrProxy ("_cpv" )
315309 __dir__ = klass .DirProxy ("_cpv" )
@@ -362,7 +356,7 @@ def cnf_solutions(self, full_solution_expansion=False):
362356 return [[self ]]
363357
364358 @property
365- def is_simple (self ):
359+ def is_simple (self ) -> bool :
366360 return len (self .restrictions ) == 2
367361
368362 @klass .jit_attr
@@ -694,7 +688,7 @@ class transitive_use_atom(atom):
694688 __inst_caching__ = True
695689 _nontransitive_use_atom = atom
696690
697- is_simple = False
691+ is_simple = False # type: ignore
698692
699693 def _stripped_use (self ):
700694 return str (self ).split ("[" , 1 )[0 ]
0 commit comments