Skip to content

Commit

Permalink
Responding to comments
Browse files Browse the repository at this point in the history
  • Loading branch information
john-science committed Jun 27, 2022
1 parent 2a330db commit 03e7680
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
7 changes: 5 additions & 2 deletions armi/plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -626,12 +626,15 @@ def __enforceLimitations(self):
corral their side effects during a run.
"""
if issubclass(self.__class__, UserPlugin):
assert (
len(self.__class__.defineParameterRenames()) == 0
), "UserPlugins cannot define parameter renames"
assert (
len(self.__class__.defineSettings()) == 0
), "UserPlugins cannot define new Settings"
# NOTE: These are the class methods that we are staunchly _not_ allowing people
# to change in this class. If you need these, please use a regular ArmiPlugin.
self.defineParameterRenames = lambda: None
self.defineParameterRenames = lambda: {}
self.defineSettings = lambda: []
self.defineSettingsValidators = lambda: []

Expand All @@ -643,7 +646,7 @@ def defineParameterRenames():
It is a design limitation of user plugins that they not generate parameter renames,
so that they are able to be added to the plugin stack during run time.
"""
pass
return {}

@staticmethod
@HOOKSPEC
Expand Down
6 changes: 1 addition & 5 deletions armi/tests/test_user_plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ class UserPluginBadDefineParameterRenames(plugins.UserPlugin):
"""This is invalid/bad because it implements defineParameterRenames()"""

def defineParameterRenames():
self.danger = "danger"
return {"oldType": "type"}


class UserPluginOnProcessCoreLoading(plugins.UserPlugin):
Expand Down Expand Up @@ -162,10 +162,6 @@ def test_validateUserPluginLimitations(self):
with self.assertRaises(AssertionError):
bad0 = UserPluginBadDefinesSettings()

# overriding defineParameterRenames() is correctly fixed
bad1 = UserPluginBadDefineParameterRenames()
self.assertFalse(hasattr(bad1, "danger"))

def test_registerUserPlugins(self):
app = getApp()

Expand Down

0 comments on commit 03e7680

Please sign in to comment.