cocotb 1.9.2__cp36-cp36m-win_amd64.whl → 2.0.0b1__cp36-cp36m-win_amd64.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.

Potentially problematic release.


This version of cocotb might be problematic. Click here for more details.

Files changed (151) hide show
  1. cocotb/{ANSI.py → _ANSI.py} +5 -25
  2. cocotb/__init__.py +76 -332
  3. cocotb/_base_triggers.py +513 -0
  4. cocotb/_bridge.py +187 -0
  5. cocotb/_decorators.py +515 -0
  6. cocotb/_deprecation.py +3 -3
  7. cocotb/_exceptions.py +7 -0
  8. cocotb/_extended_awaitables.py +419 -0
  9. cocotb/_gpi_triggers.py +382 -0
  10. cocotb/_init.py +295 -0
  11. cocotb/_outcomes.py +54 -0
  12. cocotb/_profiling.py +46 -0
  13. cocotb/_py_compat.py +100 -29
  14. cocotb/_scheduler.py +454 -0
  15. cocotb/_test.py +245 -0
  16. cocotb/_test_factory.py +309 -0
  17. cocotb/_test_functions.py +42 -0
  18. cocotb/_typing.py +7 -0
  19. cocotb/_utils.py +296 -0
  20. cocotb/_version.py +3 -7
  21. cocotb/_xunit_reporter.py +66 -0
  22. cocotb/clock.py +271 -108
  23. cocotb/handle.py +1342 -795
  24. cocotb/libs/cocotb.dll +0 -0
  25. cocotb/libs/cocotb.exp +0 -0
  26. cocotb/libs/cocotb.lib +0 -0
  27. cocotb/libs/cocotbfli_modelsim.dll +0 -0
  28. cocotb/libs/cocotbfli_modelsim.exp +0 -0
  29. cocotb/libs/cocotbfli_modelsim.lib +0 -0
  30. cocotb/libs/cocotbutils.dll +0 -0
  31. cocotb/libs/cocotbutils.exp +0 -0
  32. cocotb/libs/cocotbutils.lib +0 -0
  33. cocotb/libs/cocotbvhpi_aldec.dll +0 -0
  34. cocotb/libs/cocotbvhpi_aldec.exp +0 -0
  35. cocotb/libs/cocotbvhpi_aldec.lib +0 -0
  36. cocotb/libs/cocotbvhpi_modelsim.dll +0 -0
  37. cocotb/libs/cocotbvhpi_modelsim.exp +0 -0
  38. cocotb/libs/cocotbvhpi_modelsim.lib +0 -0
  39. cocotb/libs/cocotbvpi_aldec.dll +0 -0
  40. cocotb/libs/cocotbvpi_aldec.exp +0 -0
  41. cocotb/libs/cocotbvpi_aldec.lib +0 -0
  42. cocotb/libs/cocotbvpi_ghdl.dll +0 -0
  43. cocotb/libs/cocotbvpi_ghdl.exp +0 -0
  44. cocotb/libs/cocotbvpi_ghdl.lib +0 -0
  45. cocotb/libs/cocotbvpi_icarus.exp +0 -0
  46. cocotb/libs/cocotbvpi_icarus.lib +0 -0
  47. cocotb/libs/cocotbvpi_icarus.vpl +0 -0
  48. cocotb/libs/cocotbvpi_modelsim.dll +0 -0
  49. cocotb/libs/cocotbvpi_modelsim.exp +0 -0
  50. cocotb/libs/cocotbvpi_modelsim.lib +0 -0
  51. cocotb/libs/embed.dll +0 -0
  52. cocotb/libs/embed.exp +0 -0
  53. cocotb/libs/embed.lib +0 -0
  54. cocotb/libs/gpi.dll +0 -0
  55. cocotb/libs/gpi.exp +0 -0
  56. cocotb/libs/gpi.lib +0 -0
  57. cocotb/libs/gpilog.dll +0 -0
  58. cocotb/libs/gpilog.exp +0 -0
  59. cocotb/libs/gpilog.lib +0 -0
  60. cocotb/libs/pygpilog.dll +0 -0
  61. cocotb/libs/pygpilog.exp +0 -0
  62. cocotb/libs/pygpilog.lib +0 -0
  63. cocotb/{log.py → logging.py} +105 -110
  64. cocotb/queue.py +103 -57
  65. cocotb/regression.py +667 -712
  66. cocotb/result.py +17 -188
  67. cocotb/share/def/aldec.exp +0 -0
  68. cocotb/share/def/aldec.lib +0 -0
  69. cocotb/share/def/ghdl.exp +0 -0
  70. cocotb/share/def/ghdl.lib +0 -0
  71. cocotb/share/def/icarus.exp +0 -0
  72. cocotb/share/def/icarus.lib +0 -0
  73. cocotb/share/def/modelsim.def +1 -0
  74. cocotb/share/def/modelsim.exp +0 -0
  75. cocotb/share/def/modelsim.lib +0 -0
  76. cocotb/share/include/cocotb_utils.h +6 -29
  77. cocotb/share/include/embed.h +5 -28
  78. cocotb/share/include/gpi.h +137 -92
  79. cocotb/share/include/gpi_logging.h +221 -142
  80. cocotb/share/include/py_gpi_logging.h +7 -4
  81. cocotb/share/include/vpi_user_ext.h +4 -26
  82. cocotb/share/lib/verilator/verilator.cpp +59 -54
  83. cocotb/simulator.cp36-win_amd64.exp +0 -0
  84. cocotb/simulator.cp36-win_amd64.lib +0 -0
  85. cocotb/simulator.cp36-win_amd64.pyd +0 -0
  86. cocotb/task.py +434 -212
  87. cocotb/triggers.py +55 -1092
  88. cocotb/types/__init__.py +25 -47
  89. cocotb/types/_abstract_array.py +151 -0
  90. cocotb/types/_array.py +264 -0
  91. cocotb/types/_logic.py +296 -0
  92. cocotb/types/_logic_array.py +834 -0
  93. cocotb/types/{range.py → _range.py} +36 -44
  94. cocotb/types/_resolve.py +76 -0
  95. cocotb/utils.py +119 -587
  96. cocotb-2.0.0b1.dist-info/METADATA +48 -0
  97. cocotb-2.0.0b1.dist-info/RECORD +139 -0
  98. cocotb-2.0.0b1.dist-info/entry_points.txt +3 -0
  99. {cocotb-1.9.2.dist-info → cocotb-2.0.0b1.dist-info}/top_level.txt +1 -0
  100. cocotb_tools/_coverage.py +33 -0
  101. cocotb_tools/_vendor/__init__.py +3 -0
  102. cocotb_tools/check_results.py +65 -0
  103. cocotb_tools/combine_results.py +152 -0
  104. cocotb_tools/config.py +241 -0
  105. {cocotb → cocotb_tools}/ipython_support.py +29 -22
  106. cocotb_tools/makefiles/Makefile.deprecations +27 -0
  107. {cocotb/share → cocotb_tools}/makefiles/Makefile.inc +82 -54
  108. {cocotb/share → cocotb_tools}/makefiles/Makefile.sim +8 -33
  109. {cocotb/share → cocotb_tools}/makefiles/simulators/Makefile.activehdl +9 -16
  110. cocotb_tools/makefiles/simulators/Makefile.cvc +61 -0
  111. cocotb_tools/makefiles/simulators/Makefile.dsim +39 -0
  112. {cocotb/share → cocotb_tools}/makefiles/simulators/Makefile.ghdl +13 -42
  113. cocotb_tools/makefiles/simulators/Makefile.icarus +80 -0
  114. cocotb_tools/makefiles/simulators/Makefile.ius +93 -0
  115. cocotb_tools/makefiles/simulators/Makefile.modelsim +9 -0
  116. cocotb_tools/makefiles/simulators/Makefile.nvc +60 -0
  117. cocotb_tools/makefiles/simulators/Makefile.questa +29 -0
  118. cocotb/share/makefiles/simulators/Makefile.questa → cocotb_tools/makefiles/simulators/Makefile.questa-compat +26 -54
  119. cocotb_tools/makefiles/simulators/Makefile.questa-qisqrun +149 -0
  120. {cocotb/share → cocotb_tools}/makefiles/simulators/Makefile.riviera +17 -56
  121. cocotb_tools/makefiles/simulators/Makefile.vcs +65 -0
  122. {cocotb/share → cocotb_tools}/makefiles/simulators/Makefile.verilator +15 -22
  123. {cocotb/share → cocotb_tools}/makefiles/simulators/Makefile.xcelium +20 -52
  124. {cocotb → cocotb_tools}/runner.py +794 -361
  125. cocotb/_sim_versions.py → cocotb_tools/sim_versions.py +16 -21
  126. pygpi/entry.py +34 -17
  127. cocotb/binary.py +0 -858
  128. cocotb/config.py +0 -289
  129. cocotb/decorators.py +0 -332
  130. cocotb/memdebug.py +0 -35
  131. cocotb/outcomes.py +0 -56
  132. cocotb/scheduler.py +0 -1099
  133. cocotb/share/makefiles/Makefile.deprecations +0 -12
  134. cocotb/share/makefiles/simulators/Makefile.cvc +0 -94
  135. cocotb/share/makefiles/simulators/Makefile.icarus +0 -111
  136. cocotb/share/makefiles/simulators/Makefile.ius +0 -125
  137. cocotb/share/makefiles/simulators/Makefile.modelsim +0 -32
  138. cocotb/share/makefiles/simulators/Makefile.nvc +0 -64
  139. cocotb/share/makefiles/simulators/Makefile.vcs +0 -98
  140. cocotb/types/array.py +0 -309
  141. cocotb/types/logic.py +0 -292
  142. cocotb/types/logic_array.py +0 -298
  143. cocotb/wavedrom.py +0 -199
  144. cocotb/xunit_reporter.py +0 -80
  145. cocotb-1.9.2.dist-info/METADATA +0 -170
  146. cocotb-1.9.2.dist-info/RECORD +0 -121
  147. cocotb-1.9.2.dist-info/entry_points.txt +0 -3
  148. {cocotb-1.9.2.dist-info → cocotb-2.0.0b1.dist-info}/LICENSE +0 -0
  149. {cocotb-1.9.2.dist-info → cocotb-2.0.0b1.dist-info}/WHEEL +0 -0
  150. {cocotb/_vendor → cocotb_tools}/__init__.py +0 -0
  151. {cocotb → cocotb_tools}/_vendor/distutils_version.py +0 -0
