worktoy 1.2.2.dev0__py3-none-any.whl → 1.2.3.dev0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
worktoy/__init__.py CHANGED
@@ -48,7 +48,7 @@ and the enclosing class is left without the decoration.
48
48
  # Copyright (c) 2025-2026 Asger Jon Vistisen
49
49
  from __future__ import annotations
50
50
 
51
- __version__ = '1.2.2-dev0'
51
+ __version__ = '1.2.3-dev0'
52
52
 
53
53
  from . import utilities
54
54
  from . import waitaminute
@@ -63,6 +63,40 @@ def _dropReceiver(func: Method) -> Method:
63
63
  return dropped
64
64
 
65
65
 
66
+ def _passClass(func: Method) -> Method:
67
+ """
68
+ A dispatcher reached through an instance passes that instance ahead of
69
+ the arguments of every call. A classmethod at a name that also holds
70
+ bound methods is reached that way too, and must receive the class of
71
+ the instance, as a classmethod read through an instance does.
72
+
73
+ Implementation
74
+ --------------
75
+
76
+ The wrapper takes the instance by position and calls the function with
77
+ its class in that place; 'functools.wraps' copies the name, docstring
78
+ and attributes.
79
+
80
+ Parameters
81
+ ----------
82
+
83
+ func : Method
84
+ A 'Callable[..., Any]' taking the class first.
85
+
86
+ Returns
87
+ -------
88
+
89
+ Method
90
+ A function taking the instance first and passing on its class.
91
+ """
92
+
93
+ @wraps(func)
94
+ def classed(receiver: Any, *args, **kwargs) -> Any:
95
+ return func(type(receiver), *args, **kwargs)
96
+
97
+ return classed
98
+
99
+
66
100
  def _uniformType(types: tuple) -> Optional[type]:
67
101
  first = types[0]
68
102
  for type_ in types:
@@ -260,6 +294,19 @@ class Dispatcher(Object):
260
294
  function, the fallback and the finalizer behind '_dropReceiver', and a
261
295
  'PermuterMethod' over the wrapped function.
262
296
 
297
+ One name may hold bound methods, classmethods and staticmethods
298
+ together. A dispatcher still binds one receiver, the instance or the
299
+ class, and 'setFunctionKind' names the functions of another kind than
300
+ its own: a staticmethod is registered behind '_dropReceiver', and a
301
+ classmethod in a dispatcher of bound methods behind '_passClass'. A
302
+ name holding bound methods beside another kind takes two dispatchers.
303
+ The one in the class dictionary holds the bound methods and the
304
+ classmethods, and is reached through an instance. It keeps the second,
305
+ given by 'setClassDispatcher', which holds the classmethods and the
306
+ staticmethods, and hands a read through the class on to it. A bound
307
+ method is therefore not considered through the class, nor a
308
+ staticmethod through an instance.
309
+
263
310
  Attributes
264
311
  ----------
265
312
 
@@ -293,6 +340,13 @@ class Dispatcher(Object):
293
340
  __method_kind__ = None
294
341
  # The '_dropReceiver' wrapper of each function, for a staticmethod.
295
342
  __static_adapters__ = None
343
+ # The '_passClass' wrapper of each function, for a classmethod reached
344
+ # through an instance.
345
+ __class_adapters__ = None
346
+ # The functions of another kind than the dispatcher, each with its kind.
347
+ __function_kinds__ = None
348
+ # The dispatcher a read through the class is handed on to.
349
+ __class_dispatcher__ = None
296
350
 
297
351
  # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
298
352
  # GETTERS # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
@@ -564,6 +618,26 @@ class Dispatcher(Object):
564
618
  """
565
619
  return self.__method_kind__
566
620
 
621
+ def _getFunctionKind(self, func: Any) -> Any:
622
+ for held, kind in maybe(self.__function_kinds__, []):
623
+ if held is func:
624
+ return kind
625
+ return self.__method_kind__
626
+
627
+ def getClassDispatcher(self) -> Optional[Self]:
628
+ """
629
+ Code holding the dispatcher of a name with bound methods beside
630
+ another kind may need the dispatcher that answers through the class.
631
+
632
+ Returns
633
+ -------
634
+
635
+ Dispatcher or None
636
+ The dispatcher a read through the class is handed on to, or 'None'
637
+ when this dispatcher answers such a read itself.
638
+ """
639
+ return self.__class_dispatcher__
640
+
567
641
  def _hasRegistrations(self) -> bool:
568
642
  registries = (
569
643
  self._getSigFuncList(),
@@ -943,22 +1017,93 @@ class Dispatcher(Object):
943
1017
  self.__method_kind__ = kind
944
1018
  self.__compiled_func__ = None
945
1019
 
1020
+ def setFunctionKind(self, kind: Any, *funcs) -> None:
1021
+ """
1022
+ One name may hold bound methods, classmethods and staticmethods
1023
+ together, while a dispatcher binds one receiver for every call. The
1024
+ functions of another kind than the dispatcher must be named before
1025
+ they are registered, since a function is wrapped for its kind as it
1026
+ is registered.
1027
+
1028
+ Implementation
1029
+ --------------
1030
+
1031
+ Each function is recorded with the kind, as it will be registered, a
1032
+ 'PermuterMethod' of a flexible declaration included, and found again
1033
+ by identity. The compiled dispatch function is cleared.
1034
+
1035
+ Parameters
1036
+ ----------
1037
+
1038
+ kind : Any
1039
+ 'classmethod' or 'staticmethod'.
1040
+
1041
+ *funcs
1042
+ The functions of that kind.
1043
+
1044
+ Raises
1045
+ ------
1046
+
1047
+ TypeError
1048
+ 'kind' is neither of the two.
1049
+
1050
+ WriteOnceError
1051
+ A function, a fallback or a finalizer is registered already.
1052
+ """
1053
+ if kind is not classmethod and kind is not staticmethod:
1054
+ infoSpec = """The kind of a function named apart from its
1055
+ dispatcher is 'classmethod' or 'staticmethod', not '%s'."""
1056
+ raise TypeError(textFmt(infoSpec % (kind,)))
1057
+ existing = maybe(self.__function_kinds__, [])
1058
+ if self._hasRegistrations():
1059
+ raise WriteOnceError(self, existing, (kind, *funcs))
1060
+ self.__function_kinds__ = [*existing, *((func, kind) for func in funcs)]
1061
+ self.__compiled_func__ = None
1062
+
1063
+ def setClassDispatcher(self, dispatcher: Self) -> None:
1064
+ """
1065
+ A name holding bound methods beside classmethods or staticmethods is
1066
+ two things: through an instance it is the bound methods and the
1067
+ classmethods, through the class the classmethods and the
1068
+ staticmethods. Each is a dispatcher of its own, and the one the class
1069
+ holds must know the other.
1070
+
1071
+ Parameters
1072
+ ----------
1073
+
1074
+ dispatcher : Dispatcher
1075
+ The dispatcher a read through the class is handed on to.
1076
+
1077
+ Raises
1078
+ ------
1079
+
1080
+ TypeException
1081
+ 'dispatcher' is not a 'Dispatcher'.
1082
+ """
1083
+ if not isinstance(dispatcher, Dispatcher):
1084
+ raise TypeException('dispatcher', dispatcher, Dispatcher)
1085
+ self.__class_dispatcher__ = dispatcher
1086
+
946
1087
  def _adaptToKind(self, func: Method) -> Method:
947
1088
  """
948
1089
  The dispatch function passes a receiver ahead of the arguments of every
949
- call, and a staticmethod takes none, so each function of a dispatcher
950
- standing for a staticmethod must be called without it. A function
1090
+ call: the instance, or the class for a dispatcher standing for a
1091
+ classmethod or a staticmethod. A staticmethod takes none, so it must
1092
+ be called without it, and a classmethod in a dispatcher of bound
1093
+ methods must be given the class of the instance. A function
951
1094
  registered under several signatures must still be one function to the
952
1095
  checks comparing registrations.
