diff --git a/pytensor/configparser.py b/pytensor/configparser.py index e587782e40..8c6da4a144 100644 --- a/pytensor/configparser.py +++ b/pytensor/configparser.py @@ -236,11 +236,7 @@ def add(self, name: str, doc: str, configparam: "ConfigParam", in_c_key: bool): raise ValueError( f"Dot-based sections were removed. Use double underscores! ({name})" ) - # Can't use hasattr here, because it returns False upon AttributeErrors - if name in dir(self): - raise AttributeError( - f"A config parameter with the name '{name}' was already registered on another config instance." - ) + configparam.doc = doc configparam.name = name configparam.in_c_key = in_c_key diff --git a/tests/test_config.py b/tests/test_config.py index 73c1408e03..4370309f39 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -194,15 +194,6 @@ def test_invalid_configvar_access(): with pytest.raises(configparser.ConfigAccessViolation, match="different instance"): print(root.test__on_test_instance) - # And also that we can't add two configs of the same name to different instances: - with pytest.raises(AttributeError, match="already registered"): - root.add( - "test__on_test_instance", - "This config setting was already added to another instance.", - configparser.IntParam(5), - in_c_key=False, - ) - def test_no_more_dotting(): root = configdefaults.config