Hadron / Hadron/entanglement

entanglement.util fails to import when SQLAlchemy is missing

Open
#19 0 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Python
Stars
4
Forks
3
PR merge metrics
No merged PRs in 30d

Description

## Description

`entanglement/util.py` treats SQLAlchemy as optional by catching `ImportError` around:

```python
from sqlalchemy.types import TypeDecorator, String
from sqlalchemy import inspect
```

However, the rest of the module still refers to symbols from those imports. In particular, `GUID` is declared unconditionally as a `TypeDecorator` subclass and uses `String`, while `get_or_create()` uses `inspect`.

As a result, importing `entanglement.util` without SQLAlchemy installed fails instead of allowing the module to load. Depending on the exact code path/revision, this manifests as a `NameError` for an unset imported symbol (or an earlier type error while defining `GUID`).

## Impact

This breaks Carthage's plugin loader path that intentionally tolerates missing modules long enough to load plugins and report/catch their dependencies. For example, the `develop` branch of `patch-upgrade/whs` can encounter this failure.

## Expected behavior

Importing Entanglement without SQLAlchemy installed should succeed for functionality that does not require SQLAlchemy. SQL-dependent classes and functions should either be defined only when SQLAlchemy is available or raise a clear optional-dependency error when used, rather than failing during module import.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start in entanglement/util.py by reading the optional SQLAlchemy import block and the GUID and get_or_create definitions that use TypeDecorator, String, and inspect. Check the import path with SQLAlchemy unavailable, then verify that non-SQL functionality still loads and SQL-dependent use reports a clear optional-dependency error instead of failing during module import.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, sqlalchemy
Domain
backend, databases
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.