CodeSampleX

サンプル

wrapt 2.2.2: Register post-import hooks and resolve target attribute paths for deferred or immediate module monkey-patching

検証済みサンプル — pypi wrapt 2.2.2: Register post-import hooks and resolve target attribute paths for deferred or immediate module monkey-patching. python 3.12 …

sha256:af57dbec1640ac0b0db78fcb6d980b05450f08ba22cb0c541017566924aa9cd9

このネットワークが提供するのは一つだけです。ビルドされるサンプル。サンドボックスで実行し、署名済みの受領証を保管します。等級はつけず、何も保証しません — 同じコードがあなたの環境でビルドされるかは測定していません。 合格した契約受領証を提出した異なる署名鍵の数です。1 なら作者だけ、2 以上なら他の誰かもビルドしています。鍵は自己生成で背後に登録された身元がないため、数えているのは人ではなく鍵です。 MIT-0

実行証拠

宣言された環境と署名済みの実行を分けてあります。このサンプルが何をどこで実行したかをそのまま確認できます。

証拠の基準
署名済みコントラクト合格
検証レシート
2
ビルドした署名鍵
2
宣言された環境 python linux x64 python python pip

検証実行環境

環境 コントラクト ステージ 実行日
python 3.12 · linux alpine/x64 · docker ed25519:d91480838ac982c9 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · python@1
2026-08-17
python 3.12 · linux alpine/x64 · docker ed25519:2175b912ea1c23b1 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · python@1
2026-08-18

ケース

HOW
ゴール
Register post-import hooks and resolve target attribute paths for deferred or immediate module monkey-patching
パッケージ
シンボル
  • wrapt.register_post_import_hook
  • wrapt.when_imported
  • wrapt.resolve_path
  • wrapt.patch_function_wrapper
  • wrapt.apply_patch
  • wrapt.notify_module_loaded
環境
python
作成日
2026-08-17T13:15:00Z

コントラクト

  1. wrapt.when_imported defers hook execution until the module is loaded via the import machinery or executes immediately if already in sys.modules
  2. assert multiple registered post-import hooks execute sequentially in order of registration
  3. assert wrapt.resolve_path returns a tuple of parent object, attribute name, and target reference for dotted target strings
  4. assert wrapt.resolve_path raises AttributeError when resolving non-existent path segments
  5. assert @wrapt.patch_function_wrapper installs a 4-argument wrapper on a resolved target function in-place
  6. assert wrapt.apply_patch replaces the attribute on the parent namespace and allows unpatching to the original target
  7. assert wrapt.notify_module_loaded triggers pending hooks for manually instantiated module objects

ファイル

  • NOTES.md
  • csx.json
  • requirements.txt
  • src/__init__.py
  • src/hook_manager.py
  • src/services.py
  • test/__init__.py
  • test/contract.py

ソースアーティファクトをダウンロード (tar.gz)

オリジンシーダー

csx-seed