python: Improve type annotations in pystats
This fixes some errors and warning when running mypy. `gem5/src/python/m5/ext> mypy pystats` There is one error that is ignored, which is a bug in mypy. See https://github.com/python/mypy/issues/6040 Change-Id: I18b648c059da12bd30d612f0e265930b976f22b4 Signed-off-by: Jason Lowe-Power <jason@lowepower.com> Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/42644 Reviewed-by: Andreas Sandberg <andreas.sandberg@arm.com> Maintainer: Bobby R. Bruce <bbruce@ucdavis.edu> Tested-by: kokoro <noreply+kokoro@google.com>
This commit is contained in:
committed by
Jason Lowe-Power
parent
2dfa2ddc6f
commit
91f4ea6683
@@ -25,7 +25,8 @@
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
import re
|
||||
from typing import Callable, Dict, Iterator, List, Optional, Pattern, Union
|
||||
from typing import Callable, Dict, Iterator, List, Mapping, Optional, Pattern,\
|
||||
Union
|
||||
|
||||
from .jsonserializable import JsonSerializable
|
||||
from .statistic import Scalar, Statistic
|
||||
@@ -118,8 +119,10 @@ class Group(JsonSerializable):
|
||||
precompiled regex or a string in regex format
|
||||
"""
|
||||
if isinstance(regex, str):
|
||||
regex = re.compile(regex)
|
||||
yield from self.children(lambda _name: regex.search(_name))
|
||||
pattern = re.compile(regex)
|
||||
else:
|
||||
pattern = regex
|
||||
yield from self.children(lambda _name: bool(pattern.search(_name)))
|
||||
|
||||
class Vector(Group):
|
||||
"""
|
||||
@@ -129,7 +132,7 @@ class Vector(Group):
|
||||
accordance to decisions made in relation to
|
||||
https://gem5.atlassian.net/browse/GEM5-867.
|
||||
"""
|
||||
def __init__(self, scalar_map: Dict[str,Scalar]):
|
||||
def __init__(self, scalar_map: Mapping[str,Scalar]):
|
||||
super(Vector, self).__init__(
|
||||
type="Vector",
|
||||
time_conversion=None,
|
||||
|
||||
Reference in New Issue
Block a user