953
1096
 
954
1097
  Implementation
955
1098
  --------------
956
1099
 
957
- For a staticmethod, a function is wrapped by '_dropReceiver', the
958
- wrapper kept in '__static_adapters__' under the function; a
1100
+ The kind of a function is the one 'setFunctionKind' named for it, or
1101
+ else that of the dispatcher. A staticmethod is wrapped by
1102
+ '_dropReceiver', and a classmethod in a dispatcher of bound methods
1103
+ by '_passClass', each wrapper kept under the function; a
959
1104
  'PermuterMethod' is rebuilt over the wrapped function with the same
960
1105
  arrangement, so it still reorders the arguments after the receiver.
961
- For the other kinds the function is returned as it is.
1106
+ Any other function is returned as it is.
962
1107
 
963
1108
  Parameters
964
1109
  ----------
@@ -972,11 +1117,21 @@ class Dispatcher(Object):
972
1117
  Method
973
1118
  What the dispatcher registers.
974
1119
  """
975
- if self.__method_kind__ is not staticmethod:
1120
+ kind = self._getFunctionKind(func)
1121
+ if kind is staticmethod:
1122
+ wrap = self._dropFor
1123
+ elif kind is classmethod and self.__method_kind__ is None:
1124
+ wrap = self._classFor
1125
+ else:
1126
+ # This branch is reached by the following:
1127
+ # - A bound method
1128
+ # - A classmethod in a dispatcher that binds the class
976
1129
  return func
977
1130
  if isinstance(func, PermuterMethod):
978
- inner = self._adaptToKind(func.__wrapped__)
979
- return PermuterMethod(inner, func.arrangement)
1131
+ return PermuterMethod(wrap(func.__wrapped__), func.arrangement)
1132
+ return wrap(func)
1133
+
1134
+ def _dropFor(self, func: Method) -> Method:
980
1135
  adapters = self.__static_adapters__
981
1136
  if adapters is None:
982
1137
  adapters = dict()
@@ -990,6 +1145,20 @@ class Dispatcher(Object):
990
1145
  adapters[func] = adapted
991
1146
  return adapted
992
1147
 
1148
+ def _classFor(self, func: Method) -> Method:
1149
+ adapters = self.__class_adapters__
1150
+ if adapters is None:
1151
+ adapters = dict()
1152
+ self.__class_adapters__ = adapters
1153
+ try:
1154
+ adapted = adapters[func]
1155
+ except KeyError:
1156
+ # This branch is reached by the following:
1157
+ # - The first registration of the function on this dispatcher
1158
+ adapted = _passClass(func)
1159
+ adapters[func] = adapted
1160
+ return adapted
1161
+
993
1162
  def addSigFunc(
994
1163
  self,
995
1164
  sig: TypeSig,
@@ -1254,8 +1423,9 @@ class Dispatcher(Object):
1254
1423
  Through the class the compiled function is returned, through an
1255
1424
  instance a new 'MethodType' of it on every read. A classmethod or a
1256
1425
  staticmethod gives a new 'MethodType' bound to the class, read through
1257
- either. A dispatcher no class body placed, as one installed with
1258
- 'setattr', has no name to compile with.
1426
+ either. A dispatcher keeping a second one for the class hands a read
1427
+ through the class on to it. A dispatcher no class body placed, as one
1428
+ installed with 'setattr', has no name to compile with.
1259
1429
 
1260
1430
  Parameters
1261
1431
  ----------
@@ -1282,9 +1452,16 @@ class Dispatcher(Object):
1282
1452
  owner = type(instance)
1283
1453
  if self.__method_kind__ is not None:
1284
1454
  return MethodType(self._getCachedFunction(), owner)
1285
- if instance is None:
1455
+ if instance is not None:
1456
+ return MethodType(self._getCachedFunction(), instance)
1457
+ onClass = self.__class_dispatcher__
1458
+ if onClass is None:
1459
+ # This branch is reached by the following:
1460
+ # - Every function at the name is a bound method
1286
1461
  return self._getCachedFunction()
1287
- return MethodType(self._getCachedFunction(), instance)
1462
+ # The rest of the method is reached by the following:
1463
+ # - The name holds bound methods beside classmethods or staticmethods
1464
+ return onClass.__get__(None, owner)
1288
1465
 
1289
1466
  def __set__(self, instance: Any, value: Any, **kwargs) -> Never:
1290
1467
  """
@@ -1334,6 +1511,10 @@ class Dispatcher(Object):
1334
1511
  """
1335
1512
  self.swapAllTHIS(owner)
1336
1513
  Object.__set_name__(self, owner, name, **kwargs)
1514
+ onClass = self.__class_dispatcher__
1515
+ if onClass is not None:
1516
+ # The dispatcher answering through the class is placed with this one.
1517
+ onClass.__set_name__(owner, name, **kwargs)
1337
1518
 
1338
1519
  def __str__(self, ) -> str:
1339
1520
  owner = self.getFieldOwner()
@@ -1426,6 +1607,11 @@ class Dispatcher(Object):
1426
1607
  newLoad.__method_kind__ = self.__method_kind__
1427
1608
  # The wrappers of a staticmethod stay one per function on the copy.
1428
1609
  newLoad.__static_adapters__ = self.__static_adapters__
1610
+ newLoad.__class_adapters__ = self.__class_adapters__
1611
+ newLoad.__function_kinds__ = self.__function_kinds__
1612
+ onClass = self.__class_dispatcher__
1613
+ if onClass is not None:
1614
+ newLoad.__class_dispatcher__ = onClass.clone()
1429
1615
  return newLoad
1430
1616
 
1431
1617
  # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
@@ -1452,6 +1638,9 @@ class Dispatcher(Object):
1452
1638
  for sig, func in self._getVariadicFuncs():
1453
1639
  sig.restoreTHIS()
1454
1640
  self.__compiled_func__ = None
1641
+ onClass = self.__class_dispatcher__
1642
+ if onClass is not None:
1643
+ onClass.restoreTHIS()
1455
1644
 
1456
1645
  def swapAllTHIS(self, thisType: type) -> None:
1457
1646
  """
@@ -71,14 +71,17 @@ class overload: # NOQA
71
71
  raises 'MixedMethodKind'.
72
72
  The namespace of a 'BaseObject' class claims every 'overload' object,
73
73
  so the namespace never stores one, and 'LoadSpaceHook' builds the
