From 92158d8f0f52ce0db677c70a4948cc1f75713e1c Mon Sep 17 00:00:00 2001 From: whitequark Date: Mon, 23 Sep 2019 11:08:43 +0000 Subject: [PATCH] hdl.ast: make Signal(name=) a keyword-only argument. Almost no code would specify Signal(_, name) as a positional argument on purpose, but forgetting parens and accidentally placing signedness into the name position is so common that we had a test for it. --- nmigen/hdl/ast.py | 2 +- nmigen/test/test_hdl_ast.py | 6 ------ 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/nmigen/hdl/ast.py b/nmigen/hdl/ast.py index 6d891b3..d7ae092 100644 --- a/nmigen/hdl/ast.py +++ b/nmigen/hdl/ast.py @@ -729,7 +729,7 @@ class Signal(Value, DUID): attrs : dict """ - def __init__(self, shape=None, name=None, *, reset=0, reset_less=False, min=None, max=None, + def __init__(self, shape=None, *, name=None, reset=0, reset_less=False, min=None, max=None, attrs=None, decoder=None, src_loc_at=0): super().__init__(src_loc_at=src_loc_at) diff --git a/nmigen/test/test_hdl_ast.py b/nmigen/test/test_hdl_ast.py index 9f2fb41..1029c82 100644 --- a/nmigen/test/test_hdl_ast.py +++ b/nmigen/test/test_hdl_ast.py @@ -582,12 +582,6 @@ class SignalTestCase(FHDLTestCase): s2 = Signal(name="sig") self.assertEqual(s2.name, "sig") - def test_name_bad(self): - with self.assertRaises(TypeError, - msg="Name must be a string, not 'True'"): - # A common typo: forgetting to put parens around width and signedness - Signal(1, True) - def test_reset(self): s1 = Signal(4, reset=0b111, reset_less=True) self.assertEqual(s1.reset, 0b111) -- 2.30.2