Optional extras under [project.optional-dependencies] are currently treated as regular dependencies. That means this is invisible to deptry:
[project]
dependencies = ["httpx"]
[project.optional-dependencies]
snowflake = ["snowflake-connector-python"]
mypackage/core.py
import snowflake.connector
Users who install mypackage without [snowflake] then fail at import time. Treating the extra as a dev group (optional_dependencies_dev_groups) is the wrong fix, because mypackage/snowflake.py is allowed to import snowflake.connector when the extra is installed. That import does not need to be ImportError-guarded.
A mapping from extra name to first-party modules would catch both "base imports an extra-only package" and "the postgres extra imports a snowflake-only package".
Optional extras under [project.optional-dependencies] are currently treated as regular dependencies. That means this is invisible to deptry:
[project]
dependencies = ["httpx"]
[project.optional-dependencies]
snowflake = ["snowflake-connector-python"]
mypackage/core.py
import snowflake.connector
Users who install mypackage without [snowflake] then fail at import time. Treating the extra as a dev group (optional_dependencies_dev_groups) is the wrong fix, because mypackage/snowflake.py is allowed to import snowflake.connector when the extra is installed. That import does not need to be ImportError-guarded.
A mapping from extra name to first-party modules would catch both "base imports an extra-only package" and "the postgres extra imports a snowflake-only package".