Skip to content

Commit d617e84

Browse files
committed
Add release notes to docs.
1 parent bd342a1 commit d617e84

File tree

2 files changed

+36
-7
lines changed

2 files changed

+36
-7
lines changed

docs/index.rst

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,6 @@ To get started quickly, take a look at the following example showcasing the basi
4646
4747
Explore the :doc:`user guide<gettingstarted>` to dive deeper into using the library effectively.
4848

49-
GitHub Repository
50-
=================
51-
52-
Find the source code, contribute, and report issues on our `GitHub Repository <https://github.com/runemalm/py-dependency-injection>`_.
53-
54-
Now, let's embark on a journey to harness the power of dependency injection with py-dependency-injection!
55-
5649
.. gettingstarted-docs:
5750
.. toctree::
5851
:maxdepth: 1

docs/versionhistory.rst

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,42 @@
22
Version history
33
###############
44

5+
**1.0.0-alpha.3 (2024-03-02)**
6+
7+
- **Breaking Change**: Restriction on `@inject` Decorator: Starting from this version, the `@inject` decorator can now only be used on static class methods and class methods. This change is introduced due to potential pitfalls associated with resolving and injecting dependencies directly into class instance methods using the dependency container.
8+
9+
**Reasoning:**
10+
11+
Resolving and injecting dependencies into instance methods can lead to unexpected behaviors and may violate the principles of dependency injection. Instance methods often rely on the state of the object, and injecting dependencies from the container directly can obscure the dependencies required for a method. Additionally, it may introduce difficulties in testing and make the code harder to reason about.
12+
13+
By restricting the usage of the `@inject` decorator to static and class methods, we aim to encourage a cleaner separation of concerns, making it more explicit when dependencies are injected and providing better clarity on the dependencies required by a method.
14+
15+
**Before:**::
16+
17+
class Foo:
18+
19+
@inject()
20+
def instance_method(self, transient_instance: SomeInterface, scoped_instance: AnotherInterface, singleton_instance: ThirdInterface):
21+
# ...
22+
23+
**After:**::
24+
25+
class Foo:
26+
27+
@classmethod
28+
@inject()
29+
def class_method(cls, transient_instance: SomeInterface, scoped_instance: AnotherInterface, singleton_instance: ThirdInterface):
30+
# ...
31+
32+
@staticmethod
33+
@inject()
34+
def static_method(transient_instance: SomeInterface, scoped_instance: AnotherInterface, singleton_instance: ThirdInterface):
35+
# ...
36+
37+
- Documentation Update: The documentation has been updated to reflect the new restriction on the usage of the `@inject` decorator. Users are advised to review the documentation for updated examples and guidelines regarding method injection.
38+
39+
`View release on GitHub <https://github.com/runemalm/py-dependency-injection/releases/tag/v1.0.0-alpha.3>`_
40+
541
**1.0.0-alpha.2 (2024-02-27)**
642

743
- Python Version Support: Added support for Python versions 3.7, 3.9, 3.10, 3.11, and 3.12.

0 commit comments

Comments
 (0)