RepositoryPythonBRBrazil
roo-oliv

roo-oliv/injectable

Python Dependency Injection for Humans™

119sao
11fork
5issue
0lượt xem

🌟 Injectable: Dependency Injection cho Python được thiết kế cho con người

Injectable mang lại trải nghiệm Dependency Injection đẹp và đơn giản cho Python.

Injectable là một framework Dependency Injection (DI) nhẹ cho Python, được thiết kế với triết chất "built with Heart and designed for Humans". Dự án giúp các nhà phát triển quản lý và tiêm phụ thuộc một cách tự nhiên thông qua decorator và annotation, giảm thiểu công việc thủ công trong việc khởi tạo và kết nối các thành phần.

✨ Điểm nổi bật

  • Autowiring: Chỉ cần dùng @autowired và annotate tham số với Autowired, hệ thống tự động tiêm dependency.
  • Khám phá dependency tự động: Gọi load_injection_container() để tự động tìm và đăng ký tất cả lớp có decorator @injectable.
  • Qualifier overloading: Hỗ trợ nhiều implementation cho cùng một interface, tiêm danh sách bằng List[qualifier].
  • Lazy initialization trong suốt: Dùng lazy=True để khởi tạo dependency chỉ khi thực sự cần.
  • Xử lý circular dependencies: Tích hợp cơ chế giải quyết vòng trùng lặp phụ thuộc phổ biến trong DI.
  • Hỗ trợ Multiple Instances: Cấu hình singleton hoặc instance mới cho từng lần tiêm.
  • Tích hợp Testing thông minh: Dễ dàng mock hoặc override dependency trong môi trường kiểm thử.

💡 Vì sao đáng chú ý

Injectable khác biệt so với các framework DI truyền thống ở sự đơn giản hóa tối đa cách dùng. Thay vì cần cấu hình phứ tạp hoặc registry thủ công, Injectable khám phá tự động toàn bộ dependency chỉ với một lời gọi hàm. Điều này giúp giảm đáng kể thời gian setup ban đầu.

Đặc biệt, hỗ trợ lazy evaluation và xử lý circular dependencies giúp tránh các vấn đề hiệu năng và lỗi thời gian chạy thường gặp. Phù hợp cho dự án Python vừa và lớn cần quản lý phụ thuộc phức tạp một cách sạch sẽ.


#Python #DependencyInjection #IoC #Autowiring #OpenSource #TiniX

Dự án tương tự

Khám phá các dự án và mô hình AI khác có sự tương đồng.

RepositoryC#
gustavopsantos/Reflex

Minimal dependency injection framework for Unity

1.6k
Oct 10, 2026
RepositoryC++
tensorflow/tensorflow

An Open Source Machine Learning Framework for Everyone

201.3k
Oct 28, 2026
RepositoryPython
ets-labs/python-dependency-injector

Dependency injection framework for Python

4.9k
Oct 1, 2026
RepositoryPython
donnemartin/system-design-primer

Learn how to design large-scale systems. Prep for the system design interview. Includes Anki flashcards.

376.1k
Sep 15, 2026
RepositoryPython
vinta/awesome-python

The definitive list that answers "I want to do X in Python, which tool should I use?"

331.1k
Oct 29, 2026
RepositoryPython
practical-tutorials/project-based-learning

Curated list of project-based tutorials

288.4k
Oct 26, 2026
RepositoryPython
TheAlgorithms/Python

All Algorithms implemented in Python

225.6k
Oct 20, 2026
RepositoryPython
yt-dlp/yt-dlp

A feature-rich command-line audio/video downloader

203.7k
Oct 29, 2026
RepositoryPython
Significant-Gravitas/AutoGPT

AutoGPT is the vision of accessible AI for everyone, to use and to build on. Our mission is to provide the tools, so that you can focus on what matters.

187.8k
Oct 28, 2026