Skip to content

Commit 115203f

Browse files
committed
Update typechecking to use isinstance which is properly understood in all cases of mypy
1 parent c9c79c9 commit 115203f

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

src/peakrdl_python/templates/addrmap_simulation_tb.py.jinja

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,11 +130,14 @@ class {{fq_block_name}}_single_access({{top_node.inst_name}}_SimTestCase): # typ
130130
self.assertIsInstance(sim_register, (Register,MemoryRegister))
131131
sim_field = self.sim.field_by_full_name('{{'.'.join(node.get_path_segments())}}')
132132
{% if node.is_sw_readable and node.is_sw_writable -%}
133-
self.assertIsInstance(sim_field, ReadWriteField)
133+
if not isinstance(sim_field, ReadWriteField):
134+
raise TypeError(f'should be a simulated read/write field got {type(sim_field)}')
134135
{% elif node.is_sw_readable and not node.is_sw_writable -%}
135-
self.assertIsInstance(sim_field, ReadOnlyField)
136+
if not isinstance(sim_field, ReadOnlyField):
137+
raise TypeError(f'should be a simulated read/write field got {type(sim_field)}')
136138
{% elif not node.is_sw_readable and node.is_sw_writable -%}
137-
self.assertIsInstance(sim_field, WriteOnlyField)
139+
if not isinstance(sim_field, WriteOnlyField):
140+
raise TypeError(f'should be a simulated read/write field got {type(sim_field)}')
138141
{% endif %}
139142
register_read_callback = Mock()
140143
register_write_callback = Mock()

0 commit comments

Comments
 (0)