Skip to content

Commit 4783f29

Browse files
authored
Merge pull request #156 from krcb197/155-bug-fixes-from-pylint-331
Fix for excessive positional arguments
2 parents ea9da62 + 60e1e3c commit 4783f29

10 files changed

Lines changed: 45 additions & 38 deletions

File tree

src/peakrdl_python/__about__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@
1717
1818
Variables that describes the peakrdl-python Package
1919
"""
20-
__version__ = "0.9.0"
20+
__version__ = "0.9.1"

src/peakrdl_python/__peakrdl__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,9 @@ def do_export(self, top_node: 'AddrmapNode', options: 'argparse.Namespace') -> N
109109
user_template_context=user_template_context)
110110

111111
peakrdl_exporter.export(
112-
top_node,
113-
options.output,
114-
options.is_async,
112+
node=top_node,
113+
path=options.output,
114+
asyncoutput=options.is_async,
115115
skip_test_case_generation=options.skip_test_case_generation,
116116
delete_existing_package_content=not options.suppress_cleanup,
117117
legacy_block_access=options.legacy_block_access,

src/peakrdl_python/exporter.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,8 @@ def __stream_jinja_template(self,
290290
stream = template.stream(template_context)
291291
stream.dump(fp)
292292

293-
def __export_reg_model(self, # pylint: disable=too-many-arguments
293+
# pylint: disable-next=too-many-arguments
294+
def __export_reg_model(self, *,
294295
top_block: AddrmapNode,
295296
package: _Package,
296297
skip_lib_copy: bool,
@@ -359,7 +360,7 @@ def __export_reg_model(self, # pylint: disable=too-many-arguments
359360
target_name=top_block.inst_name + '.py',
360361
template_context=context)
361362

362-
def __export_simulator(self,
363+
def __export_simulator(self, *,
363364
top_block: AddrmapNode,
364365
package: _Package,
365366
skip_lib_copy: bool,
@@ -384,7 +385,7 @@ def __export_simulator(self,
384385
target_name=top_block.inst_name + '.py',
385386
template_context=context)
386387

387-
def __export_example(self,
388+
def __export_example(self, *,
388389
top_block: AddrmapNode,
389390
package: _Package,
390391
skip_lib_copy: bool,
@@ -409,7 +410,7 @@ def __export_example(self,
409410
target_name='example.py',
410411
template_context=context)
411412

412-
def __export_base_tests(self,
413+
def __export_base_tests(self, *,
413414
top_block: AddrmapNode,
414415
package: _Package,
415416
skip_lib_copy: bool,
@@ -446,7 +447,8 @@ def __export_base_tests(self,
446447
target_name='_' + top_block.inst_name + '_sim_test_base.py',
447448
template_context=context)
448449

449-
def __export_tests(self, # pylint: disable=too-many-arguments
450+
# pylint: disable-next=too-many-arguments
451+
def __export_tests(self, *,
450452
top_block: AddrmapNode,
451453
package: _Package,
452454
skip_lib_copy: bool,
@@ -566,7 +568,8 @@ def _validate_udp_to_include(self, udp_to_include: Optional[List[str]]) -> None:
566568
raise RuntimeError('It is not permitted to expose a property name used to'
567569
' build the peakrdl-python wrappers: ' + reserved_name)
568570

569-
def export(self, node: Node, path: str, # pylint: disable=too-many-arguments
571+
# pylint: disable-next=too-many-arguments
572+
def export(self, node: Node, path: str, *,
570573
asyncoutput: bool = False,
571574
skip_test_case_generation: bool = False,
572575
delete_existing_package_content: bool = True,

src/peakrdl_python/lib/async_memory.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ class _MemoryAsyncWriteOnly(AsyncMemory, ABC):
366366
__slots__: List[str] = []
367367

368368
# pylint: disable=too-many-arguments
369-
def __init__(self,
369+
def __init__(self, *,
370370
address: int,
371371
width: int,
372372
accesswidth: int,

src/peakrdl_python/lib/fields.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ class to hold the key attributes of a field
4444
"""
4545
__slots__ = ['__msb', '__lsb', '__width', '__high', '__low']
4646

47-
def __init__(self, width: int, msb: int, lsb: int, high: int, low: int): #pylint: disable=too-many-arguments
47+
# pylint: disable-next=too-many-arguments
48+
def __init__(self, *, width: int, msb: int, lsb: int, high: int, low: int):
4849
self.__width = width
4950
self.__msb = msb
5051
self.__lsb = lsb