cocotb/libs/cocotb.dll CHANGED
Binary file
cocotb/libs/cocotb.exp CHANGED
Binary file
cocotb/libs/cocotb.lib CHANGED
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
cocotb/libs/embed.dll CHANGED
Binary file
cocotb/libs/embed.exp CHANGED
Binary file
cocotb/libs/embed.lib CHANGED
Binary file
cocotb/libs/gpi.dll CHANGED
Binary file
cocotb/libs/gpi.exp CHANGED
Binary file
cocotb/libs/gpi.lib CHANGED
Binary file
cocotb/libs/gpilog.dll CHANGED
Binary file
cocotb/libs/gpilog.exp CHANGED
Binary file
cocotb/libs/gpilog.lib CHANGED
Binary file
cocotb/libs/pygpilog.dll CHANGED
Binary file
cocotb/libs/pygpilog.exp CHANGED
Binary file
cocotb/libs/pygpilog.lib CHANGED
Binary file
@@ -1,29 +1,8 @@
1
+ # Copyright cocotb contributors
1
2
  # Copyright (c) 2013, 2018 Potential Ventures Ltd
2
3
  # Copyright (c) 2013 SolarFlare Communications Inc
3
- # All rights reserved.
4
- #
5
- # Redistribution and use in source and binary forms, with or without
6
- # modification, are permitted provided that the following conditions are met:
7
- # * Redistributions of source code must retain the above copyright
8
- # notice, this list of conditions and the following disclaimer.
9
- # * Redistributions in binary form must reproduce the above copyright
10
- # notice, this list of conditions and the following disclaimer in the
11
- # documentation and/or other materials provided with the distribution.
12
- # * Neither the name of Potential Ventures Ltd,
13
- # SolarFlare Communications Inc nor the
14
- # names of its contributors may be used to endorse or promote products
15
- # derived from this software without specific prior written permission.
16
- #
17
- # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
18
- # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19
- # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20
- # DISCLAIMED. IN NO EVENT SHALL POTENTIAL VENTURES LTD BE LIABLE FOR ANY
21
- # DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22
- # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23
- # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24
- # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25
- # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26
- # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
4
+ # Licensed under the Revised BSD License, see LICENSE for details.
5
+ # SPDX-License-Identifier: BSD-3-Clause
27
6
 
