Skip to content

Import resolution ​

text
name at a use site ─► import statement ─► module ─► exported symbol ─► declaration

Added by the M07 remediation. M07 measured 286 OrmAccess edges whose model name was imported from somewhere other than the model's own module, and a sample showed why that matters: Onyx's Airtable connector imports Document from connectors/models.py, a Pydantic BaseModel, while the SQLAlchemy Document lives in db/models.py. Matching a name against a project-wide map cannot tell them apart.

What resolves ​

LanguageFormExample
Pythonabsolutefrom app.models import Order
Pythonrelativefrom .models import Order, from ..models import Order
Pythonpackageresolved through __init__.py
Pythonaliasfrom app.models import Order as OrderModel
Pythonre-exporta module that imports a name and is imported for it
TypeScriptnamedimport { X } from "./m"
TypeScriptdefaultimport X from "./m"
TypeScriptnamespaceimport * as m from "./m"
TypeScriptre-exportexport { X } from "./m", export * from "./m"
TypeScriptbuild aliasresolve: { alias: { openapi: "/openapi-gen" } } in a Vite configuration

A dotted Python path is matched as a path suffix anchored at a separator, because a project may be rooted under any number of source directories — backend/, src/, airflow-core/src/. ics.models therefore cannot be satisfied by analytics/models.py.

A TypeScript build alias governs only files beneath the configuration that declares it. Airflow has five Vite configurations, several declaring an alias named src; a global alias list resolves imports into the wrong project.

What refuses ​

OutcomeWhen
Unresolvedthe module is not one the project contains — a third-party package, an unaliased bare specifier
Unresolveda dotted path matches two files in a monorepo
Unresolveda re-export chain exceeds four hops, or cycles
Ambiguoustwo barrel files export the same name
NotBoundnothing in the file binds the name

NotBound is deliberately not a refusal. A star import, a conditional import, or a name bound by machinery this analysis does not model all land there, and callers decide what it means for them. The ORM resolver treats it as permissive, because refusing it would trade M07's false positives for false negatives.

What is out of scope ​

sys.path manipulation, namespace packages, editable installs, node_modules resolution, tsconfig path mapping, conditional exports, and any resolution that depends on runtime state. Each is a different mechanism; none is guessed at.

Released under the Apache-2.0 licence.