74
- 'Dispatcher' of each name, refusing a body that declares one name as
75
- two kinds of method; see 'Dispatcher' for how calls are matched, and
76
- for why the most specific signature is declared first. A subclass
77
- declaring an overload at a name it inherits keeps the inherited
78
- overloads and adds its own, an equal signature replacing the inherited
79
- one. A subclass overloading the name as another kind of method
80
- overrides it as a plain definition does, hiding the inherited
81
- overloads.
74
+ 'Dispatcher' of each name; see 'Dispatcher' for how calls are matched,
75
+ and for why the most specific signature is declared first. One name
76
+ may hold bound methods, classmethods and staticmethods together: the
77
+ classmethods and the staticmethods are reached through the class, the
78
+ bound methods and the classmethods through an instance, and a
79
+ staticmethod is not considered through an instance where the name has
80
+ a bound method. A subclass declaring an overload at a name it inherits
81
+ keeps the inherited overloads and adds its own, an equal signature
82
+ replacing the inherited one. A subclass overloading the name only as
83
+ kinds of method the inherited declarations are not overrides it as a
84
+ plain definition does, hiding the inherited overloads.
82
85
  """
83
86
 
84
87
  # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
@@ -10,7 +10,6 @@ from typing import TYPE_CHECKING
10
10
  from ..dispatch import TypeSig, Dispatcher
11
11
  from ..utilities import maybe
12
12
  from ..waitaminute.dispatch import DuplicateSignature
13
- from ..waitaminute.meta import MixedMethodKind
14
13
  from . import AbstractNamespace
15
14
  from .space_hooks import LoadSpaceHook
16
15
 
@@ -51,10 +50,13 @@ class BaseSpace(AbstractNamespace):
51
50
  it: once a class overloads a name, a plain method it inherits there
52
51
  takes no part in its dispatch. Each gathered
53
52
  declaration must carry how far from the class it comes, which decides
54
- the order of dispatch. An overloaded name is one kind of method, an
55
- instance method, a classmethod or a staticmethod: one body may not
56
- declare it as two, and a base declaring it as another kind than the
57
- nearer classes is hidden as a plain definition is.
53
+ the order of dispatch. An overloaded name may hold bound methods,
54
+ classmethods and staticmethods together, each function keeping its
55
+ kind. A bound method is reached through an instance and a staticmethod
56
+ through the class, so the two never answer one call and may share a
57
+ signature; any other two functions of one signature at a name would
58
+ leave dispatch undecided. A base declaring the name as kinds none of
59
+ which the nearer classes declare is hidden as a plain definition is.
58
60
 
59
61
  Implementation
60
62
  --------------
@@ -65,12 +67,14 @@ class BaseSpace(AbstractNamespace):
65
67
  different functions. 'collectOverloads', 'collectVariadics',
66
68
  'collectFallback' and 'collectFinalizer' gather the declarations of the
67
69
  body and of the 'BaseSpace' namespaces of the bases, with distances, 0
68
- for the body. 'addMethodKind' records the kind each name is declared
69
- as, refusing a second kind with 'MixedMethodKind', and
70
- '_getInheritedSpaces' passes over a base of another kind as it passes
71
- over a plain definition, so
72
- 'collectMethodKind' gives the kind of the nearest class declaring the
73
- name. They are kept in lists rather than dictionaries keyed by
70
+ for the body. 'addMethodKind' records the kinds each name is declared
71
+ as and 'addFunctionKind' the kind of each function, and
72
+ '_getInheritedSpaces' passes over a base sharing no kind with the
73
+ nearer classes as it passes over a plain definition.
74
+ 'collectFunctionKinds' gathers the kind of every function at a name,
75
+ from which 'LoadSpaceHook' builds the dispatchers, and
76
+ 'collectMethodKind' gives the first kind of the nearest class declaring
77
+ the name. They are kept in lists rather than dictionaries keyed by
74
78
  signature, since a signature holding 'THIS' hashes differently once its
75
79
  class exists. The signature objects are shared with the dispatchers
76
80
  built from them, those of subclasses included, so nothing changes them
@@ -89,7 +93,8 @@ class BaseSpace(AbstractNamespace):
89
93
  __finalizer_map__: Optional[FuncMap] = None
90
94
  __plain_names__: Optional[tuple[str, ...]] = None
91
95
  __claimed_overloads__: Optional[tuple[Claim, ...]] = None
92
- __method_kinds__: Optional[dict[str, Any]] = None
96
+ __method_kinds__: Optional[dict[str, tuple]] = None
97
+ __function_kinds__: Optional[dict[str, list]] = None
93
98
 
94
99
  # Public Variables
95
100
  loadSpaceHook = LoadSpaceHook()
@@ -161,20 +166,37 @@ class BaseSpace(AbstractNamespace):
161
166
  """
162
167
  return maybe(self.__finalizer_map__, dict())
163
168
 
164
- def getMethodKinds(self) -> dict[str, Any]:
169
+ def getMethodKinds(self) -> dict[str, tuple]:
165
170
  """
166
- The dispatchers of the class and of its subclasses need the kind of
171
+ The dispatchers of the class and of its subclasses need the kinds of
167
172
  method this class body declared each overloaded name as.
168
173
 
169
174
  Returns
170
175
  -------
171
176
 
172
- dict[str, Any]
173
- From each name to 'classmethod', 'staticmethod', or 'None' for an
177
+ dict[str, tuple]
178
+ From each name to the kinds declared at it, in the order first
179
+ declared, each 'classmethod', 'staticmethod', or 'None' for an
174
180
  instance method.
175
181
  """
176
182
  return maybe(self.__method_kinds__, dict())
177
183
 
184
+ def getFunctionKinds(self) -> dict[str, list]:
185
+ """
186
+ One name may hold bound methods, classmethods and staticmethods, so
187
+ the dispatchers built for it need the kind of each function.
188
+
189
+ Returns
190
+ -------
191
+
192
+ dict[str, list]
193
+ From each name to a 'list[tuple[Callable, Any]]' of each function
194
+ this class body declared at it, as the body handed it over, with
195
+ its kind: 'classmethod', 'staticmethod', or 'None' for an instance
196
+ method.
197
+ """
198
+ return maybe(self.__function_kinds__, dict())
199
+
178
200
  def _getDeclaredKind(self, name: str) -> tuple:
179
201
  """
180
202
  'None' is the kind of an instance method, so whether this body declared
@@ -184,16 +206,16 @@ class BaseSpace(AbstractNamespace):
184
206
  -------
185
207
 
186
208
  tuple
187
- The kind in a one-element tuple, or an empty tuple when the body
188
- declared nothing at the name.
209
+ The kinds the body declared the name as, in the order first
210
+ declared, or an empty tuple when it declared nothing at the name.
189
211
  """
190
212
  kinds = self.getMethodKinds()
191
213
  try:
192
- kind = kinds[name]
214
+ declared = kinds[name]
193
215
  except KeyError:
194
216
  return ()
195
217
  else:
196
- return (kind,)
218
+ return declared
197
219
 
198
220
  def getPlainNames(self, ) -> tuple[str, ...]:
199
221
  """
@@ -325,8 +347,8 @@ class BaseSpace(AbstractNamespace):
325
347
  The name.
326
348
 
327
349
  kind : tuple
328
- The kind the nearer classes declare, in a one-element tuple, or an
329
- empty tuple when none of them declares the name.
350
+ The kinds the nearer classes declare, or an empty tuple when none
351
+ of them declares the name.
330
352
 
331
353
  Returns
332
354
  -------
@@ -340,7 +362,15 @@ class BaseSpace(AbstractNamespace):
340
362
  if space is None:
341
363
  return False
342
364
  found = space._getDeclaredKind(name)
343
- return True if kind and found and found[0] is not kind[0] else False
365
+ if not kind or not found:
366
+ return False
367
+ for one in found:
368
+ if any(one is other for other in kind):
369
+ # This branch is reached by the following:
370
+ # - The class declares the name as a kind the nearer classes
371
+ # declare as well
372
+ return False
373
+ return True
344
374
 
345
375
  def _isReachedAlong(
346
376
  self,
@@ -445,8 +475,7 @@ class BaseSpace(AbstractNamespace):
445
475
  # of the new class, and no base gathered before inherits this one
446
476
  # past such a class
447
477
  continue
448
- if not kind:
449
- kind = space._getDeclaredKind(name)
478
+ kind = self._joinKinds(kind, space._getDeclaredKind(name))
450
479
  out.append(space)
451
480
  routes.append([*cls.__mro__[1:]])
452
481
  return out
@@ -486,14 +515,82 @@ class BaseSpace(AbstractNamespace):
486
515
  return out
487
516
 
488
517
  @staticmethod
518
+ def _joinKinds(first: tuple, second: tuple) -> tuple:
519
+ out = [*first]
520
+ for kind in second:
521
+ if not any(kind is other for other in out):
522
+ out.append(kind)
523
+ return (*out,)
524
+
525
+ @staticmethod
526
+ def _mayMeet(first: Any, second: Any) -> bool:
527
+ """
528
+ Two functions of one signature at a name leave dispatch undecided only
529
+ if one call can reach both. A bound method is reached through an
530
+ instance and a staticmethod through the class, so those two never
531
+ meet; a classmethod is reached both ways and meets either.
532
+
533
+ Parameters
534
+ ----------
535
+
536
+ first : Any
537
+ The kind of one function: 'classmethod', 'staticmethod', or 'None'
538
+ for an instance method.
539
+
540
+ second : Any
541
+ The kind of the other.
542
+
543
+ Returns
544
+ -------
545
+
546
+ bool
547
+ Whether one call can reach functions of both kinds.
548
+ """
549
+ kinds = (first, second)
550
+ bound = any(kind is None for kind in kinds)
551
+ static = any(kind is staticmethod for kind in kinds)
552
+ return False if bound and static else True
553
+
554
+ @staticmethod
555
+ def _kindIn(kinds: list, func: Any) -> Any:
556
+ """
557
+ The kind of a function is looked up among the recorded ones by
558
+ identity; one recorded nowhere is an instance method, as a function
559
+ registered by hand is.
560
+
561
+ Parameters
562
+ ----------
563
+
564
+ kinds : list
565
+ A 'list[tuple[Callable, Any]]' of functions with their kinds.
566
+
567
+ func : Any
568
+ The function asked about.
569
+
570
+ Returns
571
+ -------
572
+
573
+ Any
574
+ 'classmethod', 'staticmethod', or 'None' for an instance method.
575
+ """
576
+ for held, kind in kinds:
577
+ if held is func:
578
+ return kind
579
+ return None
580
+
489
581
  def _mergeSigFuncs(
582
+ self,
490
583
  collected: CollectedList,
491
584
  more: SigFuncList,
492
585
  distance: int,
586
+ kinds: list,
493
587
  ) -> None:
494
588
  for sig, func in more:
495
- for existing, _, __ in collected:
496
- if existing == sig:
589
+ own = self._kindIn(kinds, func)
590
+ for existing, held, __ in collected:
591
+ if existing != sig:
592
+ continue
593
+ if self._mayMeet(self._kindIn(kinds, held), own):
497
594
  break
498
595
  else:
499
596
  collected.append((sig, func, distance,))
@@ -525,9 +622,10 @@ class BaseSpace(AbstractNamespace):
525
622
  """