28
7
  """
29
8
  Everything related to logging
@@ -32,12 +11,14 @@ Everything related to logging
32
11
  import logging
33
12
  import os
34
13
  import sys
35
- import typing
36
- import warnings
14
+ from functools import wraps
15
+ from pathlib import Path
16
+ from typing import Union
37
17
 
38
- import cocotb.ANSI as ANSI
39
- from cocotb import simulator
40
- from cocotb.utils import get_sim_time, get_time_from_sim_steps, want_color_output
18
+ from cocotb import _ANSI, simulator
19
+ from cocotb._deprecation import deprecated
20
+ from cocotb._utils import want_color_output
21
+ from cocotb.utils import get_sim_time, get_time_from_sim_steps
41
22
 
42
23
  try:
43
24
  _suppress = int(os.environ.get("COCOTB_REDUCED_LOG_FMT", "1"))
@@ -52,14 +33,20 @@ _LINENO_CHARS = 4
52
33
  _FUNCNAME_CHARS = 31
53
34
 
54
35
  # Custom log level
55
- logging.TRACE = 5
36
+ logging.TRACE = 5 # type: ignore[attr-defined] # type checkers don't like adding module attributes after the fact
56
37
  logging.addLevelName(5, "TRACE")
57
38
 
58
- # Default log level if not overwritten by the user.
59
- _COCOTB_LOG_LEVEL_DEFAULT = "INFO"
60
39
 
40
+ __all__ = (
41
+ "SimColourLogFormatter",
42
+ "SimLog",
43
+ "SimLogFormatter",
44
+ "SimTimeContextFilter",
45
+ "default_config",
46
+ )
61
47
 
62
- def default_config():
48
+
49
+ def default_config() -> None:
63
50
  """Apply the default cocotb log formatting to the root logger.
