@@ -259,8 +259,8 @@ class BaseConfig:
259259 # List of plugins to use in the app.
260260 plugins : list [Plugin ] = dataclasses .field (default_factory = list )
261261
262- # List of fully qualified import paths of plugins to disable in the app (e.g. reflex.plugins.sitemap.SitemapPlugin) .
263- disable_plugins : list [str ] = dataclasses .field (default_factory = list )
262+ # List of plugin types to disable in the app.
263+ disable_plugins : list [type [ Plugin ] ] = dataclasses .field (default_factory = list )
264264
265265 # The transport method for client-server communication.
266266 transport : Literal ["websocket" , "polling" ] = "websocket"
@@ -358,6 +358,9 @@ def _post_init(self, **kwargs):
358358 for key , env_value in env_kwargs .items ():
359359 setattr (self , key , env_value )
360360
361+ # Normalize disable_plugins: convert strings and Plugin subclasses to instances.
362+ self ._normalize_disable_plugins ()
363+
361364 # Add builtin plugins if not disabled.
362365 if not self ._skip_plugins_checks :
363366 self ._add_builtin_plugins ()
@@ -374,16 +377,52 @@ def _post_init(self, **kwargs):
374377 msg = f"{ self ._prefixes [0 ]} REDIS_URL is required when using the redis state manager."
375378 raise ConfigError (msg )
376379
380+ def _normalize_disable_plugins (self ):
381+ """Normalize disable_plugins list entries to Plugin subclasses.
382+
383+ Handles backward compatibility by converting strings (fully qualified
384+ import paths) and Plugin instances to their associated classes.
385+ """
386+ normalized : list [type [Plugin ]] = []
387+ for entry in self .disable_plugins :
388+ if isinstance (entry , type ) and issubclass (entry , Plugin ):
389+ normalized .append (entry )
390+ elif isinstance (entry , Plugin ):
391+ normalized .append (type (entry ))
392+ elif isinstance (entry , str ):
393+ console .deprecate (
394+ feature_name = "Passing strings to disable_plugins" ,
395+ reason = "pass Plugin classes directly instead, e.g. disable_plugins=[SitemapPlugin]" ,
396+ deprecation_version = "0.8.28" ,
397+ removal_version = "0.9.0" ,
398+ )
399+ try :
400+ from reflex .environment import interpret_plugin_class_env
401+
402+ normalized .append (
403+ interpret_plugin_class_env (entry , "disable_plugins" )
404+ )
405+ except Exception :
406+ console .warn (
407+ f"Failed to import plugin from string { entry !r} in disable_plugins. "
408+ "Please pass Plugin subclasses directly." ,
409+ )
410+ else :
411+ console .warn (
412+ f"reflex.Config.disable_plugins should contain Plugin subclasses, but got { entry !r} ." ,
413+ )
414+ self .disable_plugins = normalized
415+
377416 def _add_builtin_plugins (self ):
378417 """Add the builtin plugins to the config."""
379418 for plugin in _PLUGINS_ENABLED_BY_DEFAULT :
380419 plugin_name = plugin .__module__ + "." + plugin .__qualname__
381- if plugin_name not in self .disable_plugins :
420+ if plugin not in self .disable_plugins :
382421 if not any (isinstance (p , plugin ) for p in self .plugins ):
383422 console .warn (
384423 f"`{ plugin_name } ` plugin is enabled by default, but not explicitly added to the config. "
385424 "If you want to use it, please add it to the `plugins` list in your config inside of `rxconfig.py`. "
386- f"To disable this plugin, set `disable_plugins ` to ` { [ plugin_name , * self . disable_plugins ]!r } ` ." ,
425+ f"To disable this plugin, add ` { plugin . __name__ } ` to the ` disable_plugins` list ." ,
387426 )
388427 self .plugins .append (plugin ())
389428 else :
@@ -394,16 +433,9 @@ def _add_builtin_plugins(self):
394433 )
395434
396435 for disabled_plugin in self .disable_plugins :
397- if not isinstance (disabled_plugin , str ):
398- console .warn (
399- f"reflex.Config.disable_plugins should only contain strings, but got { disabled_plugin !r} . "
400- )
401- if not any (
402- plugin .__module__ + "." + plugin .__qualname__ == disabled_plugin
403- for plugin in _PLUGINS_ENABLED_BY_DEFAULT
404- ):
436+ if disabled_plugin not in _PLUGINS_ENABLED_BY_DEFAULT :
405437 console .warn (
406- f"`{ disabled_plugin } ` is disabled in the config, but it is not a built-in plugin. "
438+ f"`{ disabled_plugin !r } ` is disabled in the config, but it is not a built-in plugin. "
407439 "Please remove it from the `disable_plugins` list in your config inside of `rxconfig.py`." ,
408440 )
409441
0 commit comments