<commit_before>Injector - Python dependency injection framework, inspired by Guice
===================================================================

[![image](https://secure.travis-ci.org/alecthomas/injector.png?branch=master)](https://travis-ci.org/alecthomas/injector)

Introduction
------------

Dependency injection as a formal pattern is less useful in Python than in other languages, primarily due to its support for keyword arguments, the ease with which objects can be mocked, and its dynamic nature.

That said, a framework for assisting in this process can remove a lot of boiler-plate from larger applications. That's where Injector can help. It automatically and transitively provides keyword arguments with their values. As an added benefit, Injector encourages nicely compartmentalised code through the use of `Module` s.

While being inspired by Guice, it does not slavishly replicate its API. Providing a Pythonic API trumps faithfulness.

Supported Python versions
-------------------------

Injector work with the following Python interpreters:

-   CPython 2.6, 2.7, 3.2, 3.3
-   PyPy 1.9

Recent Notable Changes
----------------------
Added support for using Python3 annotations instead of @inject.

eg. The following code:

```python
class B(object):
    @inject(a=A):
    def __init__(self, a):
        self.a = a
```

Can now be written as:

```python3
class B(object):<commit_msg>Add PyPI and GitHub links to the readme<commit_after>Injector - Python dependency injection framework, inspired by Guice
===================================================================

[![image](https://secure.travis-ci.org/alecthomas/injector.png?branch=master)](https://travis-ci.org/alecthomas/injector)

Introduction
------------

Dependency injection as a formal pattern is less useful in Python than in other languages, primarily due to its support for keyword arguments, the ease with which objects can be mocked, and its dynamic nature.

That said, a framework for assisting in this process can remove a lot of boiler-plate from larger applications. That's where Injector can help. It automatically and transitively provides keyword arguments with their values. As an added benefit, Injector encourages nicely compartmentalised code through the use of `Module` s.

While being inspired by Guice, it does not slavishly replicate its API. Providing a Pythonic API trumps faithfulness.

How to get Injector?
--------------------

GitHub page: https://github.com/alecthomas/injector

Injector is also available on PyPI: https://pypi.python.org/pypi/injector. You can install it using pip:

```python
pip install injector
```


Supported Python versions
-------------------------

Injector work with the following Python interpreters:

-   CPython 2.6, 2.7, 3.2, 3.3
-   PyPy 1.9

Recent Notable Changes
----------------------
Added support for using Python3 annotations instead of @inject.

eg. The following code:

```python
class B(object):
    @inject(a=A):
    def __init__(self, a):
        self.a = a
```

Can now be written as:

```python3
class B(object):
{'fraction_non_alphanumeric': 0.15524520948359857, 'fraction_numerical': 0.007794738551477752, 'mean_word_length': 3.6737481031866466, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 6, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4240605', 'n_tokens_mistral': 840, 'n_tokens_neox': 796, 'n_words': 352}