fix: close the motor client if an invalid db name raises in __init__ (mongo-9)

self._client[database] can raise InvalidName after the client is already
built, leaking it via any exception traceback the caller holds. close it
before re-raising, matching the __aenter__ leak fix. also compresses essay
docstrings/comments across the module with no behavior change, keeping the
swallow-and-default contract note and the matched_count/nInserted footguns.

Signed-off-by: disqualifier <dev@disqualifier.me>
This commit is contained in:
2026-07-02 23:28:04 -04:00
parent 30f0e44097
commit 0a68b65937
4 changed files with 55 additions and 69 deletions
+1 -1
View File
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
[project]
name = "mongo"
version = "0.1.7"
version = "0.1.8"
description = "async mongodb wrapper over motor with a raw escape hatch"
requires-python = ">=3.10"
dependencies = [