526
623
  out = []
527
624
  spaces = (self, *self._getInheritedSpaces(name))
625
+ kinds = self._gatherFunctionKinds(spaces, name)
528
626
  for distance, space in enumerate(spaces):
529
627
  sigFuncs = space.getOverloads().get(name, [])
530
- self._mergeSigFuncs(out, sigFuncs, distance)
628
+ self._mergeSigFuncs(out, sigFuncs, distance, kinds)
531
629
  return out
532
630
 
533
631
  def collectVariadics(self, name: str) -> CollectedList:
@@ -548,9 +646,10 @@ class BaseSpace(AbstractNamespace):
548
646
  """
549
647
  out = []
550
648
  spaces = (self, *self._getInheritedSpaces(name))
649
+ kinds = self._gatherFunctionKinds(spaces, name)
551
650
  for distance, space in enumerate(spaces):
552
651
  sigFuncs = space.getVariadics().get(name, [])
553
- self._mergeSigFuncs(out, sigFuncs, distance)
652
+ self._mergeSigFuncs(out, sigFuncs, distance, kinds)
554
653
  return out
555
654
 
556
655
  def collectFlexes(self, name: str) -> CollectedList:
@@ -573,11 +672,15 @@ class BaseSpace(AbstractNamespace):
573
672
  """
574
673
  out = []
575
674
  spaces = (self, *self._getInheritedSpaces(name))
675
+ kinds = self._gatherFunctionKinds(spaces, name)
576
676
  for distance, space in enumerate(spaces):
577
677
  for sig, func in space.getFlexes().get(name, []):
578
678
  bag = sig.getBag()
579
- for existing, _, __ in out:
580
- if existing.getBag() == bag:
679
+ own = self._kindIn(kinds, func)
680
+ for existing, held, __ in out:
681
+ if existing.getBag() != bag:
682
+ continue
683
+ if self._mayMeet(self._kindIn(kinds, held), own):
581
684
  break
582
685
  else:
583
686
  out.append((sig, func, distance,))
@@ -612,6 +715,49 @@ class BaseSpace(AbstractNamespace):
612
715
  return found[0]
613
716
  return None
614
717
 
718
+ @staticmethod
719
+ def _gatherFunctionKinds(spaces: tuple, name: str) -> list:
720
+ out = []
721
+ for space in spaces:
722
+ try:
723
+ recorded = space.getFunctionKinds()[name]
724
+ except KeyError:
725
+ # This branch is reached by the following:
726
+ # - The class body recorded no kind at the name, as one whose
727
+ # declarations were registered by hand
728
+ continue
729
+ out.extend(recorded)
730
+ return out
731
+
732
+ def collectFunctionKinds(self, name: str) -> list:
733
+ """
734
+ The dispatchers of a name are built by the kind of each function, its
735
+ own and the inherited ones: the bound methods are reached through an
736
+ instance, the staticmethods through the class and the classmethods
737
+ both ways.
738
+
739
+ Implementation
740
+ --------------
741
+
742
+ The body and the namespaces from '_getInheritedSpaces' are asked in
743
+ order.
744
+
745
+ Parameters
746
+ ----------
747
+
748
+ name : str
749
+ The name.
750
+
751
+ Returns
752
+ -------
753
+
754
+ list
755
+ A 'list[tuple[Callable, Any]]' of each function recorded at the
756
+ name with its kind, nearest class first.
757
+ """
758
+ spaces = (self, *self._getInheritedSpaces(name))
759
+ return self._gatherFunctionKinds(spaces, name)
760
+
615
761
  def collectFallback(self, name: str) -> Optional[Callable]:
616
762
  """
617
763
  The dispatcher of a name needs the fallback of the nearest class
@@ -683,19 +829,26 @@ class BaseSpace(AbstractNamespace):
683
829
 
684
830
  DuplicateSignature
685
831
  An equal signature is declared for a different function, or a
686
- flexible declaration of the same classes is.
832
+ flexible declaration of the same classes is, unless the two are a
833
+ bound method and a staticmethod, which no call reaches together.
687
834
  """
835
+ kinds = self._gatherFunctionKinds((self,), name)
836
+ own = self._kindIn(kinds, func)
688
837
  bag = sig.getBag()
689
838
  for flexSig, flexFunc in self.getFlexes().get(name, []):
690
- if flexSig.getBag() == bag and flexFunc is not func:
839
+ if flexSig.getBag() != bag or flexFunc is func:
840
+ continue
841
+ if self._mayMeet(self._kindIn(kinds, flexFunc), own):
691
842
  raise DuplicateSignature(sig, flexFunc, func)
692
843
  existing = self.getOverloads()
693
844
  sigFuncs = existing.get(name, [])
694
845
  for oldSig, oldFunc in sigFuncs:
695
- if oldSig == sig:
696
- if oldFunc is not func:
697
- raise DuplicateSignature(sig, oldFunc, func)
846
+ if oldSig != sig:
847
+ continue
848
+ if oldFunc is func:
698
849
  break
850
+ if self._mayMeet(self._kindIn(kinds, oldFunc), own):
851
+ raise DuplicateSignature(sig, oldFunc, func)
699
852
  else:
700
853
  sigFuncs.append((sig, func,))
701
854
  existing[name] = sigFuncs
@@ -726,19 +879,26 @@ class BaseSpace(AbstractNamespace):
726
879
 
727
880
  DuplicateSignature
728
881
  The same classes are declared for a different function, flexibly or
