# _importer

URL: /pounce/api/_importer/
Section: api
Description: Application importer — resolves string references to ASGI callables.

Handles the standard "module:attribute" pattern used by ASGI servers:

    "myapp:app"              → import myapp; return myapp.app
    "myapp.web:app"          → import myapp.web; return myapp.web.app
    "myapp:create_app()"     → import myapp; return myapp.create_app()

For development mode, `reimport_app`() clears project-local modules
from ``sys.modules`` before re-importing, so that code changes on disk
are picked up without a full process restart.

---

> For a complete page index, fetch /pounce/llms.txt.

Open LLM text
(/pounce/api/_importer/index.txt)

Share with AI

Ask Claude
(https://claude.ai/new?q=Please%20help%20me%20understand%20this%20documentation%3A%20%2Fpounce%2Fapi%2F_importer%2Findex.txt)

Ask ChatGPT
(https://chatgpt.com/?q=Please%20help%20me%20understand%20this%20documentation%3A%20%2Fpounce%2Fapi%2F_importer%2Findex.txt)

Ask Gemini
(https://gemini.google.com/app?q=Please%20help%20me%20understand%20this%20documentation%3A%20%2Fpounce%2Fapi%2F_importer%2Findex.txt)

Ask Copilot
(https://copilot.microsoft.com/?q=Please%20help%20me%20understand%20this%20documentation%3A%20%2Fpounce%2Fapi%2F_importer%2Findex.txt)

Module

#
`_importer`

Application importer — resolves string references to ASGI callables.

Handles the standard "module:attribute" pattern used by ASGI servers:

```
"myapp:app"              → import myapp; return myapp.app
"myapp.web:app"          → import myapp.web; return myapp.web.app
"myapp:create_app()"     → import myapp; return myapp.create_app()
```

For development mode,`reimport_app`() clears project-local modules
from`sys.modules`before re-importing, so that code changes on disk
are picked up without a full process restart.

3Functions

## Functions

`import_app`

1

`ASGIApp`

▼

Resolve an application string to an ASGI callable.

`def import_app(app_path: str) -> ASGIApp`

##### Parameters

Name
Type
Description

`app_path`
`str`

Application reference in "module:attribute" format. Optionally, the attribute may end with "()" to call a factory.

##### Returns

`ASGIApp`

`reimport_app`

2

`ASGIApp`

▼

Re-import an ASGI app, clearing cached local modules first.

Evicts all ``sys.m…

`def reimport_app(app_path: str, base_dirs: list[str] | None = None) -> ASGIApp`

Re-import an ASGI app, clearing cached local modules first.

Evicts all`sys.modules`entries whose source file lives under one
of the base_dirs (defaults to the current working directory), then
re-imports the application via `import_app` (/pounce/api/_importer/#import_app)(). This forces
Python to re-execute module source, picking up code changes saved
since the last load.

##### Parameters

Name
Type
Description

`app_path`
`str`

Application reference in`"module:attribute"`format.

`base_dirs`
`list[str] | None`

Directories whose modules should be evicted from the module cache. Defaults to`[os.getcwd()]`.

Default:`None`

##### Returns

`ASGIApp`

`_clear_local_modules`

1

`list[str]`

▼

Remove project-local modules from ``sys.modules``.

A module is considered "loc…

`def _clear_local_modules(base_dirs: list[str] | None = None) -> list[str]`

Remove project-local modules from`sys.modules`.

A module is considered "local" when its`__file__`attribute
resolves to a path under one of the base_dirs. Third-party
packages (installed in site-packages) and the standard library are
left untouched.

##### Parameters

Name
Type
Description

`base_dirs`
`list[str] | None`

Directories to treat as project roots. Defaults to`[os.getcwd()]`.

Default:`None`

##### Returns

`list[str]`