src/peakrdl_python/lib/memory.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -231,8 +231,8 @@ class _MemoryReadOnly(Memory, ABC):
231231

232232
__slots__: List[str] = []
233233

234-
# pylint: disable=too-many-arguments
235-
def __init__(self,
234+
# pylint: disable-next=too-many-arguments
235+
def __init__(self, *,
236236
address: int,
237237
width: int,
238238
accesswidth: int,
@@ -500,8 +500,8 @@ class _MemoryWriteOnly(Memory, ABC):
500500
"""
501501
__slots__: List[str] = []
502502

503-
# pylint: disable=too-many-arguments
504-
def __init__(self,
503+
# pylint: disable-next=too-many-arguments
504+
def __init__(self, *,
505505
address: int,
506506
width: int,
507507
accesswidth: int,

tests/unit_tests/simple_components.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class FieldToTest(FieldReadOnly):
2525
__slots__: List[str] = []
2626

2727
# pylint: disable=duplicate-code,too-many-arguments
28-
def __init__(self,
28+
def __init__(self, *,
2929
address: int,
3030
accesswidth:int,
3131
width:int,
@@ -89,6 +89,7 @@ def systemrdl_python_child_name_map(self) -> Dict[str, str]:
8989
'field': 'field',
9090
}
9191

92+
9293
class WriteOnlyRegisterToTest(RegWriteOnly):
9394
"""
9495
Class to represent a register in the register model
@@ -102,7 +103,7 @@ class FieldToTest(FieldWriteOnly):
102103
"""
103104
__slots__: List[str] = []
104105

105-
def __init__(self,
106+
def __init__(self, *,
106107
address: int,
107108
accesswidth: int,
108109
width: int,
@@ -169,6 +170,7 @@ def systemrdl_python_child_name_map(self) -> Dict[str, str]:
169170
'field': 'field',
170171
}
171172

173+
172174
class ReadWriteRegisterToTest(RegReadWrite):
173175
"""
174176
Class to represent a register in the register model
@@ -182,7 +184,7 @@ class FieldToTest(FieldReadWrite):
182184
"""
183185
__slots__: List[str] = []
184186

185-
def __init__(self,
187+
def __init__(self, *,
186188
address: int,
187189
accesswidth: int,
188190
width: int,
@@ -256,6 +258,7 @@ def systemrdl_python_child_name_map(self) -> Dict[str, str]:
256258
'field': 'field',
257259
}
258260

261+
259262
class ReadOnlyRegisterArrayToTest(RegReadOnlyArray):
260263
"""
261264
Class to represent a register array in the register model
@@ -266,6 +269,7 @@ class ReadOnlyRegisterArrayToTest(RegReadOnlyArray):
266269
def _element_datatype(self) -> Type[Node]:
267270
return ReadOnlyRegisterToTest
268271

272+
269273
class WriteOnlyRegisterArrayToTest(RegWriteOnlyArray):
270274
"""
271275
Class to represent a register array in the register model
@@ -276,6 +280,7 @@ class WriteOnlyRegisterArrayToTest(RegWriteOnlyArray):
276280
def _element_datatype(self) -> Type[Node]:
277281
return WriteOnlyRegisterToTest
278282

283+
279284
class ReadWriteRegisterArrayToTest(RegReadWriteArray):
280285
"""
281286
Class to represent a register array in the register model

tests/unit_tests/test_array_indexing.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ def calculate_address(self, indices: Tuple[int, ...]) -> int:
5353
address based on array index
5454
"""
5555

56-
5756
def setUp(self) -> None:
5857

5958
class DUTWrapper(AddressMap):
@@ -62,15 +61,14 @@ class DUTWrapper(AddressMap):
6261
"""
6362

6463
# pylint: disable=too-many-arguments,duplicate-code
65-
def __init__(self,
64+
def __init__(self, *,
6665
callbacks: Optional[CallbackSet],
6766
address: int,
6867
logger_handle: str,
6968
inst_name: str,
7069
dut_stride : int,
7170
dut_dimensions : Tuple[int, ...]):
7271

73-
7472
super().__init__(callbacks=callbacks, address=address, logger_handle=logger_handle,
7573
inst_name=inst_name, parent=None )
7674

@@ -187,6 +185,7 @@ def test_slice(self) -> None:
187185
with self.assertRaises(IndexError):
188186
_ = subset_slice[index]
189187

188+
190189
class Test2DArray(ArrayBase):
191190
"""
192191
Test for 2D arrays
@@ -257,5 +256,6 @@ def test_inner_section(self) -> None:
257256
for index, entry in zip(product(range(2,8), range(3,9)), chunk):
258257
self.assertEqual(entry.address, self.calculate_address(index))
259258

259+
260260
if __name__ == '__main__':
261261
unittest.main()

tests/unit_tests/test_optimised_reg_array.py

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ def calculate_address(self, indices: Tuple[int, ...]) -> int:
6262
address based on array index
6363
"""
6464

65-
6665
def setUp(self) -> None:
6766

6867
class DUTWrapper(AddressMap):
@@ -71,7 +70,7 @@ class DUTWrapper(AddressMap):
7170
"""
7271

7372
# pylint: disable=too-many-arguments,duplicate-code
74-
def __init__(self,
73+
def __init__(self, *,
7574
callbacks: Optional[CallbackSet],
7675
address: int,
7776
logger_handle: str,
@@ -80,18 +79,17 @@ def __init__(self,
8079
dut_dimensions : Tuple[int, ...],
8180
RegisterArrayType):
8281

83-
8482
super().__init__(callbacks=callbacks, address=address, logger_handle=logger_handle,
8583
inst_name=inst_name, parent=None )
8684

8785
self.__dut = RegisterArrayType(logger_handle='dut',
88-
inst_name='dut',
89-
parent=self,
90-
address=address,
91-
accesswidth=32,
92-
width=32,
93-
stride=dut_stride,
94-
dimensions=dut_dimensions)
86+
inst_name='dut',
87+
parent=self,
88+
address=address,
89+
accesswidth=32,
90+
width=32,
91+
stride=dut_stride,
92+
dimensions=dut_dimensions)
9593

9694
def get_memories(self, unroll: bool = False) -> \
9795
Iterator[Union[Memory, Tuple[Memory, ...]]]:
@@ -221,14 +219,13 @@ def test_block_context_manager(self):
221219
with self.dut.single_read_modify_write(verify=True) as dut_context:
222220
dut_context[2].write(4)
223221

224-
225-
226222
def test_blockless_context_manager(self):
227223
"""
228224
test the context manager that will perform a set of read operation,
229225
modify write operations with optional read-verify
230226
"""
231227

228+
232229
class Test1DArrayReadOnly(ArrayBase):
233230
"""
234231
Test for 1D arrays
@@ -289,6 +286,7 @@ def test_blockless_context_manager(self):
289286
modify write operations with optional read-verify
290287
"""
291288

289+
292290
class Test1DArrayWriteOnly(ArrayBase):
293291
"""
294292
Test for 1D arrays
@@ -354,6 +352,5 @@ def test_blockless_context_manager(self):
354352
"""
355353

356354

357-
358355
if __name__ == '__main__':
359356
unittest.main()

tests/unit_tests/test_reg.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class DUTWrapper(AddressMap):
4545
"""
4646

4747
# pylint: disable=duplicate-code
48-
def __init__(self,
48+
def __init__(self, *,
4949
callbacks: Optional[CallbackSet],
5050
address: int,
5151
logger_handle: str,
@@ -103,6 +103,7 @@ def size(self) -> int:
103103
logger_handle='dut_wrapper', inst_name='dut_wrapper',
104104
reg_type=self.reg_type)
105105

106+
106107
class TestReadOnly(RegTestBase):
107108
"""
108109
Test for read only register
@@ -129,7 +130,6 @@ def dut(self) -> ReadOnlyRegisterToTest:
129130
"""
130131
return cast(ReadOnlyRegisterToTest, self.dut_wrapper.dut)
131132

132-
133133
def test_register_read(self) -> None:
134134
"""
135135
Test register read
@@ -182,6 +182,7 @@ def test_context_manager_read(self) -> None:
182182

183183
write_patch.assert_not_called()
184184

185+
185186
class TestWrite(RegTestBase):
186187
"""
187188
Test for write only register
@@ -232,6 +233,7 @@ def test_register_write(self) -> None:
232233
accesswidth=self.dut.accesswidth, data=1)
233234
read_patch.assert_not_called()
234235

236+
235237
class TestReadWrite(RegTestBase):
236238
"""
237239
Test for read/write register
@@ -425,7 +427,6 @@ def test_read_fields(self) -> None:
425427
accesswidth=self.dut.accesswidth)
426428
write_patch.assert_not_called()
427429

428-
429430
def test_context_manager_read(self) -> None:
430431
"""
431432
Check the write back has occurred, this happens by default even if nothing has changed in

0 commit comments

Comments
 (0)