index
int64
0
731k
package
stringlengths
2
98
name
stringlengths
1
76
docstring
stringlengths
0
281k
code
stringlengths
4
8.19k
signature
stringlengths
2
42.8k
embed_func_code
listlengths
768
768
727,786
fysom
_enter_state
Executes the callback for onenter_state_ or on_state_.
def _enter_state(self, e): ''' Executes the callback for onenter_state_ or on_state_. ''' for fnname in ['onenter' + e.dst, 'on' + e.dst, 'on_enter_' + e.dst, 'on_' + e.dst]: if hasattr(self, fnname): return getattr(self, fnname)(e)
(self, e)
[ -0.03722880035638809, -0.017423734068870544, 0.02108662575483322, 0.0013599509838968515, -0.0034152152948081493, -0.021559257060289383, 0.03664710000157356, -0.000887319736648351, -0.0023143026046454906, -0.034211233258247375, -0.02675820142030716, 0.005862445570528507, 0.012497461400926113,...
727,787
fysom
_is_base_string
Returns if the object is an instance of basestring.
def _is_base_string(self, object): # pragma: no cover ''' Returns if the object is an instance of basestring. ''' try: return isinstance(object, basestring) except NameError: return isinstance(object, str)
(self, object)
[ -0.0011986924801021814, -0.00918255653232336, -0.016652392223477364, -0.007660609669983387, 0.008533927612006664, -0.05701155215501785, 0.07454574108123779, 0.05222950130701065, 0.018704265356063843, -0.052059926092624664, 0.023265868425369263, 0.05918212980031967, -0.02845490351319313, 0....
727,788
fysom
_leave_state
Checks to see if the machine can leave the current state and perform the transition. This is helpful if the asynchronous job needs to be completed before the machine can leave the current state.
def _leave_state(self, e): ''' Checks to see if the machine can leave the current state and perform the transition. This is helpful if the asynchronous job needs to be completed before the machine can leave the current state. ''' for fnname in ['onleave' + e.src, 'on_leave_' + e.src]...
(self, e)
[ 0.020934568718075752, 0.04712512344121933, -0.025010641664266586, 0.0333951935172081, -0.046159740537405014, -0.07197486609220505, 0.0034011967945843935, 0.025225171819329262, 0.029909079894423485, -0.06979381293058395, -0.03164319694042206, 0.019414979964494705, 0.0071197194047272205, 0.0...
727,789
fysom
_reenter_state
Executes the callback for onreenter_state_. This allows callbacks following reflexive transitions (i.e. where src == dst)
def _reenter_state(self, e): ''' Executes the callback for onreenter_state_. This allows callbacks following reflexive transitions (i.e. where src == dst) ''' for fnname in ['onreenter' + e.dst, 'on_reenter_' + e.dst]: if hasattr(self, fnname): return getattr(self, fnname...
(self, e)
[ -0.0443744994699955, 0.007377120666205883, 0.008089683018624783, 0.011317173950374126, -0.0355815663933754, -0.028632914647459984, 0.024776693433523178, 0.02535419538617134, 0.03394220769405365, -0.04008980840444565, -0.02744065225124359, 0.007754359859973192, 0.03016049973666668, 0.042623...
727,790
fysom
can
Returns if the given event be fired in the current machine state.
def can(self, event): ''' Returns if the given event be fired in the current machine state. ''' return ( event in self._map and ((self.current in self._map[event]) or WILDCARD in self._map[event]) and not hasattr(self, 'transition'))
(self, event)
[ 0.043858423829078674, 0.02058268152177334, -0.01313304528594017, 0.03383813798427582, -0.02974608540534973, -0.017347510904073715, 0.03198447450995445, 0.0007317388080991805, 0.0005541323334909976, -0.006688934285193682, -0.028032317757606506, 0.019830722361803055, 0.04046586900949478, 0.0...
727,791
fysom
cannot
Returns if the given event cannot be fired in the current state.
def cannot(self, event): ''' Returns if the given event cannot be fired in the current state. ''' return not self.can(event)
(self, event)
[ 0.003772506956011057, 0.040284983813762665, 0.022533992305397987, 0.05389295518398285, -0.03546830266714096, -0.02760329842567444, 0.012395380064845085, 0.011485936120152473, 0.033076804131269455, -0.03011268936097622, 0.0056882333010435104, 0.03233577311038971, 0.007608169689774513, -0.01...
727,792
fysom
is_finished
Returns if the state machine is in its final state.
def is_finished(self): ''' Returns if the state machine is in its final state. ''' return self._final and (self.current == self._final)
(self)
[ 0.04502817615866661, 0.05055181682109833, -0.05044693872332573, 0.05995599552989006, -0.004446445032954216, -0.03628823533654213, 0.007245411165058613, 0.03730206936597824, 0.026237303391098976, -0.0250836294144392, 0.00625342782586813, 0.0235454011708498, 0.01106476504355669, 0.0322154238...
727,793
fysom
isstate
Returns if the given state is the current state.
def isstate(self, state): ''' Returns if the given state is the current state. ''' return self.current == state
(self, state)
[ 0.035296835005283356, -0.027166269719600677, 0.0283955130726099, 0.03268030285835266, -0.027254072949290276, -0.02516436018049717, 0.016945991665124893, 0.032908592373132706, 0.01471579447388649, -0.029659876599907875, -0.047238051891326904, 0.0033540772274136543, -0.0007397408480755985, 0...
727,795
fysom
trigger
Triggers the given event. The event can be triggered by calling the event handler directly, for ex: fsm.eat() but this method will come in handy if the event is determined dynamically and you have the event name to trigger as a string.
def trigger(self, event, *args, **kwargs): ''' Triggers the given event. The event can be triggered by calling the event handler directly, for ex: fsm.eat() but this method will come in handy if the event is determined dynamically and you have the event name to trigger as a string. ...
(self, event, *args, **kwargs)
[ 0.042153991758823395, -0.013260943815112114, 0.02170930616557598, 0.007451596204191446, -0.003234001575037837, -0.04239989072084427, -0.0015719926450401545, 0.055818911641836166, -0.0016235873335972428, 0.017915446311235428, -0.032019469887018204, 0.016422493383288383, 0.03758731111884117, ...
727,796
fysom
FysomError
Raised whenever an unexpected event gets triggered. Optionally the event object can be attached to the exception in case of sharing event data.
class FysomError(Exception): ''' Raised whenever an unexpected event gets triggered. Optionally the event object can be attached to the exception in case of sharing event data. ''' def __init__(self, msg, event=None): super(FysomError, self).__init__(msg) self.event...
(msg, event=None)
[ 0.005847188178449869, -0.006686388980597258, 0.00064867950277403, 0.05472496151924133, -0.01558645348995924, -0.05824507027864456, -0.0128012141212821, 0.051313724368810654, 0.040753405541181564, -0.005239334423094988, 0.05817249044775963, 0.004014554899185896, 0.06136598810553551, 0.00030...
727,798
fysom
FysomGlobal
Target to be used as global machine.
class FysomGlobal(object): ''' Target to be used as global machine. ''' def __init__(self, cfg={}, initial=None, events=None, callbacks=None, final=None, state_field=None, **kwargs): ''' Construct a Global Finite State Machine. Takes same arguments as Fysom...
(cfg={}, initial=None, events=None, callbacks=None, final=None, state_field=None, **kwargs)
[ 0.023080483078956604, 0.008144808001816273, -0.047514908015728, 0.007626502308994532, -0.024667134508490562, -0.04908040538430214, -0.03816424310207367, 0.02295355126261711, -0.02193809486925602, -0.03640834987163544, -0.008044320158660412, 0.033446602523326874, 0.03723340854048729, 0.0275...
727,799
fysom
__init__
Construct a Global Finite State Machine. Takes same arguments as Fysom and an additional state_field to specify which field holds the state to be processed. Difference with Fysom: 1. Initial state will only be automatically triggered for class derived with FysomG...
def __init__(self, cfg={}, initial=None, events=None, callbacks=None, final=None, state_field=None, **kwargs): ''' Construct a Global Finite State Machine. Takes same arguments as Fysom and an additional state_field to specify which field holds the state to be processed. Difference with...
(self, cfg={}, initial=None, events=None, callbacks=None, final=None, state_field=None, **kwargs)
[ 0.04311532527208328, 0.0034590954892337322, -0.022873571142554283, 0.010749803856015205, -0.02475067414343357, -0.044431235641241074, -0.04474085941910744, 0.014213738031685352, -0.016719767823815346, -0.003057550173252821, 0.0032389711122959852, 0.027653411030769348, 0.011011051014065742, ...
727,800
fysom
_after_event
null
def _after_event(self, obj, e): callbacks = ['onafter' + e.event, 'on' + e.event, 'on_after_' + e.event, 'on_' + e.event] return self._do_callbacks(obj, callbacks, e)
(self, obj, e)
[ -0.023831766098737717, 0.07675874978303909, -0.07368840277194977, 0.04382559284567833, 0.0014129549963399768, -0.047115255147218704, 0.0032097038347274065, 0.05851941183209419, -0.0003243971150368452, -0.031251776963472366, -0.023393142968416214, -0.00384022225625813, 0.018860721960663795, ...
727,801
fysom
_apply
null
def _apply(self, cfg): def add(e): if 'src' in e: src = [e['src']] if self._is_base_string( e['src']) else e['src'] else: src = [WILDCARD] _e = {'src': set(src), 'dst': e['dst']} conditions = e.get('cond') if conditions: _e[...
(self, cfg)
[ 0.0335550531744957, -0.0445026233792305, -0.039328768849372864, -0.009593183174729347, -0.06557294726371765, -0.005904939491301775, -0.004510717466473579, -0.008716815151274204, 0.02637539617717266, -0.01695561222732067, -0.01953316479921341, 0.057624708861112595, 0.03289894759654999, 0.02...
727,802
fysom
_before_event
null
def _before_event(self, obj, e): callbacks = ['onbefore' + e.event, 'on_before_' + e.event] return self._do_callbacks(obj, callbacks, e)
(self, obj, e)
[ -0.05430927127599716, 0.05641625449061394, -0.038361601531505585, 0.030496746301651, -0.01602941006422043, -0.011243291199207306, 0.05725178122520447, 0.061066146939992905, 0.011188800446689129, -0.021160636097192764, 0.008132767863571644, -0.02106981910765171, 0.026755036786198616, -0.065...
727,803
fysom
_build_event
null
def _build_event(self, event): def fn(obj, *args, **kwargs): if not self.can(obj, event): raise FysomError( 'event %s inappropriate in current state %s' % (event, self.current(obj))) # Prepare the event object with all the meta data to pas through. ...
(self, event)
[ -0.00716432137414813, 0.007272499147802591, -0.0033928495831787586, -0.0036436254158616066, -0.014269636943936348, -0.05369553342461586, -0.018026357516646385, 0.008870580233633518, -0.019275318831205368, -0.03733117878437042, -0.020652128383517265, 0.07454434782266617, 0.04598540440201759, ...
727,804
fysom
_change_state
null
def _change_state(self, obj, e): callbacks = ['onchangestate', 'on_change_state'] return self._do_callbacks(obj, callbacks, e)
(self, obj, e)
[ -0.041465990245342255, 0.006072484888136387, 0.009225231595337391, 0.02788492664694786, -0.04781903326511383, -0.0364253968000412, 0.03020549938082695, 0.0519275926053524, 0.02495567686855793, -0.06505214422941208, -0.032716285437345505, 0.02524099312722683, 0.026515407487750053, 0.0122781...
727,805
fysom
_check_condition
null
def _check_condition(self, obj, func, target, e): if callable(func): return func(e) is target return self._do_callbacks(obj, [func], e) is target
(self, obj, func, target, e)
[ 0.014547234401106834, -0.002696909010410309, -0.008291656151413918, 0.04993746802210808, -0.04193604364991188, -0.017038749530911446, 0.061153750866651535, 0.023843534290790558, -0.0037462031468749046, -0.044436488300561905, 0.047472741454839706, 0.009483832865953445, 0.08508658409118652, ...
727,806
fysom
_do_callbacks
null
def _do_callbacks(self, obj, callbacks, *args, **kwargs): for cb in callbacks: if cb in self._callbacks: return self._callbacks[cb](*args, **kwargs) if hasattr(obj, cb): return getattr(obj, cb)(*args, **kwargs)
(self, obj, callbacks, *args, **kwargs)
[ -0.00588487833738327, -0.014079708606004715, -0.06559531390666962, 0.003066186560317874, -0.05041562393307686, -0.0009716465719975531, 0.025556137785315514, 0.0626620352268219, 0.03996584191918373, 0.015573844313621521, 0.006004042457789183, 0.02740776725113392, 0.0671352818608284, -0.0753...
727,807
fysom
_enter_state
null
def _enter_state(self, obj, e): callbacks = ['onenter' + e.dst, 'on' + e.dst, 'on_enter_' + e.dst, 'on_' + e.dst] return self._do_callbacks(obj, callbacks, e)
(self, obj, e)
[ -0.07216966152191162, 0.020655211061239243, -0.016833115369081497, 0.0026613445952534676, 0.007498547900468111, -0.02259715460240841, 0.02526291273534298, 0.018201300874352455, -0.02408009208738804, -0.02759324386715889, -0.03172428533434868, -0.0015050057554617524, 0.0056625292636454105, ...
727,808
fysom
_is_base_string
null
@staticmethod def _is_base_string(object): # pragma: no cover try: return isinstance(object, basestring) # noqa except NameError: return isinstance(object, str) # noqa
(object)
[ -0.013111211359500885, -0.021149281412363052, -0.02415620908141136, -0.01400992926210165, -0.00830684695392847, -0.06514449417591095, 0.07828090339899063, 0.058525893837213516, 0.017671996727585793, -0.05899624899029732, 0.020494142547249794, 0.05966819077730179, -0.01520262099802494, 0.00...
727,809
fysom
_leave_state
null
def _leave_state(self, obj, e): callbacks = ['onleave' + e.src, 'on_leave_' + e.src] return self._do_callbacks(obj, callbacks, e)
(self, obj, e)
[ -0.020285440608859062, 0.06997772306203842, -0.02570897713303566, 0.01140175573527813, -0.03715475648641586, -0.07895825803279877, -0.01022196002304554, 0.05666540563106537, 0.0374717153608799, -0.05719367042183876, -0.06571637094020844, 0.015522236004471779, 0.01922890730202198, -0.000406...
727,810
fysom
_reenter_state
null
def _reenter_state(self, obj, e): callbacks = ['onreenter' + e.dst, 'on_reenter_' + e.dst] return self._do_callbacks(obj, callbacks, e)
(self, obj, e)
[ -0.04966482147574425, 0.04146561026573181, -0.0058649638667702675, 0.00260740309022367, -0.02215954102575779, -0.0439940020442009, 0.007160764187574387, 0.03151458874344826, 0.027559461072087288, -0.04522207751870155, -0.03635464981198311, -0.0046323733404278755, 0.026493925601243973, 0.01...
727,811
fysom
can
null
def can(self, obj, event): if event not in self._map or hasattr(obj, 'transition'): return False src = self._map[event]['src'] return self.current(obj) in src or WILDCARD in src
(self, obj, event)
[ 0.034537963569164276, -0.0021859193220734596, -0.053457848727703094, 0.024265671148896217, -0.018832536414265633, -0.007040363736450672, 0.053213272243738174, 0.00897952076047659, 0.001920595532283187, 0.006402713246643543, -0.024946996942162514, 0.011512654833495617, 0.050033751875162125, ...
727,812
fysom
cannot
null
def cannot(self, obj, event): return not self.can(obj, event)
(self, obj, event)
[ 0.012907163240015507, 0.056251611560583115, -0.0034904174972325563, 0.051189977675676346, -0.030656620860099792, -0.047545600682497025, 0.02709660679101944, 0.027653386816382408, 0.016627462580800056, -0.0017367727123200893, 0.004323477856814861, 0.04174159839749336, 0.006900692358613014, ...
727,813
fysom
current
null
def current(self, obj): return getattr(obj, self.state_field) or 'none'
(self, obj)
[ 0.05724231153726578, -0.011133351363241673, 0.03309538960456848, 0.028394833207130432, -0.010950552299618721, -0.058600250631570816, 0.06253478676080704, 0.009157377295196056, 0.038509730249643326, -0.04359329491853714, -0.049965158104896545, 0.01405814103782177, -0.030901795253157616, -0....
727,814
fysom
is_finished
null
def is_finished(self, obj): return self._final and (self.current(obj) == self._final)
(self, obj)
[ 0.036462072283029556, 0.0544278658926487, -0.08593873679637909, 0.054251037538051605, 0.022899312898516655, -0.04459619149565697, 0.016993235796689987, 0.06726562976837158, 0.01609141007065773, -0.01777128130197525, 0.008147381246089935, 0.008116436190903187, 0.031457822769880295, -0.01467...
727,815
fysom
isstate
null
def isstate(self, obj, state): return self.current(obj) == state
(self, obj, state)
[ 0.039205241948366165, -0.018365036696195602, 0.001589889987371862, 0.02883482351899147, -0.011680271476507187, -0.033658694475889206, 0.022168124094605446, 0.042276620864868164, 0.003728562965989113, -0.03134612739086151, -0.050334472209215164, 0.02449875883758068, 0.006982869002968073, 0....
727,817
fysom
trigger
null
def trigger(self, obj, event, *args, **kwargs): if not hasattr(self, event): raise FysomError( "There isn't any event registered as %s" % event) return getattr(self, event)(obj, *args, **kwargs)
(self, obj, event, *args, **kwargs)
[ 0.03709573671221733, -0.008234764449298382, -0.008536036126315594, -0.0028162370435893536, 0.00851857103407383, -0.06378231197595596, 0.020032396540045738, 0.0683581531047821, -0.010522684082388878, 0.026232484728097916, -0.029865210875868797, 0.007322216406464577, 0.048587728291749954, -0...
727,818
fysom
FysomGlobalMixin
null
class FysomGlobalMixin(object): GSM = None # global state machine instance, override this def __init__(self, *args, **kwargs): super(FysomGlobalMixin, self).__init__(*args, **kwargs) if self.is_state('none'): _initial = self.GSM._initial if _initial and not _initial.get...
(*args, **kwargs)
[ 0.05437843129038811, -0.004049038048833609, -0.018867773935198784, 0.030395159497857094, -0.006166626233607531, -0.03738516941666603, -0.04593435674905777, -0.0017277940642088652, 0.003094262210652232, 0.008579843677580357, -0.002864327747374773, -0.004997244570404291, 0.029151322320103645, ...
727,819
fysom
__getattribute__
Proxy public event methods to global machine if available.
def __getattribute__(self, attr): ''' Proxy public event methods to global machine if available. ''' try: return super(FysomGlobalMixin, self).__getattribute__(attr) except AttributeError as err: if not attr.startswith('_'): gsm_attr = getattr(self.GSM, attr) ...
(self, attr)
[ 0.046183571219444275, -0.0010260683484375477, 0.02203090861439705, 0.05969209223985672, -0.025231225416064262, -0.05467059835791588, 0.004902142100036144, 0.011059657670557499, 0.038191623985767365, 0.021606557071208954, 0.004473370499908924, -0.014092001132667065, 0.05866657570004463, 0.0...
727,820
fysom
__init__
null
def __init__(self, *args, **kwargs): super(FysomGlobalMixin, self).__init__(*args, **kwargs) if self.is_state('none'): _initial = self.GSM._initial if _initial and not _initial.get('defer'): self.trigger(_initial['event'])
(self, *args, **kwargs)
[ 0.023334823548793793, 0.022770414128899574, 0.036757197231054306, 0.012284735217690468, -0.025151517242193222, -0.014489461667835712, 0.0014077178202569485, 0.017011668533086777, 0.006728824693709612, 0.0022774823009967804, -0.005644099321216345, 0.03472885116934776, 0.009877174161374569, ...
727,831
fysom
_weak_callback
Store a weak reference to a callback or method.
def _weak_callback(func): ''' Store a weak reference to a callback or method. ''' if isinstance(func, types.MethodType): # Don't hold a reference to the object, otherwise we might create # a cycle. # Reference: http://stackoverflow.com/a/6975682 # Tell coveralls to not co...
(func)
[ 0.0385526679456234, -0.005031012464314699, 0.00011726647790055722, 0.07087646424770355, -0.0754099041223526, 0.011527100577950478, 0.03553037345409393, 0.037778668105602264, 0.06158844009041786, -0.04644011706113815, 0.00288868579082191, -0.03680194914340973, 0.003121347166597843, -0.04021...
727,836
nibe_mqtt.config
Config
null
class Config: def __init__(self): self._data = None def load(self, config_file: Path) -> dict: assert config_file.is_file(), f"{config_file} should be a file" with config_file.open("r", encoding="utf-8") as fh: self._data = schema(yaml.safe_load(fh)) return self._da...
()
[ 0.050805531442165375, -0.03557123988866806, -0.033250175416469574, -0.014709288254380226, 0.006829641759395599, 0.0037210723385214806, 0.010813215747475624, -0.009113864041864872, 0.037634409964084625, -0.024684341624379158, -0.004117127042263746, -0.02630540356040001, -0.02142379805445671, ...
727,837
nibe_mqtt.config
__init__
null
def __init__(self): self._data = None
(self)
[ 0.0067870779894292355, 0.014197856187820435, -0.019993076100945473, 0.021483028307557106, -0.02565835975110531, -0.01106202695518732, -0.01895357482135296, 0.05408872291445732, 0.04857936501502991, -0.011616428382694721, -0.014925507828593254, 0.016328833997249603, -0.02955649048089981, 0....
727,838
nibe_mqtt.config
get
null
def get(self): assert self._data is not None, "Not yet loaded" return self._data
(self)
[ 0.027619538828730583, -0.012978783808648586, -0.04101809859275818, 0.019361089915037155, 0.07244131714105606, 0.010554364882409573, 0.03622065857052803, -0.02580336481332779, 0.08820433169603348, -0.019395358860492706, -0.005782626569271088, -0.03543251007795334, -0.012104964815080166, -0....
727,839
nibe_mqtt.config
load
null
def load(self, config_file: Path) -> dict: assert config_file.is_file(), f"{config_file} should be a file" with config_file.open("r", encoding="utf-8") as fh: self._data = schema(yaml.safe_load(fh)) return self._data
(self, config_file: pathlib.Path) -> dict
[ 0.006044153589755297, -0.023487981408834457, -0.007779696024954319, -0.016108438372612, -0.02814090996980667, 0.02484663762152195, -0.005490455310791731, 0.017318198457360268, -0.013949478976428509, -0.02382299304008484, -0.01944923959672451, -0.006802581250667572, -0.03311023861169815, 0....
727,841
captionizer.captionizer
caption_from_path
null
def caption_from_path(file_path, base_path, class_token=None, token=None): # Prefer OrderedDict - key order in regular dict is only guaranteed # from Python 3.7 onward. tokens = OrderedDict([('S', token), ('C', class_token)]) return generic_captions_from_path(file_path, base_path, tokens)
(file_path, base_path, class_token=None, token=None)
[ -0.0070249526761472225, -0.06453578174114227, -0.032754167914390564, 0.03053119033575058, -0.013928336091339588, 0.001338344649411738, 0.022785507142543793, 0.04300069808959961, 0.09524063766002655, 0.023080745711922646, 0.06943327188491821, 0.04894021153450012, -0.022577103227376938, -0.0...
727,843
captionizer.finder
find_images
null
def find_images(root_folder, glob_pattern="**/*.*"): return list(glob.glob(f'{root_folder}{os.path.sep}{glob_pattern}', recursive=True))
(root_folder, glob_pattern='**/*.*')
[ -0.0008475081995129585, -0.06830546259880066, -0.03387421742081642, 0.013194582425057888, -0.0037990997079759836, 0.022107018157839775, 0.03114130347967148, -0.0408022440969944, 0.04393552243709564, 0.03798229247331619, 0.04034965857863426, 0.0357193723320961, -0.007097745314240456, -0.004...
727,845
captionizer.captionizer
generic_captions_from_path
null
def generic_captions_from_path(file_path, base_path, tokens): rel_path = os.path.relpath(file_path, base_path) parent_path = os.path.dirname(rel_path) caption = 'broken caption' if parent_path == '': caption = token_caption(tokens, rel_path) else: caption = path_caption(rel_path, tok...
(file_path, base_path, tokens)
[ -0.03266642615199089, -0.06883282214403152, -0.014397620223462582, 0.05709553509950638, -0.023792752996087074, 0.016969570890069008, 0.03461085632443428, 0.05391374230384827, 0.06699445098638535, -0.011153957806527615, 0.060842983424663544, 0.07127220183610916, -0.04341382160782814, -0.050...
727,846
typeapi.typehint
AnnotatedTypeHint
Represents the `Annotated` type hint.
class AnnotatedTypeHint(TypeHint): """Represents the `Annotated` type hint.""" @property def args(self) -> Tuple[Any, ...]: return (self._args[0],) def _copy_with_args(self, args: "Tuple[Any, ...]") -> "TypeHint": assert len(args) == 1 new_hint = Annotated[args + (self._args[1:...
(hint: object, source: 'Any | None' = None) -> 'TypeHint'
[ 0.0048043932765722275, -0.00902199000120163, 0.022903386503458023, 0.010782378725707531, 0.04815395548939705, 0.01072736643254757, 0.031026843935251236, -0.034419260919094086, 0.039718762040138245, -0.0418458990752697, 0.02264666184782982, 0.036803118884563446, 0.018181510269641876, -0.026...
727,847
typeapi.typehint
__eq__
null
def __eq__(self, other: object) -> bool: if type(self) != type(other): return False assert isinstance(other, TypeHint) return (self.hint, self.origin, self.args, self.parameters) == ( other.hint, other.origin, other.args, other.parameters, )
(self, other: object) -> bool
[ 0.036488328129053116, -0.016230080276727676, 0.012870264239609241, 0.02590310014784336, -0.03706636279821396, -0.042015768587589264, -0.006692537572234869, 0.028775202110409737, 0.013791504316031933, -0.008643398992717266, 0.026553386822342873, -0.05881484970450401, 0.04085970297455788, 0....
727,848
typeapi.typehint
__getitem__
null
def __getitem__(self, index: "int | slice") -> "TypeHint | List[TypeHint]": if isinstance(index, int): try: return TypeHint(self.args[index]) except IndexError: raise IndexError(f"TypeHint index {index} out of range [0..{len(self.args)}[") else: return [TypeHint(x...
(self, index: int | slice) -> Union[typeapi.typehint.TypeHint, List[typeapi.typehint.TypeHint]]
[ -0.02925277128815651, -0.03843509405851364, -0.018963489681482315, -0.058324072510004044, -0.006714345887303352, 0.02041524089872837, 0.025714129209518433, -0.023899441584944725, 0.06536506116390228, -0.05160972848534584, 0.009599699638783932, 0.055384278297424316, -0.03872544318437576, -0...
727,849
typeapi.typehint
__init__
null
def __init__(self, hint: object, source: "Any | None" = None) -> None: self._hint = hint self._origin = get_type_hint_origin_or_none(hint) self._args = get_type_hint_args(hint) self._parameters = get_type_hint_parameters(hint) self._source = source
(self, hint: object, source: Optional[Any] = None) -> NoneType
[ -0.01378800068050623, -0.013030619360506535, 0.058145031332969666, 0.002504835370928049, -0.013614624738693237, 0.005315361078828573, 0.011470230296254158, 0.06004304811358452, 0.03879985585808754, -0.048289939761161804, 0.021790700033307076, 0.05099096521735191, -0.0029405581299215555, -0...
727,850
typeapi.typehint
__iter__
null
def __iter__(self) -> Iterator["TypeHint"]: for i in range(len(self.args)): yield self[i]
(self) -> Iterator[typeapi.typehint.TypeHint]
[ 0.004796528723090887, -0.04338657855987549, -0.031846459954977036, -0.03508267179131508, -0.03143748641014099, 0.04054155573248863, 0.0117446044459939, 0.002596082165837288, 0.0815809965133667, -0.007459290791302919, 0.020839782431721687, 0.03563389554619789, -0.022262293845415115, 0.03335...
727,852
typeapi.typehint
__repr__
null
def __repr__(self) -> str: return f"TypeHint({type_repr(self._hint)})"
(self) -> str
[ 0.00658815260976553, -0.03422325849533081, 0.08671765774488449, 0.011147154495120049, 0.03578684478998184, -0.035224657505750656, 0.03211504966020584, -0.022241603583097458, 0.0425858199596405, -0.0900907963514328, -0.00530126690864563, 0.01885090209543705, -0.03485571965575218, 0.01635618...
727,853
typeapi.typehint
_copy_with_args
null
def _copy_with_args(self, args: "Tuple[Any, ...]") -> "TypeHint": assert len(args) == 1 new_hint = Annotated[args + (self._args[1:])] # type: ignore return AnnotatedTypeHint(new_hint)
(self, args: Tuple[Any, ...]) -> typeapi.typehint.TypeHint
[ -0.06708977371454239, -0.003023512428626418, 0.044332921504974365, 0.0019903299398720264, -0.026818018406629562, -0.006802903022617102, 0.04626511037349701, 0.024492239579558372, 0.0652291551232338, -0.044511828571558, 0.016835059970617294, 0.025619348511099815, -0.03807121142745018, -0.00...
727,854
typeapi.typehint
evaluate
Evaluate forward references in the type hint using the given *context*. This method supports evaluating forward references that use PEP585 and PEP604 syntax even in older versions of Python that do not support the PEPs. :param context: An object that supports `__getitem__()` to retrie...
def evaluate(self, context: "HasGetitem[str, Any] | None" = None) -> "TypeHint": """ Evaluate forward references in the type hint using the given *context*. This method supports evaluating forward references that use PEP585 and PEP604 syntax even in older versions of Python that do not support the PEPs....
(self, context: Optional[typeapi.utils.HasGetitem[str, Any]] = None) -> typeapi.typehint.TypeHint
[ 0.03804119676351547, -0.041940055787563324, 0.012780603021383286, -0.041794303804636, 0.041684988886117935, 0.014830236323177814, 0.05873794108629227, -0.012899026274681091, 0.06354774534702301, -0.049009013921022415, 0.036929838359355927, -0.0033044645097106695, -0.0003023209283128381, 0....
727,855
typeapi.typehint
get_context
Return the context for this type hint in which forward references must be evaluated. The context is derived from the `source` attribute, which can be either a `ModuleType`, `Mapping` or `type`. In case of a `type`, the context is composed of the class scope (to resolve class-level members) and ...
def get_context(self) -> HasGetitem[str, Any]: """Return the context for this type hint in which forward references must be evaluated. The context is derived from the `source` attribute, which can be either a `ModuleType`, `Mapping` or `type`. In case of a `type`, the context is composed of the class scope ...
(self) -> typeapi.utils.HasGetitem[str, typing.Any]
[ 0.029365116730332375, -0.01157645508646965, 0.03176151588559151, -0.011189344339072704, 0.03878481313586235, 0.028590895235538483, 0.06341242790222168, -0.012074168771505356, 0.07314550131559372, -0.044573038816452026, 0.023595323786139488, -0.05662877485156059, 0.02807474695146084, 0.0113...
727,856
typeapi.typehint
parameterize
Replace references to the type variables in the keys of *parameter_map* with the type hints of the associated values. :param parameter_map: A dictionary that maps :class:`TypeVar` to other type hints.
def parameterize(self, parameter_map: Mapping[object, Any]) -> "TypeHint": """ Replace references to the type variables in the keys of *parameter_map* with the type hints of the associated values. :param parameter_map: A dictionary that maps :class:`TypeVar` to other type hints. """ if s...
(self, parameter_map: Mapping[object, Any]) -> typeapi.typehint.TypeHint
[ 0.04461245238780975, -0.00949710514396429, 0.019263561815023422, -0.006708826869726181, -0.027034826576709747, 0.021687718108296394, 0.0133577985689044, 0.012799144722521305, -0.002962857484817505, -0.024700455367565155, -0.030626168474555016, 0.02645622193813324, -0.022126659750938416, 0....
727,857
typeapi.typehint
ClassTypeHint
Represents a real, possibly parameterized, type. For example `int`, `list`, `list[int]` or `list[T]`.
class ClassTypeHint(TypeHint): """Represents a real, possibly parameterized, type. For example `int`, `list`, `list[int]` or `list[T]`.""" def __init__(self, hint: object, source: "Any | None" = None) -> None: super().__init__(hint, source) assert isinstance(self.hint, type) or isinstance(self....
(hint: object, source: 'Any | None' = None) -> 'TypeHint'
[ 0.005635036155581474, 0.009609656408429146, -0.015327713452279568, 0.028766702860593796, -0.006086461711674929, 0.05371445044875145, -0.016614535823464394, -0.021751446649432182, 0.04703127592802048, -0.04719731956720352, 0.002952426904812455, 0.03202527016401291, -0.0003609458508435637, -...
727,860
typeapi.typehint
__init__
null
def __init__(self, hint: object, source: "Any | None" = None) -> None: super().__init__(hint, source) assert isinstance(self.hint, type) or isinstance(self.origin, type), ( "ClassTypeHint must be initialized from a real type or a generic that points to a real type. " f'Got "{self.hint!r}" with o...
(self, hint: object, source: Optional[Any] = None) -> NoneType
[ -0.018005259335041046, -0.0009079158771783113, 0.04482298344373703, 0.0068551707081496716, -0.0329122394323349, 0.006182640325278044, 0.0036316635087132454, 0.060332924127578735, 0.04511982575058937, -0.04456324875354767, 0.02588082104921341, 0.04771718382835388, 0.0010899628978222609, -0....
727,862
typeapi.typehint
__len__
null
def __len__(self) -> int: return len(self.args)
(self) -> int
[ -0.025920787826180458, -0.030778875574469566, 0.003662093309685588, 0.01872422732412815, 0.01966290920972824, 0.02196844294667244, 0.022561294957995415, 0.005018652882426977, 0.05312608554959297, -0.0257067009806633, 0.01038313563913107, -0.016764523461461067, -0.01355324499309063, -0.0167...
727,864
typeapi.typehint
_copy_with_args
Internal. Create a copy of this type hint with updated type arguments.
def _copy_with_args(self, args: "Tuple[Any, ...]") -> "TypeHint": """ Internal. Create a copy of this type hint with updated type arguments. """ generic = get_subscriptable_type_hint_from_origin(self.origin) try: new_hint = generic[args] except TypeError as exc: raise TypeError(f...
(self, args: Tuple[Any, ...]) -> typeapi.typehint.TypeHint
[ -0.05216260254383087, 0.013964209705591202, 0.026229070499539375, -0.00019697778043337166, -0.03553854301571846, 0.014324397780001163, 0.0339684933423996, 0.02750358171761036, 0.047766461968421936, -0.04366586357355118, 0.004460789263248444, 0.03535383194684982, -0.04699067398905754, -0.02...
727,867
typeapi.typehint
get_parameter_map
Returns a dictionary that maps generic parameters to their values. >>> TypeHint(List[int]).type <class 'list'> >>> TypeHint(List[int]).args (<class 'int'>,) # NOTE(@niklas): This is a bug for built-in types, but it's not that big of a deal because w...
def get_parameter_map(self) -> Dict[Any, Any]: """ Returns a dictionary that maps generic parameters to their values. >>> TypeHint(List[int]).type <class 'list'> >>> TypeHint(List[int]).args (<class 'int'>,) # NOTE(@niklas): This is a bug for built-in types, but it's not ...
(self) -> Dict[Any, Any]
[ 0.02438923344016075, 0.028361955657601357, 0.009711666032671928, 0.0018366157310083508, -0.007249192800372839, 0.05279214307665825, 0.019218552857637405, -0.033747654408216476, 0.016689525917172432, -0.022116180509328842, 0.003977840766310692, -0.004814877174794674, -0.0418364442884922, -0...
727,868
typeapi.typehint
parameterize
null
def parameterize(self, parameter_map: Mapping[object, Any]) -> "TypeHint": if self.type is Generic: # type: ignore[comparison-overlap] return self return super().parameterize(parameter_map)
(self, parameter_map: Mapping[object, Any]) -> typeapi.typehint.TypeHint
[ 0.056742679327726364, -0.021471219137310982, 0.017306705936789513, 0.023783793672919273, -0.036869581788778305, -0.0017450066516175866, 0.007581672165542841, -0.005443010479211807, 0.002022327622398734, -0.04331846907734871, 0.015332556329667568, 0.022636907175183296, -0.0220352616161108, ...
727,869
typeapi.typehint
recurse_bases
Iterate over all base classes of this type hint, and continues recursively. The iteration order is determined by the *order* parameter, which can be either depth-first or breadh-first. If the generator receives the string `"skip"` from the caller, it will skip the bases of the last yielded type...
def recurse_bases( self, order: Literal["dfs", "bfs"] = "bfs" ) -> Generator["ClassTypeHint", Union[Literal["skip"], None], None]: """ Iterate over all base classes of this type hint, and continues recursively. The iteration order is determined by the *order* parameter, which can be either depth-first o...
(self, order: Literal['dfs', 'bfs'] = 'bfs') -> Generator[typeapi.typehint.ClassTypeHint, Optional[Literal['skip']], NoneType]
[ -0.03918427973985672, -0.02254665642976761, -0.02921278588473797, 0.02775399200618267, -0.04394843801856041, 0.03700532391667366, -0.01972139999270439, -0.012805983424186707, 0.03624822944402695, -0.048047829419374466, 0.04930349811911583, 0.034087736159563065, 0.010146918706595898, -0.019...
727,870
typeapi.typehint
ForwardRefTypeHint
Represents a forward reference, i.e. a string in the type annotation or an explicit `ForwardRef`.
class ForwardRefTypeHint(TypeHint): """Represents a forward reference, i.e. a string in the type annotation or an explicit `ForwardRef`.""" def __init__(self, hint: object, source: "Any | None") -> None: super().__init__(hint, source) if isinstance(self._hint, str): self._forward_re...
(hint: object, source: 'Any | None' = None) -> 'TypeHint'
[ 0.006933426018804312, -0.01126279216259718, -0.02329852059483528, 0.00008346163667738438, 0.021623823791742325, 0.0672822967171669, 0.03975103050470352, -0.017657922580838203, 0.03169040381908417, -0.05502573028206825, 0.042879581451416016, 0.0027167804073542356, 0.011520436964929104, -0.0...
727,873
typeapi.typehint
__init__
null
def __init__(self, hint: object, source: "Any | None") -> None: super().__init__(hint, source) if isinstance(self._hint, str): self._forward_ref = ForwardRef(self._hint) elif isinstance(self._hint, ForwardRef): self._forward_ref = self._hint else: raise TypeError( f"F...
(self, hint: object, source: Optional[Any]) -> NoneType
[ -0.030937086790800095, -0.0036990982480347157, 0.009519103914499283, -0.017294250428676605, -0.043126627802848816, 0.021599644795060158, 0.024905899539589882, 0.07266491651535034, 0.04995713010430336, -0.05740528181195259, 0.02988344617187977, 0.0032199639827013016, -0.0022719139233231544, ...
727,878
typeapi.typehint
evaluate
null
def evaluate(self, context: "HasGetitem[str, Any] | None" = None) -> TypeHint: from .future.fake import FakeProvider if context is None: context = self.get_context() hint = FakeProvider(context).execute(self.expr).evaluate() return TypeHint(hint).evaluate(context)
(self, context: Optional[typeapi.utils.HasGetitem[str, Any]] = None) -> typeapi.typehint.TypeHint
[ 0.07375002652406693, -0.0855785384774208, 0.051945675164461136, -0.00809647049754858, 0.06124459207057953, -0.005174972116947174, 0.049522966146469116, -0.023158222436904907, 0.026364745572209358, -0.047064632177352905, 0.048917289823293686, 0.041043493896722794, -0.009094055742025375, -0....
727,880
typeapi.typehint
parameterize
null
def parameterize(self, parameter_map: Mapping[object, Any]) -> TypeHint: raise RuntimeError( "ForwardRef cannot be parameterized. Ensure that your type hint is fully " "evaluated before parameterization." )
(self, parameter_map: Mapping[object, Any]) -> typeapi.typehint.TypeHint
[ 0.0339951328933239, -0.012648489326238632, -0.0196033027023077, 0.01218483503907919, -0.04951827600598335, 0.038538943976163864, 0.02281179092824459, 0.015244953334331512, 0.011517172679305077, -0.04547521099448204, -0.0004743762838188559, -0.002019214443862438, -0.022014304995536804, 0.00...
727,881
typeapi.typehint
LiteralTypeHint
Represents a literal type hint, e.g. `Literal["a", 42]`.
class LiteralTypeHint(TypeHint): """Represents a literal type hint, e.g. `Literal["a", 42]`.""" @property def args(self) -> Tuple[Any, ...]: return () def parameterize(self, parameter_map: Mapping[object, Any]) -> "TypeHint": return self def __len__(self) -> int: return 0 ...
(hint: object, source: 'Any | None' = None) -> 'TypeHint'
[ -0.002313749399036169, -0.0375811830163002, 0.05166710913181305, -0.043099574744701385, 0.02721782959997654, 0.038497794419527054, 0.0004489538841880858, -0.01690124347805977, 0.04841219633817673, -0.0937565341591835, 0.012972896918654442, 0.05671784281730652, -0.008291617035865784, -0.012...
727,891
typeapi.typehint
parameterize
null
def parameterize(self, parameter_map: Mapping[object, Any]) -> "TypeHint": return self
(self, parameter_map: Mapping[object, Any]) -> typeapi.typehint.TypeHint
[ 0.056057821959257126, -0.031060049310326576, 0.020706700161099434, -0.0018727786373347044, -0.035771097987890244, 0.012918862514197826, 0.0037387097254395485, 0.010234660468995571, 0.0008724797517061234, -0.04561317339539528, 0.006144448649138212, 0.032831259071826935, -0.032429542392492294,...
727,892
typeapi.typehint
TupleTypeHint
A special class to represent a type hint for a parameterized tuple. This class does not represent a plain tuple type without parameterization.
class TupleTypeHint(ClassTypeHint): """ A special class to represent a type hint for a parameterized tuple. This class does not represent a plain tuple type without parameterization. """ def __init__(self, hint: object, source: "Any | None") -> None: super().__init__(hint, source) i...
(hint: object, source: 'Any | None' = None) -> 'TypeHint'
[ -0.01082641165703535, -0.009331825189292431, 0.013759537599980831, 0.00450711278244853, 0.028247686102986336, -0.012535844929516315, 0.007407544646412134, 0.015833277255296707, 0.009939000941812992, -0.0554865263402462, 0.0019814949482679367, 0.05264681205153465, -0.0249782782047987, -0.01...
727,895
typeapi.typehint
__init__
null
def __init__(self, hint: object, source: "Any | None") -> None: super().__init__(hint, source) if self._args == ((),): self._args = () elif self._args == () and self._hint == tuple: raise ValueError("TupleTypeHint can only represent a parameterized tuple.") if ... in self._args: ...
(self, hint: object, source: Optional[Any]) -> NoneType
[ -0.022049451246857643, -0.01463938970118761, 0.02992561273276806, -0.0077382349409163, -0.01372621115297079, -0.015961594879627228, 0.006687128450721502, 0.07172254472970963, 0.037915922701358795, -0.04725697636604309, 0.01456329133361578, 0.055856071412563324, -0.020489437505602837, -0.00...
727,899
typeapi.typehint
_copy_with_args
null
def _copy_with_args(self, args: "Tuple[Any, ...]") -> "TypeHint": if self._repeated: args = args + (...,) return super()._copy_with_args(args)
(self, args: Tuple[Any, ...]) -> typeapi.typehint.TypeHint
[ -0.08382201194763184, 0.004542878828942776, 0.0005531283095479012, 0.01655271276831627, -0.04724772274494171, 0.001762227970175445, 0.03020581044256687, 0.022823352366685867, 0.0887317880988121, -0.04870642349123955, 0.0009606087696738541, 0.011002528481185436, -0.06247514858841896, 0.0067...
727,905
typeapi.typehint
TypeHint
Base class that provides an object-oriented interface to a Python type hint.
class TypeHint(object, metaclass=_TypeHintMeta): """ Base class that provides an object-oriented interface to a Python type hint. """ def __init__(self, hint: object, source: "Any | None" = None) -> None: self._hint = hint self._origin = get_type_hint_origin_or_none(hint) self._...
(hint: object, source: 'Any | None' = None) -> 'TypeHint'
[ 0.0028356064576655626, -0.004118380602449179, -0.008787264116108418, 0.013866427354514599, 0.03672785311937332, 0.0448295883834362, 0.006616414990276098, -0.01329515129327774, 0.03041265718638897, -0.05060466751456261, 0.001567114028148353, 0.01274464838206768, 0.020991796627640724, 0.0120...
727,916
typeapi.typehint
TypeVarTypeHint
Represents a `TypeVar` type hint.
class TypeVarTypeHint(TypeHint): """Represents a `TypeVar` type hint.""" @property def hint(self) -> TypeVar: assert isinstance(self._hint, TypeVar) return self._hint def parameterize(self, parameter_map: Mapping[object, Any]) -> "TypeHint": return TypeHint(parameter_map.get(se...
(hint: object, source: 'Any | None' = None) -> 'TypeHint'
[ 0.021375566720962524, -0.024225642904639244, 0.019856777042150497, -0.030113298445940018, 0.05265139788389206, 0.05392643064260483, -0.013425356708467007, -0.04057607799768448, 0.02791949175298214, -0.07507698982954025, 0.000931079383008182, 0.033657144755125046, 0.007017373573035002, -0.0...
727,924
typeapi.typehint
evaluate
null
def evaluate(self, context: "HasGetitem[str, Any] | None" = None) -> TypeHint: return self
(self, context: Optional[typeapi.utils.HasGetitem[str, Any]] = None) -> typeapi.typehint.TypeHint
[ 0.04202090576291084, -0.07273687422275543, 0.03078867308795452, -0.03269706293940544, 0.04100309684872627, 0.0004841968766413629, 0.05437999218702316, -0.006970162969082594, 0.06942900270223618, -0.04758249595761299, 0.041475649923086166, 0.013467772863805294, -0.016094079241156578, 0.0141...
727,926
typeapi.typehint
parameterize
null
def parameterize(self, parameter_map: Mapping[object, Any]) -> "TypeHint": return TypeHint(parameter_map.get(self.hint, self.hint))
(self, parameter_map: Mapping[object, Any]) -> typeapi.typehint.TypeHint
[ 0.07265856117010117, -0.026424653828144073, 0.04959704354405403, -0.004379470832645893, -0.014644432812929153, 0.0056036897003650665, 0.04035765305161476, -0.004166964907199144, -0.011512279510498047, -0.04712088778614998, 0.0009470374207012355, 0.0371977835893631, -0.03612601384520531, -0...
727,927
typeapi.utils
TypedDictProtocol
A protocol that describes #typing.TypedDict values (which are actually instances of the #typing._TypedDictMeta metaclass). Use #is_typed_dict() to check if a hint is matches this protocol.
class TypedDictProtocol(Protocol): """A protocol that describes #typing.TypedDict values (which are actually instances of the #typing._TypedDictMeta metaclass). Use #is_typed_dict() to check if a hint is matches this protocol.""" __annotations__: Dict[str, Any] __required_keys__: Set[str] __optiona...
(*args, **kwargs)
[ 0.013592085801064968, 0.022837601602077484, -0.05824403092265129, -0.01298537664115429, 0.010196328163146973, 0.014678727835416794, -0.028397588059306145, 0.009825058281421661, 0.021406855434179306, -0.03256304934620857, 0.026677070185542107, 0.026731403544545174, -0.003511213231831789, 0....
727,929
typeapi.typehint
UnionTypeHint
Represents a union of types, e.g. `typing.Union[A, B]` or `A | B`.
class UnionTypeHint(TypeHint): """Represents a union of types, e.g. `typing.Union[A, B]` or `A | B`.""" def has_none_type(self) -> bool: return NoneType in self._args def without_none_type(self) -> TypeHint: args = tuple(x for x in self._args if x is not NoneType) if len(args) == 1...
(hint: object, source: 'Any | None' = None) -> 'TypeHint'
[ -0.04199118912220001, -0.005644077435135841, 0.032730069011449814, 0.007810584735125303, -0.054971639066934586, 0.01032113004475832, -0.012989746406674385, -0.017927151173353195, 0.00035159254912286997, -0.027113886550068855, 0.0036984048783779144, -0.030833212658762932, -0.02763459272682666...
727,939
typeapi.typehint
has_none_type
null
def has_none_type(self) -> bool: return NoneType in self._args
(self) -> bool
[ -0.0012166701490059495, -0.010607561096549034, 0.021215122193098068, 0.02009758912026882, 0.004310166463255882, 0.03723911941051483, 0.0008809593273326755, 0.009760398417711258, -0.00362072023563087, 0.006430326960980892, -0.0015602668281644583, -0.0315432995557785, 0.04405247047543526, -0...
727,941
typeapi.typehint
without_none_type
null
def without_none_type(self) -> TypeHint: args = tuple(x for x in self._args if x is not NoneType) if len(args) == 1: return TypeHint(args[0]) else: return self._copy_with_args(args)
(self) -> typeapi.typehint.TypeHint
[ -0.017526349052786827, -0.0003015353577211499, 0.05148651823401451, -0.017563072964549065, -0.04935654625296593, 0.002928708912804723, 0.027983399108052254, -0.00575642753392458, 0.016415458172559738, -0.03005828522145748, -0.013652006164193153, 0.02001437358558178, -0.056003522127866745, ...
727,943
typeapi.utils
get_annotations
Like #typing.get_type_hints(), but always includes extras. This is important when we want to inspect #typing.Annotated hints (without extras the annotations are removed). In Python 3.10 and onwards, this is an alias for #inspect.get_annotations() with `eval_str=True`. If *include_bases* is set to `True`, a...
def get_annotations( obj: Union[Callable[..., Any], ModuleType, type], include_bases: bool = False, globalns: Optional[Dict[str, Any]] = None, localns: Optional[Dict[str, Any]] = None, eval_str: bool = True, ) -> Dict[str, Any]: """Like #typing.get_type_hints(), but always includes extras. This ...
(obj: Union[Callable[..., Any], module, type], include_bases: bool = False, globalns: Optional[Dict[str, Any]] = None, localns: Optional[Dict[str, Any]] = None, eval_str: bool = True) -> Dict[str, Any]
[ -0.005458510015159845, 0.003958010580390692, -0.031475044786930084, 0.016134504228830338, 0.019083518534898758, 0.02979259565472603, 0.052250463515520096, 0.006640005856752396, -0.02240115776658058, -0.02092665061354637, 0.0025189488660544157, -0.0053214565850794315, 0.046276822686195374, ...
727,944
typeapi.utils
is_typed_dict
Returns: `True` if *hint* is a #typing.TypedDict. !!! note Typed dictionaries are actually just type objects. This means #typeapi.of() will represent them as #typeapi.models.Type.
def is_typed_dict(hint: Any) -> TypeGuard[TypedDictProtocol]: """ Returns: `True` if *hint* is a #typing.TypedDict. !!! note Typed dictionaries are actually just type objects. This means #typeapi.of() will represent them as #typeapi.models.Type. """ import typing impo...
(hint: Any) -> TypeGuard[typeapi.utils.TypedDictProtocol]
[ 0.021887091919779778, 0.028233055025339127, -0.05646611005067825, -0.005444020964205265, 0.012201637960970402, 0.035615090280771255, -0.004838102031499147, 0.04836251959204674, -0.007465293165296316, -0.008533746004104614, 0.020629001781344414, 0.03703969344496727, 0.015337616205215454, -0...
727,945
typeapi.utils
type_repr
#typing._type_repr() stolen from Python 3.8.
def type_repr(obj: Any) -> str: """#typing._type_repr() stolen from Python 3.8.""" if (getattr(obj, "__module__", None) or getattr(type(obj), "__module__", None)) in TYPING_MODULE_NAMES or hasattr( obj, "__args__" ): # NOTE(NiklasRosenstein): In Python 3.6, List[int] is actually a "type" su...
(obj: Any) -> str
[ 0.016944998875260353, -0.0028281714767217636, 0.006819329224526882, -0.0034384990576654673, 0.036619652062654495, -0.051171399652957916, 0.051286738365888596, -0.01699305698275566, 0.01804070547223091, -0.04056034982204437, -0.018636615946888924, -0.032486725598573685, -0.02053007297217846, ...
727,948
builtins
dict
dict() -> new empty dictionary dict(mapping) -> new dictionary initialized from a mapping object's (key, value) pairs dict(iterable) -> new dictionary initialized as if via: d = {} for k, v in iterable: d[k] = v dict(**kwargs) -> new dictionary initialized with the name=value pairs in the keywor...
dict[str, str]
null
[ 0.053469039499759674, 0.015185696072876453, 0.0061896792612969875, -0.03696322813630104, -0.013944263570010662, -0.0005155334365554154, 0.016505811363458633, 0.028413075953722, 0.09232064336538315, -0.03577424958348274, -0.02276543155312538, 0.06091763451695442, -0.005262976046651602, 0.01...
727,949
mod_wsgi_van.router
Router
Router(base_path: str = '/var/www', venv_name: str = '.venv', wsgi_dir: str = 'wsgi', module_name: str = 'app', object_name: str = 'app', update_interval: float = 1.0)
class Router: base_path: str = "/var/www" venv_name: str = ".venv" wsgi_dir: str = "wsgi" module_name: str = "app" object_name: str = "app" update_interval: float = 1.0 def __post_init__(self) -> None: self.servers: dict[str, Server] = {} self.stop_watcher = threading.Event(...
(base_path: str = '/var/www', venv_name: str = '.venv', wsgi_dir: str = 'wsgi', module_name: str = 'app', object_name: str = 'app', update_interval: float = 1.0) -> None
[ 0.09855016320943832, -0.022334424778819084, -0.11171083152294159, 0.0015712964814156294, 0.019624875858426094, -0.013963853940367699, 0.009096343070268631, 0.056087661534547806, -0.0684741735458374, -0.012454248033463955, -0.008051231503486633, -0.028314786031842232, 0.012618755921721458, ...
727,950
mod_wsgi_van.router
__eq__
null
import atexit import dataclasses import os import pathlib import threading import time import typing from .server import Server, Environ, StartResponse, Response @dataclasses.dataclass class Router: base_path: str = "/var/www" venv_name: str = ".venv" wsgi_dir: str = "wsgi" module_name: str = "app" ...
(self, other)
[ 0.0890314131975174, -0.017796389758586884, -0.11166518181562424, -0.008472822606563568, 0.015946514904499054, -0.01023861300200224, 0.0052429609932005405, 0.04637547582387924, -0.0645378828048706, -0.028865963220596313, -0.005057478789240122, -0.027382105588912964, 0.01352288294583559, -0....
727,952
mod_wsgi_van.router
__post_init__
null
def __post_init__(self) -> None: self.servers: dict[str, Server] = {} self.stop_watcher = threading.Event() self.watcher = threading.Thread( target=self.poll_server_paths, daemon=True, ) self.watcher.start() atexit.register(self.shutdown)
(self) -> NoneType
[ 0.06628735363483429, 0.02456829510629177, -0.08582620322704315, 0.022216396406292915, -0.025490961968898773, 0.0006642983062192798, 0.020805256441235542, 0.07359633594751358, -0.0464952252805233, 0.02290387451648712, -0.015468256548047066, 0.050909560173749924, -0.03748564422130585, -0.043...
727,954
mod_wsgi_van.router
application
null
def application(self, environ: Environ, start_response: StartResponse) -> Response: start_time = time.perf_counter() server = self.get_server(environ) with server.time("serve", start_time): # Drain the generator to time the response yield from server.serve(environ, start_response)
(self, environ: dict[str, str], start_response: Callable) -> Generator
[ 0.03987239673733711, -0.05626077950000763, -0.09566493332386017, 0.0059565468691289425, 0.0442306250333786, 0.011606937274336815, -0.014596466906368732, 0.034577686339616776, -0.07556665688753128, -0.00867143552750349, 0.02501479536294937, 0.041349150240421295, 0.04415858909487724, 0.02768...
727,955
mod_wsgi_van.router
get_server
null
def get_server(self, environ: Environ) -> Server: host_name = environ["HTTP_HOST"] # Lazy load and cache WSGI servers on request if host_name not in self.servers: path = self.get_server_path(host_name) server = Server( host_name=host_name, script_name=environ["mod_wsg...
(self, environ: dict[str, str]) -> mod_wsgi_van.server.Server
[ 0.07865157723426819, -0.02915467508137226, -0.09110600501298904, -0.0023694070987403393, 0.003023972036316991, -0.009392712265253067, 0.10605131089687347, 0.030060451477766037, -0.0576300211250782, 0.0036042348947376013, -0.022361353039741516, 0.04185441508889198, -0.0365707203745842, -0.0...
727,956
mod_wsgi_van.router
get_server_path
null
def get_server_path(self, host_name: str) -> pathlib.Path: return pathlib.Path(self.base_path, host_name)
(self, host_name: str) -> pathlib.Path
[ 0.048640891909599304, -0.00044929911382496357, -0.024918777868151665, 0.047127462923526764, -0.03706140071153641, -0.0581086166203022, 0.036216698586940765, 0.0792614221572876, 0.0009838385740295053, 0.007193185389041901, 0.02444363199174404, -0.008385450579226017, -0.010242040269076824, -...
727,957
mod_wsgi_van.router
get_venv_paths
null
def get_venv_paths(self, path: pathlib.Path) -> list[pathlib.Path]: venv_path = path / self.venv_name return list(venv_path.glob("lib/python*/site-packages"))
(self, path: pathlib.Path) -> list[pathlib.Path]
[ 0.053818006068468094, -0.04505093768239021, -0.005682017188519239, -0.018897080793976784, -0.012367826886475086, 0.009029526263475418, 0.055180951952934265, -0.006828550714999437, 0.033005427569150925, 0.04059373214840889, 0.0019868642557412386, -0.03893609344959259, -0.024422544986009598, ...
727,958
mod_wsgi_van.router
get_version
null
def get_version(self, path: pathlib.Path) -> typing.Any: # Monitor the vhost's WSGI directory wsgi_path = path / self.wsgi_dir # Follow symlink changes hard_path = wsgi_path.resolve(strict=True) # Allow touching to reload like mod_wsgi return os.stat(hard_path).st_mtime
(self, path: pathlib.Path) -> Any
[ 0.10711611062288284, -0.009504519402980804, -0.028531257063150406, 0.07504499703645706, 0.06017759069800377, -0.051788125187158585, 0.019858604297041893, 0.014008988626301289, 0.0008313136058859527, 0.006269973702728748, 0.025699371472001076, -0.03936322405934334, -0.013513408601284027, -0...
727,959
mod_wsgi_van.router
poll_server_paths
null
def poll_server_paths(self): # Update servers when their path changes while not self.stop_watcher.wait(self.update_interval): for server in list(self.servers.values()): try: # Reload modules after a deploy server.update(self.get_version(server.path)) ...
(self)
[ 0.09720025956630707, 0.003338542766869068, -0.09060917794704437, 0.009234748780727386, 0.01011295523494482, -0.0005287912208586931, 0.012792843393981457, 0.04747747257351875, -0.040560465306043625, 0.03259323164820671, -0.044181935489177704, -0.05638628825545311, 0.014848027378320694, -0.0...
727,960
mod_wsgi_van.router
shutdown
null
def shutdown(self): self.stop_watcher.set() self.watcher.join()
(self)
[ 0.06357748061418533, 0.004511022008955479, -0.04874950647354126, 0.007964111864566803, -0.02303752861917019, -0.02373153157532215, 0.011231006123125553, 0.05260884389281273, -0.028183309361338615, 0.047632332891225815, -0.03608817607164383, -0.04637974128127098, 0.02505183033645153, -0.040...
727,961
mod_wsgi_van.server
Server
Server(host_name: str, script_name: str, path: pathlib.Path, venv_paths: list[pathlib.Path], wsgi_dir: str, module_name: str, object_name: str, version: Any, import_cache: dict[str, module] = <factory>)
class Server: host_name: str script_name: str path: pathlib.Path venv_paths: list[pathlib.Path] wsgi_dir: str module_name: str object_name: str version: typing.Any import_cache: dict[str, types.ModuleType] = dataclasses.field(default_factory=dict) def load(self) -> None: ...
(host_name: str, script_name: str, path: pathlib.Path, venv_paths: list[pathlib.Path], wsgi_dir: str, module_name: str, object_name: str, version: Any, import_cache: dict[str, module] = <factory>) -> None
[ 0.0695381835103035, -0.03056790679693222, -0.10774806886911392, 0.01978929713368416, 0.06307481974363327, -0.016319992020726204, 0.00997068826109171, 0.05950096249580383, -0.046346116811037064, -0.024142563343048096, 0.008045936934649944, -0.007950887084007263, -0.022906919941306114, -0.00...
727,962
mod_wsgi_van.server
__eq__
null
import contextlib import dataclasses import importlib import pathlib import sys import time import types import typing Environ = dict[str, str] Response = typing.Generator StartResponse = typing.Callable Handler = typing.Callable[[Environ, StartResponse], Response] @dataclasses.dataclass class Server: host_name...
(self, other)
[ 0.06508961319923401, -0.032389648258686066, -0.11039633303880692, 0.016883347183465958, 0.057409197092056274, -0.012354614213109016, 0.007476772181689739, 0.040380388498306274, -0.04414301738142967, -0.03646259754896164, 0.005648793186992407, -0.0006151851266622543, -0.015535393729805946, ...
727,966
mod_wsgi_van.server
load
null
def load(self) -> None: # Load one module at a time since sys is global self.log("Loading") with self.time("load"), self.environment(): self.module = importlib.import_module(self.module_name) self.handler: Handler = getattr(self.module, self.object_name)
(self) -> NoneType
[ 0.013875662349164486, -0.00857544131577015, -0.07423831522464752, 0.022732842713594437, 0.04874090477824211, 0.00964076817035675, 0.04807177558541298, 0.0529317781329155, -0.1036800742149353, -0.018436318263411522, -0.015390011481940746, -0.017555883154273033, -0.020760666579008102, -0.001...
727,967
mod_wsgi_van.server
log
null
def log(self, message) -> None: print(f"(wsgi:{self.script_name}:{self.host_name}): {message}")
(self, message) -> NoneType
[ 0.016989849507808685, 0.02774825319647789, -0.038964852690696716, 0.06176460534334183, 0.049375031143426895, -0.05941865220665932, -0.019262492656707764, 0.014103224501013756, 0.0017651939997449517, 0.014625566080212593, -0.004907262045890093, -0.007221144158393145, 0.03570250794291496, -0...
727,968
mod_wsgi_van.server
serve
null
def serve(self, environ: Environ, start_response: typing.Callable) -> Response: with self.environment(): yield from self.handler(environ, start_response)
(self, environ: dict[str, str], start_response: Callable) -> Generator
[ 0.02541365846991539, -0.05183003470301628, -0.08236099779605865, -0.019310923293232918, 0.041076771914958954, 0.06379347294569016, 0.0217139832675457, 0.04927137866616249, -0.07669047266244888, 0.02287229336798191, 0.057431410998106, 0.041249655187129974, 0.04235609993338585, 0.02209432423...
727,970
mod_wsgi_van.server
update
null
def update(self, version: typing.Any) -> None: if self.version != version: # Clear import cache and reload self.import_cache = {} self.load() self.version = version
(self, version: Any) -> NoneType
[ 0.06766863912343979, 0.003419981338083744, -0.07609240710735321, 0.04674844816327095, 0.035748813301324844, -0.014924346469342709, -0.03407798334956169, 0.03895123675465584, 0.004986384883522987, 0.016273193061351776, -0.03933413699269295, -0.06728573888540268, -0.024975435808300972, 0.045...
727,973
tables.array
Array
This class represents homogeneous datasets in an HDF5 file. This class provides methods to write or read data to or from array objects in the file. This class does not allow you neither to enlarge nor compress the datasets on disk; use the EArray class (see :ref:`EArrayClassDescr`) if you want enlargea...
class Array(hdf5extension.Array, Leaf): """This class represents homogeneous datasets in an HDF5 file. This class provides methods to write or read data to or from array objects in the file. This class does not allow you neither to enlarge nor compress the datasets on disk; use the EArray class (see :r...
(parentnode, name, obj=None, title='', byteorder=None, _log=True, _atom=None, track_times=True)
[ 0.03211202099919319, -0.016036346554756165, -0.04829585179686546, 0.05616162344813347, 0.015416916459798813, -0.02369564399123192, -0.08156806975603104, 0.013647117651998997, -0.04310443997383118, -0.06866820156574249, -0.005545370280742645, -0.04593611881136894, 0.026389671489596367, 0.01...
727,974
tables.node
__del__
null
def __del__(self): # Closed `Node` instances can not be killed and revived. # Instead, accessing a closed and deleted (from memory, not # disk) one yields a *new*, open `Node` instance. This is # because of two reasons: # # 1. Predictability. After closing a `Node` and deleting it, # on...
(self)
[ 0.04436379298567772, -0.02829131670296192, 0.016354449093341827, 0.008431000635027885, -0.033385634422302246, -0.012904975563287735, -0.06154536083340645, 0.04534129798412323, -0.017360152676701546, -0.026129521429538727, -0.03393078222870827, -0.006029528100043535, 0.04590524360537529, 0....
727,975
tables.array
__getitem__
Get a row, a range of rows or a slice from the array. The set of tokens allowed for the key is the same as that for extended slicing in Python (including the Ellipsis or ... token). The result is an object of the current flavor; its shape depends on the kind of slice used as key and th...
def __getitem__(self, key): """Get a row, a range of rows or a slice from the array. The set of tokens allowed for the key is the same as that for extended slicing in Python (including the Ellipsis or ... token). The result is an object of the current flavor; its shape depends on the kind of slice ...
(self, key)
[ 0.03570917993783951, -0.0614461824297905, -0.05330713093280792, 0.03371107950806618, 0.019981008023023605, 0.008753147907555103, 0.006580900866538286, -0.00007697672117501497, 0.03136468306183815, -0.08168382942676544, 0.01482077594846487, 0.0118236243724823, -0.017634615302085876, -0.0225...
727,976
tables.array
__init__
null
def __init__(self, parentnode, name, obj=None, title="", byteorder=None, _log=True, _atom=None, track_times=True): self._v_version = None """The object version of this array.""" self._v_new = new = obj is not None """Is this the first time the node has been created...
(self, parentnode, name, obj=None, title='', byteorder=None, _log=True, _atom=None, track_times=True)
[ 0.015571906231343746, -0.0007067957194522023, -0.027503136545419693, 0.026069501414895058, -0.011638844385743141, -0.020485874265432358, -0.08714985102415085, 0.0025300809647887945, -0.017505425959825516, -0.03199267387390137, -0.005748683586716652, -0.04327310994267464, 0.012129297479987144...
727,977
tables.array
__iter__
Iterate over the rows of the array. This is equivalent to calling :meth:`Array.iterrows` with default arguments, i.e. it iterates over *all the rows* in the array. Examples -------- :: result = [row[2] for row in array] Which is equivalent to:: ...
def __iter__(self): """Iterate over the rows of the array. This is equivalent to calling :meth:`Array.iterrows` with default arguments, i.e. it iterates over *all the rows* in the array. Examples -------- :: result = [row[2] for row in array] Which is equivalent to:: result =...
(self)
[ 0.030445538461208344, -0.04626580327749252, -0.037490639835596085, 0.01699742116034031, -0.023578794673085213, -0.006055220030248165, -0.03831108286976814, 0.022758351638913155, 0.05011831596493721, -0.023578794673085213, 0.014206134714186192, 0.0005021864199079573, 0.026610862463712692, 0...
727,978
tables.leaf
__len__
Return the length of the main dimension of the leaf data. Please note that this may raise an OverflowError on 32-bit platforms for datasets having more than 2**31-1 rows. This is a limitation of Python that you can work around by using the nrows or shape attributes.
def __len__(self): """Return the length of the main dimension of the leaf data. Please note that this may raise an OverflowError on 32-bit platforms for datasets having more than 2**31-1 rows. This is a limitation of Python that you can work around by using the nrows or shape attributes. """ re...
(self)
[ -0.023364322260022163, -0.007673985790461302, 0.021293431520462036, 0.07588811963796616, 0.005277430638670921, 0.03537214547395706, -0.01925594173371792, 0.003851605812087655, 0.0035071533638983965, -0.03270002827048302, 0.009586218744516373, -0.026787972077727318, -0.01943965069949627, -0...