Skip to content

Commit

Permalink
Fix #112: @Autowired wrong type annotation
Browse files Browse the repository at this point in the history
  • Loading branch information
roo-oliv committed Jul 31, 2024
1 parent d9bbd06 commit f5e5db2
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 26 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
Changelog
=========

4.0.1 (2024-07-31)
------------------
* Fix ``@autowired`` decorator wrong type annotation causing issues with pyright, mypy, and other type checkers

4.0.0 (2024-07-12)
------------------
* Drop support for Python versions 3.6, 3.7 and 3.8
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ docs:
make html -B
cp -a build/html/. docs

CURRENT_VERSION = 4.0.0
CURRENT_VERSION = 4.0.1

.PHONY: bump-patch-version
bump-patch-version:
Expand Down
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
year = "2018"
author = "Rodrigo Martins de Oliveira"
copyright = "{0}, {1}".format(year, author)
version = release = "4.0.0"
version = release = "4.0.1"

pygments_style = "trac"
templates_path = ["."]
Expand Down
2 changes: 1 addition & 1 deletion injectable/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from injectable import testing
from injectable import constants

__version__ = "4.0.0"
__version__ = "4.0.1"

__all__ = [
"load_injection_container",
Expand Down
8 changes: 4 additions & 4 deletions injectable/autowiring/autowired_decorator.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import inspect
from functools import wraps
from typing import TypeVar, Callable, Any, get_args, _AnnotatedAlias, Union
from typing import TypeVar, Callable, get_args, _AnnotatedAlias, Union

from injectable.autowiring.autowired_type import _Autowired, Autowired
from injectable.errors import AutowiringError

T = TypeVar("T", bound=Callable[..., Any])
R = TypeVar("R")


def autowired(func: T) -> T:
def autowired(func: Callable[..., R]) -> Callable[..., R]:
"""
Function decorator to setup dependency injection autowiring.
Expand Down Expand Up @@ -64,7 +64,7 @@ def autowired(func: T) -> T:
raise AutowiringError("No parameter is typed with 'Autowired'")

@wraps(func)
def wrapper(*args, **kwargs):
def wrapper(*args, **kwargs) -> R:
bound_arguments = signature.bind_partial(*args, **kwargs).arguments
args = list(args)
for parameter in autowired_parameters:
Expand Down
19 changes: 0 additions & 19 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -95,22 +95,3 @@ parallel = true
[tool.coverage.report]
show_missing = true
precision = 2

[tool.bumpversion]
current_version = "4.0.0"

[[tool.bumpversion.files]]
filename = "Makefile"
search = "CURRENT_VERSION = {current_version}"

[[tool.bumpversion.files]]
filename = "pyproject.toml"
search = 'version = "{current_version}"'

[[tool.bumpversion.files]]
filename = "docs/conf.py"
search = 'version = release = "{current_version}"'

[[tool.bumpversion.files]]
filename = "injectable/__init__.py"
search = '__version__ = "{current_version}"'
19 changes: 19 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
[bumpversion]
current_version = 4.0.1

[bumpversion:file:Makefile]
search = CURRENT_VERSION = {current_version}
replace = CURRENT_VERSION = {new_version}

[bumpversion:file:setup.cfg]
search = current_version = {current_version}
replace = current_version = {new_version}

[bumpversion:file:docs/conf.py]
search = version = release = "{current_version}"
replace = version = release = "{new_version}"

[bumpversion:file:injectable/__init__.py]
search = __version__ = "{current_version}"
replace = __version__ = "{new_version}"

[flake8]
max-line-length = 89
ignore = F821,E203,E701,E704,W503
Expand Down

0 comments on commit f5e5db2

Please sign in to comment.