64
51
 
65
52
  This hooks up the logger to write to stdout, using either
@@ -68,17 +55,16 @@ def default_config():
68
55
  :class:`SimTimeContextFilter` filter so that
69
56
  :attr:`~logging.LogRecord.created_sim_time` is available to the formatter.
70
57
 
71
- The logging level for cocotb logs is set based on the
72
- :envvar:`COCOTB_LOG_LEVEL` environment variable, which defaults to ``INFO``.
73
-
74
58
  If desired, this logging configuration can be overwritten by calling
75
59
  ``logging.basicConfig(..., force=True)`` (in Python 3.8 onwards), or by
76
60
  manually resetting the root logger instance.
77
61
  An example of this can be found in the section on :ref:`rotating-logger`.
78
62
 
79
63
  .. versionadded:: 1.4
64
+
65
+ .. versionchanged:: 2.0
66
+ No longer set the log level of the ``cocotb`` and ``gpi`` loggers.
80
67
  """
81
- # construct an appropriate handler
82
68
  hdlr = logging.StreamHandler(sys.stdout)
83
69
  hdlr.addFilter(SimTimeContextFilter())
84
70
  if want_color_output():
@@ -86,66 +72,71 @@ def default_config():
86
72
  else:
87
73
  hdlr.setFormatter(SimLogFormatter())
88
74
 
89
- logging.setLoggerClass(SimBaseLog) # For backwards compatibility
90
75
  logging.basicConfig()
91
76
  logging.getLogger().handlers = [hdlr] # overwrite default handlers
92
77
 
93
- # apply level settings for cocotb
94
- log = logging.getLogger("cocotb")
95
-
96
- try:
97
- # All log levels are upper case, convert the user input for convenience.
98
- level = os.environ["COCOTB_LOG_LEVEL"].upper()
99
- except KeyError:
100
- level = _COCOTB_LOG_LEVEL_DEFAULT
101
-
102
- try:
103
- log.setLevel(level)
104
- except ValueError:
105
- valid_levels = ("CRITICAL", "ERROR", "WARNING", "INFO", "DEBUG", "TRACE")
106
- raise ValueError(
107
- "Invalid log level %r passed through the "
108
- "COCOTB_LOG_LEVEL environment variable. Valid log "
109
- "levels: %s" % (level, ", ".join(valid_levels))
110
- )
111
78
 
112
- # Notify GPI of log level, which it uses as an optimization to avoid
113
- # calling into Python.
114
- logging.getLogger("gpi").setLevel(level)
79
+ def _init(_: object) -> None:
80
+ """Set cocotb and pygpi log levels."""
115
81
 
82
+ # Monkeypatch "gpi" logger with function that also sets a PyGPI-local logger level
83
+ # as an optimization.
84
+ gpi_logger = logging.getLogger("gpi")
85
+ old_setLevel = gpi_logger.setLevel
116
86
 
117
- class SimBaseLog(logging.getLoggerClass()):
118
- """This class only exists for backwards compatibility"""
87
+ @wraps(old_setLevel)
88
+ def setLevel(level: Union[int, str]) -> None:
89
+ old_setLevel(level)
90
+ simulator.set_gpi_log_level(gpi_logger.getEffectiveLevel())
119
91
 
120
- @property
121
- def logger(self):
122
- warnings.warn(
123
- "the .logger attribute should not be used now that `SimLog` "
124
- "returns a native logger instance directly.",
125
- DeprecationWarning,
126
- stacklevel=2,
127
- )
128
- return self
129
-
130
- @property
131
- def colour(self):
132
- warnings.warn(
133
- "the .colour attribute may be removed in future, use the "
134
- "equivalent `cocotb.utils.want_color_output()` instead",
135
- DeprecationWarning,
136
- stacklevel=2,
137
- )
138
- return want_color_output()
92
+ gpi_logger.setLevel = setLevel # type: ignore[method-assign]
139
93
 
140
- def setLevel(self, level: typing.Union[int, str]) -> None:
141
- super().setLevel(level)
142
- if self.name == "gpi":
143
- simulator.log_level(self.getEffectiveLevel())
94
+ # Initialize PyGPI logging
95
+ simulator.initialize_logger(_log_from_c, logging.getLogger)
96
+
97
+ # Set "cocotb" and "gpi" logger based on environment variables
98
+ def set_level(logger_name: str, envvar: str, default_level: str) -> None:
99
+ log_level = os.environ.get(envvar, default_level)
100
+ log_level = log_level.upper()
101
+
102
+ logger = logging.getLogger(logger_name)
103
+
104
+ try:
105
+ logger.setLevel(log_level)
106
+ except ValueError:
107
+ valid_levels = ", ".join(
108
+ ("CRITICAL", "ERROR", "WARNING", "INFO", "DEBUG", "TRACE", "NOTSET")
109
+ )
110
+ raise ValueError(
111
+ f"Invalid log level {log_level!r} passed through the "
112
+ f"{envvar} environment variable. Valid log "
113
+ f"levels: {valid_levels}"
114
+ ) from None
144
115
 
116
+ set_level("gpi", "GPI_LOG_LEVEL", "INFO")
117
+ set_level("cocotb", "COCOTB_LOG_LEVEL", "INFO")
145
118
 
146
- # this used to be a class, hence the unusual capitalization
147
- def SimLog(name, ident=None):
148
- """Like logging.getLogger, but append a numeric identifier to the name"""
119
+
120
+ def _setup_formatter(_: object) -> None:
121
+ """Setup cocotb's logging formatter."""
122
+ default_config()
123
+
124
+
125
+ @deprecated('Use `logging.getLogger(f"{name}.0x{ident:x}")` instead')
126
+ def SimLog(name: str, ident: Union[int, None] = None) -> logging.Logger:
127
+ """Like logging.getLogger, but append a numeric identifier to the name.
128
+
129
+ Args:
130
+ name: Logger name.
131
+ ident: Unique integer identifier.
132
+
133
+ Returns:
134
+ The Logger named ``{name}.0x{ident:x}``.
135
+
136
+ .. deprecated:: 2.0
137
+
138
+ Use ``logging.getLogger(f"{name}.0x{ident:x}")`` instead.
139
+ """
149
140
  if ident is not None:
