diff options
author | Mats Wichmann <mats@linux.com> | 2023-05-01 11:54:48 -0600 |
---|---|---|
committer | Mats Wichmann <mats@linux.com> | 2023-05-01 12:06:45 -0600 |
commit | 1a103470a13a83590b3fc06e8779494e2b99751d (patch) | |
tree | ab4b5fcdbc2504ff1436387dbe82db2dcedff22b /SCons/Memoize.py | |
parent | 0ef81fc03600cd275a8e6733aeca26e0db268dad (diff) | |
download | scons-git-1a103470a13a83590b3fc06e8779494e2b99751d.tar.gz |
Add some cheap return and parameter annotations
Use: https://github.com/JelleZijlstra/autotyping
to add "safe" return annotations.
Where a parameter has a default value that is an obvious scalar type
(bool, int, str, etc.) add those annotations as well.
Also fixed two small bugs that popped up when sanity-checking with
mypy. One in FortranCommon, where a return had been previously
annotated to be a tuple of Action, which should be ActionBase -
Action is the factory function, not the base class. The other was
a typo in the error raised in _add_cppdefines - the message was
formatted with the value of "define" which should have been "defines".
Signed-off-by: Mats Wichmann <mats@linux.com>
Diffstat (limited to 'SCons/Memoize.py')
-rw-r--r-- | SCons/Memoize.py | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/SCons/Memoize.py b/SCons/Memoize.py index b02c1445b..c59434823 100644 --- a/SCons/Memoize.py +++ b/SCons/Memoize.py @@ -111,7 +111,7 @@ class Counter: fill in the correct class name and method name that represents the name of the function being counted. """ - def __init__(self, cls_name, method_name): + def __init__(self, cls_name, method_name) -> None: """ """ self.cls_name = cls_name @@ -120,7 +120,7 @@ class Counter: self.miss = 0 def key(self): return self.cls_name+'.'+self.method_name - def display(self): + def display(self) -> None: print(" {:7d} hits {:7d} misses {}()".format(self.hit, self.miss, self.key())) def __eq__(self, other): try: @@ -136,7 +136,7 @@ class CountValue(Counter): the class's methods that memoizes its return value by simply storing the return value in its _memo dictionary. """ - def count(self, *args, **kw): + def count(self, *args, **kw) -> None: """ Counts whether the memoized value has already been set (a hit) or not (a miss). """ @@ -156,12 +156,12 @@ class CountDict(Counter): indexed by some key that can be computed from one or more of its input arguments. """ - def __init__(self, cls_name, method_name, keymaker): + def __init__(self, cls_name, method_name, keymaker) -> None: """ """ super().__init__(cls_name, method_name) self.keymaker = keymaker - def count(self, *args, **kw): + def count(self, *args, **kw) -> None: """ Counts whether the computed key value is already present in the memoization dictionary (a hit) or not (a miss). """ @@ -177,7 +177,7 @@ class CountDict(Counter): else: self.miss = self.miss + 1 -def Dump(title=None): +def Dump(title=None) -> None: """ Dump the hit/miss count for all the counters collected so far. """ @@ -186,7 +186,7 @@ def Dump(title=None): for counter in sorted(CounterList): CounterList[counter].display() -def EnableMemoization(): +def EnableMemoization() -> None: global use_memoizer use_memoizer = 1 |