729
- as one order.
882
+ as one order, unless the two are a bound method and a staticmethod,
883
+ which no call reaches together.
730
884
  """
885
+ kinds = self._gatherFunctionKinds((self,), name)
886
+ own = self._kindIn(kinds, func)
731
887
  bag = sig.getBag()
732
888
  for oldSig, oldFunc in self.getOverloads().get(name, []):
733
- if oldSig.getBag() == bag and oldFunc is not func:
889
+ if oldSig.getBag() != bag or oldFunc is func:
890
+ continue
891
+ if self._mayMeet(self._kindIn(kinds, oldFunc), own):
734
892
  raise DuplicateSignature(sig, oldFunc, func)
735
893
  existing = self.getFlexes()
736
894
  flexes = existing.get(name, [])
737
895
  for oldSig, oldFunc in flexes:
738
- if oldSig.getBag() == bag:
739
- if oldFunc is not func:
740
- raise DuplicateSignature(sig, oldFunc, func)
896
+ if oldSig.getBag() != bag:
897
+ continue
898
+ if oldFunc is func:
741
899
  break
900
+ if self._mayMeet(self._kindIn(kinds, oldFunc), own):
901
+ raise DuplicateSignature(sig, oldFunc, func)
742
902
  else:
743
903
  flexes.append((sig, func,))
744
904
  existing[name] = flexes
@@ -766,15 +926,21 @@ class BaseSpace(AbstractNamespace):
766
926
  ------
767
927
 
768
928
  DuplicateSignature
769
- An equal signature is declared for a different function.
929
+ An equal signature is declared for a different function, unless the
930
+ two are a bound method and a staticmethod, which no call reaches
931
+ together.
770
932
  """
933
+ kinds = self._gatherFunctionKinds((self,), name)
934
+ own = self._kindIn(kinds, func)
771
935
  existing = self.getVariadics()
772
936
  sigFuncs = existing.get(name, [])
773
937
  for oldSig, oldFunc in sigFuncs:
774
- if oldSig == sig:
775
- if oldFunc is not func:
776
- raise DuplicateSignature(sig, oldFunc, func)
938
+ if oldSig != sig:
939
+ continue
940
+ if oldFunc is func:
777
941
  break
942
+ if self._mayMeet(self._kindIn(kinds, oldFunc), own):
943
+ raise DuplicateSignature(sig, oldFunc, func)
778
944
  else:
779
945
  sigFuncs.append((sig, func,))
780
946
  existing[name] = sigFuncs
@@ -782,9 +948,9 @@ class BaseSpace(AbstractNamespace):
782
948
 
783
949
  def addMethodKind(self, name: str, kind: Any) -> None:
784
950
  """
785
- One dispatcher stands at an overloaded name and passes one receiver
786
- to every function, so one body declares the name as one kind of
787
- method.
951
+ One name may be declared as several kinds of method, and which kinds
952
+ a body declares decides what the class inherits at the name: a base
953
+ sharing no kind with the nearer classes is hidden.
788
954
 
789
955
  Parameters
790
956
  ----------
@@ -794,22 +960,49 @@ class BaseSpace(AbstractNamespace):
794
960
 
795
961
  kind : Any
796
962
  'classmethod', 'staticmethod', or 'None' for an instance method.
963
+ """
964
+ kinds = self.getMethodKinds()
965
+ kinds[name] = self._joinKinds(self._getDeclaredKind(name), (kind,))
966
+ self.__method_kinds__ = kinds
797
967
 
798
- Raises
799
- ------
968
+ def addFunctionKind(self, name: str, kind: Any, *funcs) -> None:
969
+ """
970
+ 'LoadSpaceHook' records the kind of each function a body declares at
971
+ an overloaded name, since the dispatchers of the name are built by
972
+ kind.
973
+
974
+ Implementation
975
+ --------------
976
+
977
+ Each function is recorded once, compared by identity, with the kind
978
+ of its first record.
979
+
980
+ Parameters
981
+ ----------
982
+
983
+ name : str
984
+ The name.
985
+
986
+ kind : Any
987
+ 'classmethod', 'staticmethod', or 'None' for an instance method.
800
988
 
801
- MixedMethodKind
802
- The body declared the name as another kind already.
989
+ *funcs
990
+ The functions as the body handed them over, a 'PermuterMethod' of
991
+ a flexible declaration included.
803
992
  """
804
- kinds = self.getMethodKinds()
993
+ existing = self.getFunctionKinds()
805
994
  try:
806
- existing = kinds[name]
995
+ recorded = existing[name]
807
996
  except KeyError:
808
- kinds[name] = kind
809
- self.__method_kinds__ = kinds
810
- else:
811
- if existing is not kind:
812
- raise MixedMethodKind(self.getClassName(), name, (existing, kind))
997
+ # This branch is reached by the following:
998
+ # - The first function the body declares at the name
999
+ recorded = []
1000
+ for func in funcs:
1001
+ if any(func is held for held, _ in recorded):
1002
+ continue
1003
+ recorded.append((func, kind))
1004
+ existing[name] = recorded
1005
+ self.__function_kinds__ = existing
813
1006
 
814
1007
  def addPlainName(self, name: str) -> None:
815
1008
  """
@@ -32,16 +32,22 @@ class LoadSpaceHook(AbstractSpaceHook):
32
32
  stores one, and records its signatures, as copies, its fallback and its
33
33
  finalizer on the namespace. A record under '@classmethod' or
34
34
  '@staticmethod' is taken out and claimed the same way, and the kind of
35
- method each binding declares is recorded; a second kind at one name, or
36
- both kinds in one stack, raises 'MixedMethodKind'. A plain binding at
35
+ method each binding declares is recorded, for the name and for each
36
+ function; one stack declaring both a classmethod and a staticmethod
37
+ raises 'MixedMethodKind'. A plain binding at
37
38
  an overloaded name, or an overload at a plainly bound one, raises
38
39
  'OverloadConflict'; binding one 'overload' object twice in a body, as
39
40
  '__radd__ = __add__', raises 'ReboundOverload'. 'postCompilePhase'
40
41
  builds a 'Dispatcher' for every
41
42
  overloaded name of the body or of a base, unless the body defines the
42
- name plainly, and writes it into the dictionary, of the kind of method
43
- the nearest class declaring the name made it. Every class thus has
44
- dispatchers of its own.
43
+ name plainly, and writes it into the dictionary. Every class thus has
44
+ dispatchers of its own. A name holding bound methods beside
45
+ classmethods or staticmethods takes two: one of the bound methods and
46
+ the classmethods, reached through an instance, which keeps one of the
47
+ classmethods and the staticmethods, reached through the class. A bound
48
+ method is thus not considered through the class, nor a staticmethod
49
+ through an instance. Any other name takes one dispatcher holding every
50
+ function.
45
51
  """
46
52
 
47
53
  # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
@@ -90,8 +96,7 @@ class LoadSpaceHook(AbstractSpaceHook):
90
96
  The 'overload' object is bound a second time in the body.
91
97
 
92
98
  MixedMethodKind
93
- The body declared the name as another kind of method already, or the
94
- binding is decorated as both a classmethod and a staticmethod.
99
+ The binding is decorated as both a classmethod and a staticmethod.
95
100
  """
96
101
  kinds, record = overload.peelMethodKinds(val)
97
102
  if not isinstance(record, overload):
@@ -105,7 +110,11 @@ class LoadSpaceHook(AbstractSpaceHook):
105
110
  claimedName = self.space.getClaimedName(val)
106
111
  if claimedName is not None:
107
112
  raise ReboundOverload(self.space.getClassName(), claimedName, key)
108
- self.space.addMethodKind(key, self._getMethodKind(key, kinds, val))
113
+ kind = self._getMethodKind(key, kinds, val)
114
+ self.space.addMethodKind(key, kind)
115
+ # Before the registrations below, which ask for the kind of a function
116
+ # to tell whether two of one signature can meet.
117
+ self.space.addFunctionKind(key, kind, *self._getFunctions(val))
109
118
  self.space.addClaimedName(val, key)
110
119
  # A stack of decorators may give one 'overload' every role at once.
111
120
  if val.isFallback():
@@ -155,6 +164,35 @@ class LoadSpaceHook(AbstractSpaceHook):
155
164
  className = self.space.getClassName()
156
165
  return overload.agreeMethodKind(stack, key, className)
157
166
 
167
+ @staticmethod
168
+ def _getFunctions(record: overload) -> list:
169
+ """
170
+ A record hands its function to the namespace under every role it
171
+ declares, and the namespace keeps the kind of each.
172
+
173
+ Parameters
174
+ ----------
175
+
176
+ record : overload
177
+ The record.
178
+
179
+ Returns
180
+ -------
181
+
182
+ list
183
+ Every function the record hands over: those of its concrete,
184
+ flexible and variadic signatures, a 'PermuterMethod' of a flexible
185
+ declaration included, its fallback and its finalizer.
186
+ """
187
+ out = [func for _, func in record]
188
+ out += [func for _, func in record.getFlexes()]
189
+ out += [func for _, func in record.getVariadics()]
190
+ if record.isFallback():
191
+ out.append(record.getFallback())
192
+ if record.isFinalizer():
193
+ out.append(record.getFinalizer())
194
+ return out
195
+
158
196
  def delItemPhase(self, key: str, val: Any = None, ) -> bool:
159
197
  """
