Get the source from app_source. Args: app_source: function or module or str Returns: source code
(self, app_source: Any)
| 219 | return glbs |
| 220 | |
| 221 | def _get_source_from_app_source(self, app_source: Any) -> str: |
| 222 | """Get the source from app_source. |
| 223 | |
| 224 | Args: |
| 225 | app_source: function or module or str |
| 226 | |
| 227 | Returns: |
| 228 | source code |
| 229 | """ |
| 230 | if isinstance(app_source, str): |
| 231 | return app_source |
| 232 | source = inspect.getsource(app_source) |
| 233 | source = re.sub( |
| 234 | r"^\s*def\s+\w+\s*\(.*?\)(\s+->\s+\w+)?:", "", source, flags=re.DOTALL |
| 235 | ) |
| 236 | return textwrap.dedent(source) |
| 237 | |
| 238 | def _initialize_app(self): |
| 239 | # disable telemetry reporting for tests |