150
141
  name = f"{name}.0x{ident:x}"
151
142
  return logging.getLogger(name)
@@ -163,11 +154,11 @@ class SimTimeContextFilter(logging.Filter):
163
154
  """
164
155
 
165
156
  # needed to make our docs render well
166
- def __init__(self):
157
+ def __init__(self) -> None:
167
158
  """"""
168
159
  super().__init__()
169
160
 
170
- def filter(self, record):
161
+ def filter(self, record: logging.LogRecord) -> bool:
171
162
  try:
172
163
  record.created_sim_time = get_sim_time()
173
164
  except RecursionError:
@@ -187,24 +178,26 @@ class SimLogFormatter(logging.Formatter):
187
178
 
188
179
  # Removes the arguments from the base class. Docstring needed to make
189
180
  # sphinx happy.
190
- def __init__(self):
181
+ def __init__(self) -> None:
191
182
  """Takes no arguments."""
192
183
  super().__init__()
193
184
 
194
185
  # Justify and truncate
195
186
  @staticmethod
196
- def ljust(string, chars):
187
+ def ljust(string: str, chars: int) -> str:
197
188
  if len(string) > chars:
198
189
  return ".." + string[(chars - 2) * -1 :]
199
190
  return string.ljust(chars)
200
191
 
201
192
  @staticmethod
202
- def rjust(string, chars):
193
+ def rjust(string: str, chars: int) -> str:
203
194
  if len(string) > chars:
204
195
  return ".." + string[(chars - 2) * -1 :]
205
196
  return string.rjust(chars)
206
197
 
207
- def _format(self, level, record, msg, coloured=False):
198
+ def _format(
199
+ self, level: str, record: logging.LogRecord, msg: str, coloured: bool = False
200
+ ) -> str:
208
201
  sim_time = getattr(record, "created_sim_time", None)
209
202
  if sim_time is None:
210
203
  sim_time_str = " -.--ns"
@@ -221,7 +214,7 @@ class SimLogFormatter(logging.Formatter):
221
214
  )
222
215
  if not _suppress:
223
216
  prefix += (
224
- self.rjust(os.path.split(record.filename)[1], _FILENAME_CHARS)
217
+ self.rjust(Path(record.filename).name, _FILENAME_CHARS)
225
218
  + ":"
226
219
  + self.ljust(str(record.lineno), _LINENO_CHARS)
227
220
  + " in "
@@ -229,7 +222,7 @@ class SimLogFormatter(logging.Formatter):
229
222
  + " "
230
223
  )
231
224
 
232
- # these lines are copied from the builtin logger
225
+ # these lines are copied from the built-in logger
233
226
  if record.exc_info:
234
227
  # Cache the traceback text to avoid converting it multiple times
235
228
  # (it's constant anyway)
@@ -246,8 +239,8 @@ class SimLogFormatter(logging.Formatter):
246
239
  pad = "\n" + " " * (prefix_len)
247
240
  return prefix + pad.join(msg.split("\n"))
248
241
 
249
- def format(self, record):
250
- """Prettify the log output, annotate with simulation time"""
242
+ def format(self, record: logging.LogRecord) -> str:
243
+ """Prettify the log output by annotating with simulation time."""
251
244
 
252
245
  msg = record.getMessage()
253
246
  level = record.levelname.ljust(_LEVEL_CHARS)
@@ -259,16 +252,16 @@ class SimColourLogFormatter(SimLogFormatter):
259
252
  """Log formatter to provide consistent log message handling."""
260
253
 
261
254
  loglevel2colour = {
262
- logging.TRACE: "%s",
255
+ logging.TRACE: "%s", # type: ignore[attr-defined] # type checkers don't like adding module attributes after the fact
263
256
  logging.DEBUG: "%s",
264
257
  logging.INFO: "%s",
265
- logging.WARNING: ANSI.COLOR_WARNING + "%s" + ANSI.COLOR_DEFAULT,
266
- logging.ERROR: ANSI.COLOR_ERROR + "%s" + ANSI.COLOR_DEFAULT,
267
- logging.CRITICAL: ANSI.COLOR_CRITICAL + "%s" + ANSI.COLOR_DEFAULT,
258
+ logging.WARNING: _ANSI.COLOR_WARNING + "%s" + _ANSI.COLOR_DEFAULT,
259
+ logging.ERROR: _ANSI.COLOR_ERROR + "%s" + _ANSI.COLOR_DEFAULT,
260
+ logging.CRITICAL: _ANSI.COLOR_CRITICAL + "%s" + _ANSI.COLOR_DEFAULT,
268
261
  }
269
262
 
270
- def format(self, record):
271
- """Prettify the log output, annotate with simulation time"""
263
+ def format(self, record: logging.LogRecord) -> str:
264
+ """Prettify the log output by annotating with simulation time."""
272
265
 
273
266
  msg = record.getMessage()
274
267
 
@@ -286,18 +279,20 @@ class SimColourLogFormatter(SimLogFormatter):
286
279
  return self._format(level, record, msg, coloured=True)
287
280
 
288
281
 
289
- def _filter_from_c(logger_name, level):
290
- return logging.getLogger(logger_name).isEnabledFor(level)
291
-
292
-
293
- def _log_from_c(logger_name, level, filename, lineno, msg, function_name):
282
+ def _log_from_c(
283
+ logger: logging.Logger,
284
+ level: int,
285
+ filename: str,
286
+ lineno: int,
287
+ msg: str,
288
+ function_name: str,
289
+ ) -> None:
294
290
  """
295
291
  This is for use from the C world, and allows us to insert C stack
296
292
  information.
297
293
  """
298
- logger = logging.getLogger(logger_name)
299
294
  if logger.isEnabledFor(level):
300
295
  record = logger.makeRecord(
301
- logger.name, level, filename, lineno, msg, None, None, function_name
296
+ logger.name, level, filename, lineno, msg, (), None, function_name
302
297
  )
303
298
  logger.handle(record)