160
198
  A plain definition deleted from the body no longer conflicts with
@@ -206,15 +244,145 @@ class LoadSpaceHook(AbstractSpaceHook):
206
244
  # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
207
245
 
208
246
  def _buildDispatcher(self, name: str) -> Optional[Dispatcher]:
209
- sigFuncs = self.space.collectOverloads(name)
210
- flexes = self.space.collectFlexes(name)
211
- variadics = self.space.collectVariadics(name)
212
- fallback = self.space.collectFallback(name)
213
- finalizer = self.space.collectFinalizer(name)
214
- if not (sigFuncs or flexes or variadics or fallback or finalizer):
247
+ """
248
+ One name may hold bound methods, classmethods and staticmethods. A
249
+ bound method needs an instance, so it is not considered through the
250
+ class, and where a name has bound methods its staticmethods are not
251
+ considered through an instance. A classmethod is reached both ways.
252
+
253
+ Implementation
254
+ --------------
255
+
256
+ A name holding bound methods beside another kind takes two
257
+ dispatchers, each built by '_buildSide': one of the bound methods and
258
+ the classmethods, which is returned and reached through an instance,
259
+ and one of the classmethods and the staticmethods, which the first
260
+ keeps for a read through the class. Any other name takes one
261
+ dispatcher of every function.
262
+
263
+ Parameters
264
+ ----------
265
+
266
+ name : str
267
+ The overloaded name.
268
+
269
+ Returns
270
+ -------
271
+
272
+ Dispatcher or None
273
+ The dispatcher for the class dictionary, or 'None' when nothing is
274
+ declared at the name that the class inherits.
275
+ """
276
+ gathered = (
277
+ self.space.collectOverloads(name),
278
+ self.space.collectFlexes(name),
279
+ self.space.collectVariadics(name),
280
+ self.space.collectFallback(name),
281
+ self.space.collectFinalizer(name),
282
+ )
283
+ members = self._getMembers(*gathered)
284
+ if not members:
215
285
  return None
286
+ kinds = self.space.collectFunctionKinds(name)
287
+ memberKinds = [self.space._kindIn(kinds, func) for func in members]
288
+ bound = any(kind is None for kind in memberKinds)
289
+ other = any(kind is not None for kind in memberKinds)
290
+ if bound and other:
291
+ # This branch is reached by the following:
292
+ # - The name holds bound methods beside classmethods or
293
+ # staticmethods
294
+ onInstance = self._buildSide(gathered, kinds, (None, classmethod))
295
+ onClass = self._buildSide(gathered, kinds, (classmethod, staticmethod))
296
+ onInstance.setClassDispatcher(onClass)
297
+ return onInstance
298
+ every = (None, classmethod, staticmethod)
299
+ return self._buildSide(gathered, kinds, every)
300
+
301
+ @staticmethod
302
+ def _getMembers(*gathered) -> list:
303
+ sigFuncs, flexes, variadics, fallback, finalizer = gathered
304
+ out = [func for _, func, __ in (*sigFuncs, *flexes, *variadics)]
305
+ for role in (fallback, finalizer):
306
+ if role is not None:
307
+ out.append(role)
308
+ return out
309
+
310
+ def _buildSide(
311
+ self,
312
+ gathered: tuple,
313
+ kinds: list,
314
+ accepted: tuple,
315
+ ) -> Dispatcher:
316
+ """
317
+ A dispatcher holds the functions of a name that one way of reaching
318
+ it considers, and binds one receiver for them all: the instance when
319
+ a bound method is among them, else the class.
320
+
321
+ Implementation
322
+ --------------
323
+
324
+ The dispatcher stands for an instance method when it holds a bound
325
+ method, else for a classmethod when it holds one, else for a
326
+ staticmethod. The functions of another kind than that are named to it
327
+ by 'setFunctionKind' before any is registered, and the functions of
328
+ the accepted kinds are registered with their distances, the fallback
329
+ and the finalizer included.
330
+
331
+ Parameters
332
+ ----------
333
+
334
+ gathered : tuple
335
+ What the namespace gathered at the name: the concrete, the flexible
336
+ and the variadic registrations, each a list of signature, function
337
+ and distance, then the fallback and the finalizer, each a function
338
+ or 'None'.
339
+
340
+ kinds : list
341
+ A 'list[tuple[Callable, Any]]' of each function at the name with
342
+ its kind.
343
+
344
+ accepted : tuple
345
+ The kinds the dispatcher holds, each 'classmethod', 'staticmethod',
346
+ or 'None' for an instance method.
347
+
348
+ Returns
349
+ -------
350
+
351
+ Dispatcher
352
+ The dispatcher, unplaced.
353
+ """
354
+
355
+ def kindOf(func: Any) -> Any:
356
+ return self.space._kindIn(kinds, func)
357
+
358
+ def taken(func: Any) -> bool:
359
+ own = kindOf(func)
360
+ return True if any(own is kind for kind in accepted) else False
361
+
362
+ sigFuncs = [entry for entry in gathered[0] if taken(entry[1])]
363
+ flexes = [entry for entry in gathered[1] if taken(entry[1])]
364
+ variadics = [entry for entry in gathered[2] if taken(entry[1])]
365
+ # A fallback or a finalizer the name does not have is 'None' here,
366
+ # and stays 'None' whichever way the test falls.
367
+ fallback = gathered[3] if taken(gathered[3]) else None
368
+ finalizer = gathered[4] if taken(gathered[4]) else None
369
+ members = self._getMembers(
370
+ sigFuncs, flexes, variadics, fallback, finalizer,
371
+ )
372
+ memberKinds = [kindOf(func) for func in members]
373
+ if any(kind is None for kind in memberKinds):
374
+ binding = None
375
+ elif any(kind is classmethod for kind in memberKinds):
376
+ binding = classmethod
377
+ else:
378
+ binding = staticmethod
216
379
  dispatcher = Dispatcher()
217
- dispatcher.setMethodKind(self.space.collectMethodKind(name))
380
+ dispatcher.setMethodKind(binding)
381
+ for kind in (classmethod, staticmethod):
382
+ if kind is binding:
383
+ continue
384
+ named = [func for func in members if kindOf(func) is kind]
385
+ dispatcher.setFunctionKind(kind, *named)
218
386
  for sig, func, distance in sigFuncs:
219
387
  dispatcher.addSigFunc(sig, func, distance)
220
388
  for sig, func, distance in flexes:
@@ -3,8 +3,8 @@ during class creation by the metaclass machinery in 'worktoy.mcls' (and
3
3
  the primitive metaclasses in 'worktoy.core'). They cover near-miss dunder
4
4
  names, illegal '__del__', reserved names, hook conflicts, a name both
5
5
  overloaded and defined plainly in one class body, an 'overload' object
6
- bound twice in one class body, an overloaded name declared as two kinds
7
- of method, the deletion of a name a hook claimed, a class hook a
6
+ bound twice in one class body, one overloaded function declared as two
7
+ kinds of method, the deletion of a name a hook claimed, a class hook a
8
8
  metaclass takes over, '__slots__' in the body of a worktoy class, a
9
9
  second sentinel at a taken name, illegal instantiation, and a disallowed
10
10
  attribute in the class body of a control-flow signal.
