@@ -51,13 +51,17 @@ def is_express_app(app: str, app_dir: str | None) -> bool:
5151 except Exception :
5252 return False
5353
54- return detector .found_shiny_express_import
54+ return detector .is_express_app ()
5555
5656
5757class DetectShinyExpressVisitor (ast .NodeVisitor ):
5858 def __init__ (self ):
5959 super ().__init__ ()
6060 self .found_shiny_express_import = False
61+ self .found_shiny_express_in_core = False
62+
63+ def is_express_app (self ) -> bool :
64+ return self .found_shiny_express_import and not self .found_shiny_express_in_core
6165
6266 def visit_Import (self , node : ast .Import ) -> None :
6367 if any (alias .name == "shiny.express" for alias in node .names ):
@@ -71,6 +75,20 @@ def visit_ImportFrom(self, node: ast.ImportFrom) -> None:
7175 ):
7276 self .found_shiny_express_import = True
7377
78+ def visit_Assign (self , node : ast .Assign ) -> None :
79+ for target in node .targets :
80+ # Look for the statement `shiny.express.allow_express_in_core = True` at the
81+ # top level.
82+ if (
83+ isinstance (target , ast .Attribute )
84+ and isinstance (target .value , ast .Attribute )
85+ and target .value .attr == "express"
86+ and isinstance (target .value .value , ast .Name )
87+ and target .value .value .id == "shiny"
88+ and target .attr == "allow_express_in_core"
89+ ):
90+ self .found_shiny_express_in_core = True
91+
7492 # Visit top-level nodes.
7593 def visit_Module (self , node : ast .Module ) -> None :
7694 super ().generic_visit (node )
0 commit comments