mistercrunch opened a new pull request, #34345:
URL: https://github.com/apache/superset/pull/34345

     ## Summary
   
     This PR improves config access patterns throughout the Superset codebase 
to reduce circular import issues and prepare for better app factory patterns.
   
     ### Changes
   
     1. **Migrated easy cases to use `current_app.config`**: Files with Flask 
routes/views that have guaranteed app context now use `current_app.config` 
directly instead of importing from `superset.__init__.py`
   
     2. **Added `conf = current_app.config` alias**: For cleaner code, we use a 
short alias `conf` that references `current_app.config` (which is already a 
proxy)
   
     3. **Removed module-scoped config extractions**: Moved config access from 
module scope into methods/functions where app context is available
   
     4. **Added TODO markers**: Complex module-scoped cases are marked with `# 
TODO-CONF` for future refactoring
   
     ### Why These Changes?
   
     The current pattern of using `from superset import app` and then 
`app.config` at module scope has several issues:
   
     1. **Circular imports**: Since `superset/__init__.py` imports from many 
modules that then import back from it
     2. **App factory pattern**: Module-scoped config access prevents proper 
app factory usage for testing with different configs
     3. **Context requirements**: Flask's `current_app` is the recommended way 
to access config within request context
   
     ### Migration Strategy
   
     - **Easy wins first**: Views, APIs, and routes that already have app 
context
     - **Local variables**: For module-scoped variables, we create local 
variables within methods
     - **Preserve behavior**: All changes maintain exact same functionality 
while improving the pattern
   
     ### Files Modified
   
     - `superset/sqllab/api.py` - API endpoints
     - `superset/available_domains/api.py` - API endpoints
     - `superset/views/base.py` - View functions
     - `superset/models/core.py` - Database model with complex config usage
     - `superset/models/helpers.py` - Added local variable for 
ADVANCED_DATA_TYPES
     - `superset/connectors/sqla/models.py` - Removed unused ADVANCED_DATA_TYPES
   
     ### Testing
   
     - All changes are refactoring only - no functional changes
     - Existing tests continue to pass
     - Code compiles without import errors


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscr...@superset.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscr...@superset.apache.org
For additional commands, e-mail: notifications-h...@superset.apache.org

Reply via email to