@@ -1,7 +1,6 @@
1
1
  """
2
- MixedMethodKind is raised when the declarations of one overloaded name
3
- are not all one kind of method, or when one is decorated as both a
4
- classmethod and a staticmethod.
2
+ MixedMethodKind is raised when one function declared at an overloaded name
3
+ is decorated as both a classmethod and a staticmethod.
5
4
  """
6
5
  # Apache-2.0 license
7
6
  # Copyright (c) 2026 Asger Jon Vistisen
@@ -18,17 +17,15 @@ if TYPE_CHECKING: # pragma: no cover, no mutate
18
17
 
19
18
  class MixedMethodKind(WorkToyException, SyntaxError):
20
19
  """
21
- MixedMethodKind is raised when the declarations of one overloaded name
22
- are not all one kind of method. One dispatcher stands at the name, and
23
- it passes the instance, the class or nothing ahead of the arguments of
24
- every call, so every declaration at the name is an instance method, or
25
- every one is decorated '@classmethod', or every one '@staticmethod'. A
26
- function decorated as both a classmethod and a staticmethod is refused
27
- as well: Python itself gives that stack a different meaning on each
28
- version, refusing the call on 3.7 and 3.8, acting as a staticmethod on
29
- 3.9 to 3.12 and as a classmethod from 3.13. The refusal comes at the
30
- declaration breaking the rule, from the decorator for a stack under
31
- '@overload' and from the class body otherwise. It subclasses
20
+ MixedMethodKind is raised when one function declared at an overloaded
21
+ name is decorated as both a classmethod and a staticmethod. One
22
+ function is one kind of method, and Python itself gives that stack a
23
+ different meaning on each version, refusing the call on 3.7 and 3.8,
24
+ acting as a staticmethod on 3.9 to 3.12 and as a classmethod from 3.13.
25
+ The refusal comes at the declaration, from the decorator for a stack
26
+ under '@overload' and from the class body otherwise. Different
27
+ functions at one name may be of different kinds: bound methods,
28
+ classmethods and staticmethods share an overloaded name. It subclasses
32
29
  'SyntaxError', as the other refusals of a class-body line do.
33
30
 
34
31
  Attributes
@@ -40,8 +37,7 @@ class MixedMethodKind(WorkToyException, SyntaxError):
40
37
  The overloaded name, or the name of the function a decorator refused.
41
38
  kinds : tuple
42
39
  The two kinds that disagree, each 'classmethod', 'staticmethod' or
43
- None for an instance method: the earlier declaration first, or the
44
- outer decorator of a stack.
40
+ None for an instance method: the outer decorator of the stack first.
45
41
  """
46
42
 
47
43
  __slots__ = ('className', 'overloadName', 'kinds',)
@@ -75,9 +71,9 @@ class MixedMethodKind(WorkToyException, SyntaxError):
75
71
  info = spec % (
76
72
  name, self._describeKind(first), self._describeKind(second),
77
73
  )
78
- rule = """Every declaration at an overloaded name is an instance
79
- method, or every one is decorated '@classmethod', or every one
80
- '@staticmethod', and none is decorated as both."""
74
+ rule = """One function is one kind of method, and none is decorated
75
+ as both a classmethod and a staticmethod. Functions of different
76
+ kinds may share an overloaded name."""
81
77
  return textFmt(info, rule)
82
78
 
83
79
  __repr__ = __str__
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: worktoy
3
- Version: 1.2.2.dev0
3
+ Version: 1.2.3.dev0
4
4
  Summary: Declarative structure for Python that enforces types at runtime and enables true function overloading
5
5
  Author-email: Asger Jon Vistisen <asgerjon2@gmail.com>
6
6
  License-Expression: Apache-2.0
@@ -27,12 +27,12 @@ License-File: LICENSE
27
27
  Dynamic: license-file
28
28
 
29
29
  [![wakatime](https://wakatime.com/badge/github/AsgerJon/WorkToy.svg)](https://wakatime.com/badge/github/AsgerJon/WorkToy)
30
- [![Tokens](https://img.shields.io/badge/Tokens-23.6B-D97757)](https://claude.com/claude-code)
30
+ [![Tokens](https://img.shields.io/badge/Tokens-24.9B-D97757)](https://claude.com/claude-code)
31
31
  [![codecov](https://codecov.io/gh/AsgerJon/WorkToy/graph/badge.svg?token=FC0KFZJ7JK)](https://codecov.io/gh/AsgerJon/WorkToy)
32
32
  [![PyPI version](https://img.shields.io/pypi/v/worktoy)](https://pypi.org/project/worktoy/)
33
33
  [![License: Apache 2.0](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
34
34
 
35
- # worktoy v1.2.2-dev0 (development build)
35
+ # worktoy v1.2.3-dev0 (development build)
36
36
 
37
37
  **worktoy** provides utilities for Python development focused on
38
38
  reducing boilerplate while improving type safety and readability. Each
@@ -1,4 +1,4 @@
1
- worktoy/__init__.py,sha256=fhl-o_8VyaGH6R2HKDfutkTpCeRDPdRWzLVNPRmU5d0,2899
1
+ worktoy/__init__.py,sha256=EWLBfZ1lFQt8B-aXjjCdA8FQdA8EgEl9BG2OeSIjivY,2899
2
2
  worktoy/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
3
  worktoy/core/__init__.py,sha256=dUNFlZa37R95JPn_6spjQDhI_A3LBJV34NGiyElV5gs,604
4
4
  worktoy/core/_instance_owner.py,sha256=Nb0j0Wp8uXROUTLMVGWS_Krl6mlUcelo24vu07U4_bo,2144
@@ -28,9 +28,9 @@ worktoy/desc/_root_alias.py,sha256=t_64Ap11UQujx1Ov3eS9yOd_dUQ61hXkpXVCnHQOfKw,4
28
28
  worktoy/desc/_symbolic_name.py,sha256=KPtQtU-5GWv7C0xK8wpn7x6zTbMVJEPKLJW7LYjt_sM,6133
29
29
  worktoy/dispatch/__init__.py,sha256=VcWtjDBdeUhEcPK7LH4-4Ok484kTAXRqC0lXZEZWfJM,1134
30
30
  worktoy/dispatch/_call_me_maybe.py,sha256=w1RXd_yi1TdCIL-Ee5FYmNBYC_2mHV8TNUZxnAPi2oc,7666
31
- worktoy/dispatch/_dispatcher.py,sha256=MDWUJibRI6bnozahNR3jCQuT1CZHgV4Jg-G0m5BGb04,50461
31
+ worktoy/dispatch/_dispatcher.py,sha256=cBGnS_zNPILR3xI6o4TNQdh4t7WAIkUC4tXU_xsgyw8,57183
32
32
  worktoy/dispatch/_flex_call.py,sha256=lz7e0Wa36ejNzrFzH9Dmd-f5yVqN1WbCAelKYNanPiw,4632
33
- worktoy/dispatch/_overload.py,sha256=pKVgePtjxHRSqQTvxLy6-YFLCOCnOoeHS8L_0RcGDPk,24935
33
+ worktoy/dispatch/_overload.py,sha256=yMGeoLXqbxCCPKZ3ZJJSYV_05FpSWOH1Su5cSeznPe4,25207
34
34
  worktoy/dispatch/_permuter.py,sha256=n8mNyViyn5gIBRjRjtq438Qb0GC7R3XXy59Eu_MJq6I,8172
35
35
  worktoy/dispatch/_permuter_method.py,sha256=N_KquUeKxWjfAruY7pVmAWzjPLYsTDAMlwnllMiT9nA,1657
36
36
  worktoy/dispatch/_type_sig.py,sha256=XZFOuPjsqrhtxQWjM9wqTAxVHGHKBo5dsjbQhu81qhM,15160
@@ -70,11 +70,11 @@ worktoy/mcls/_abstract_metaclass.py,sha256=ntkgG-RojlThddvTx9D-5zT-Oq-wQVu33uTr-
70
70
  worktoy/mcls/_abstract_namespace.py,sha256=WayJ-mG248nT5sV4e0G6PGkk_-CpxKKsz-ML4ub6qxw,18782
71
71
  worktoy/mcls/_base_meta.py,sha256=kRoLGaqIu5OvraSG_TdBCKpoMDr4q8D_cUH81BhZgjY,1119
72
72
  worktoy/mcls/_base_object.py,sha256=nmn62F_PmVDURIBdAeW6U2lNVJdn0w_pc-LUDRKa3ls,2138
73
- worktoy/mcls/_base_space.py,sha256=289seWw8e-i9OQ552mduZ-JJobmgT9MF8qxFdPE_RZ0,25925
73
+ worktoy/mcls/_base_space.py,sha256=OG9p94lVm_q6ue0ntoew8wgevqivS-sqvzb9LTSf1zk,32205
74
74
  worktoy/mcls/space_hooks/__init__.py,sha256=h2m1uKEcPsprkcg0Cw3g3tDOHM7jKgcsr0Hs-b0AYdA,1180
75
75
  worktoy/mcls/space_hooks/_abstract_space_hook.py,sha256=QUpoorQJbZhEn_XbEK106ZNijns5deOoh-oKKT2aYEU,7158
76
76
  worktoy/mcls/space_hooks/_flex_call_hook.py,sha256=FfKFuKnvY-PuLu8CFfyz_hzjd6T0dbxDA2tHK5nVvcA,1126
77
- worktoy/mcls/space_hooks/_load_space_hook.py,sha256=fCi6-t3oIEaM6uyVUoaATuUPYXsWqwyb5gqRF8jeDsc,7969
77
+ worktoy/mcls/space_hooks/_load_space_hook.py,sha256=mk7uFLj5bymN4nS0yjNwnqsOwi3FFSVtCAfOkeu8d1U,13784
78
78
  worktoy/mcls/space_hooks/_name_hook.py,sha256=tItAB5rs5wFknhjYG-LrpOFlO1bvGILio5ThsAJ1DfE,12675
79
79
  worktoy/mcls/space_hooks/_reserved_names.py,sha256=siKNcEalYATzzUhngcnDfcnFWng-I5cIoRc7XctuUDI,1359
80
80
  worktoy/mcls/space_hooks/_reserved_namespace_hook.py,sha256=DVHMNdbK-lnJp6IdThP2yYEmqDcBFGBBYdhn2i5vsQ4,1800
@@ -161,7 +161,7 @@ worktoy/waitaminute/keenum/_kee_name_conflict.py,sha256=vOTDkuKpvmCZakUs8zKceNYI
161
161
  worktoy/waitaminute/keenum/_kee_resolve_error.py,sha256=SGZ4m2DuQ22gJdd-QTDnNZIE5RoZlzugryubzuKz0nc,1678
162
162
  worktoy/waitaminute/keenum/_kee_type_exception.py,sha256=P0VnOFXDbH3JrCc8Q8TL5q1wWtM5Xqt2FUB9nUY_SFc,1969
163
163
  worktoy/waitaminute/keenum/_kee_write_once_error.py,sha256=f4hYFO1PDxZhN4VTR-sxhZzBM5rXt8PLQcNryIEwz6w,1524
164
- worktoy/waitaminute/meta/__init__.py,sha256=bxmDO2jolCvk8PQBix41cMeKbxDme65GBCBTIZWL_ik,1836
164
+ worktoy/waitaminute/meta/__init__.py,sha256=xYEdSU30sxF4zeIoF_4w0xjeOMs6obfUsBcpkbZ2Gsk,1841
165
165
  worktoy/waitaminute/meta/_claimed_name.py,sha256=P6NdaRvQAgZbna3kE1APRVEaVimpqRS5t31wBeaCLpA,1844
166
166
  worktoy/waitaminute/meta/_control_class_error.py,sha256=-QaYjuEOGS4h1kyQHF2fz6Dsw_h8nuAD3g_kNoW9M9I,1824
167
167
  worktoy/waitaminute/meta/_del_exception.py,sha256=hI5lcFwThECx3hpZFLmw17EcV_YxrpIvpUZ0XXnztBg,1889
@@ -169,7 +169,7 @@ worktoy/waitaminute/meta/_duplicate_hook.py,sha256=SPEgK724WpZEJ851LwNJZPcVz4x8W
169
169
  worktoy/waitaminute/meta/_duplicate_sentinel.py,sha256=C3-LrH-rwWoJL_85j-ostnEt8lWd9xBcjLf3CLv2Ifo,2524
170
170
  worktoy/waitaminute/meta/_hook_exception.py,sha256=nY-gmUWLGH6fei7mw2nNgEWPrAUtiiFvvM5Prp_UCGA,2387
171
171
  worktoy/waitaminute/meta/_illegal_instantiation.py,sha256=9A7j5tkJZj4X2jhLtrJKGMIeDp2BvfF43uj0ZuNjkp4,990
172
- worktoy/waitaminute/meta/_mixed_method_kind.py,sha256=4v8uwjJpsrsWl1QP1l6W_8xqs7Jxfu-WpRH3YhgMuw4,2988
172
+ worktoy/waitaminute/meta/_mixed_method_kind.py,sha256=EoMWWlwvN1tk5SK61UpS0mrwOkcHpaoj3pNWn5NX0Vw,2755
173
173
  worktoy/waitaminute/meta/_overload_conflict.py,sha256=jNzoJxwmFBdvQaadWthdeS_bt0Y3lvY4uf8zB41v_Hk,2135
174
174
  worktoy/waitaminute/meta/_questionable_syntax.py,sha256=FNzJYd6B1vnj_Dm00HZKZ71YIiKMeIEAWUlNNDcsYSE,1383
175
175
  worktoy/waitaminute/meta/_rebound_overload.py,sha256=UixG78dPz6CIsQlwrisNaOH-xkmTXtgymUnhbpb3qTE,2088
@@ -194,8 +194,8 @@ worktoy/work_test/samplers/_lorem_text.py,sha256=KQgBKQ5iLS_lU7HGvfoLTVsFyDcm-JR
194
194
  worktoy/work_test/samplers/_sampler_meta.py,sha256=9AodXKw3Ww-Eu1qzqJsRm-AbYolgON9TKA5fdfBZ9bY,1216
195
195
  worktoy/work_test/samplers/_symbolic_sampler.py,sha256=VgheImGi_-WiUYa1o-Htu1OSjoOqTzx8PycDzf-es4c,3042
196
196
  worktoy/work_test/samplers/_word_sampler.py,sha256=9K5ib8Wt2APUEMh2ZGMRNSkHjnUpl_HDl8OdFSgw1BU,1044
197
- worktoy-1.2.2.dev0.dist-info/licenses/LICENSE,sha256=z8d0m5b2O9McPEK1xHG_dWgUBT6EfBDz6wA0F7xSPTA,11358
198
- worktoy-1.2.2.dev0.dist-info/METADATA,sha256=Qh9NmjYpSj9-E31Ku68aG4YWfDcbfE5k_4QBSzEZt24,10656
199
- worktoy-1.2.2.dev0.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
200
- worktoy-1.2.2.dev0.dist-info/top_level.txt,sha256=6yO8xnr7WakfINq91qO3rs5ECubDOGvAQ9ztVgoG0j4,8
201
- worktoy-1.2.2.dev0.dist-info/RECORD,,
197
+ worktoy-1.2.3.dev0.dist-info/licenses/LICENSE,sha256=z8d0m5b2O9McPEK1xHG_dWgUBT6EfBDz6wA0F7xSPTA,11358
198
+ worktoy-1.2.3.dev0.dist-info/METADATA,sha256=EZQP3b-gM_IpigkyPD1dbEP7uNIPjwhOae7DPPTOucI,10656
199
+ worktoy-1.2.3.dev0.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
200
+ worktoy-1.2.3.dev0.dist-info/top_level.txt,sha256=6yO8xnr7WakfINq91qO3rs5ECubDOGvAQ9ztVgoG0j4,8
201
+ worktoy-1.2.3.dev0.dist-info/RECORD,,