diff --git a/.github/actions/code-style/action.yml b/.github/actions/code-style/action.yml index 2d3311a..6b84ef4 100644 --- a/.github/actions/code-style/action.yml +++ b/.github/actions/code-style/action.yml @@ -4,14 +4,8 @@ description: Check code style runs: using: "composite" steps: - - name: Isort + - name: Ruff shell: bash - run: isort ./ --check - - - name: Black - shell: bash - run: black ./ --check - - - name: Flake8 - shell: bash - run: flake8 + run: | + ruff format --check + ruff check diff --git a/README.md b/README.md index 0716b2a..db6bfe4 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,6 @@ [![CI](https://github.com/100nm/python-injection/actions/workflows/ci.yml/badge.svg)](https://github.com/100nm/python-injection) [![PyPI](https://badge.fury.io/py/python-injection.svg)](https://pypi.org/project/python-injection/) -[![Black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black) Fast and easy dependency injection framework. diff --git a/before_commit.sh b/before_commit.sh index 4a429e8..9c674d0 100755 --- a/before_commit.sh +++ b/before_commit.sh @@ -11,14 +11,9 @@ set -e title "POETRY" poetry check -title "ISORT" -isort ./ - -title "BLACK" -black ./ - -title "FLAKE" -flake8 +title "RUFF" +ruff format +ruff check --fix title "PYTEST" pytest --cov=./ --cov-report term-missing:skip-covered diff --git a/documentation/advanced-usage.md b/documentation/advanced-usage.md index dbc2c0e..7c73c06 100644 --- a/documentation/advanced-usage.md +++ b/documentation/advanced-usage.md @@ -106,24 +106,24 @@ The default priority is **`LOW`**. Apply priority with `use` method: ```python -from injection import Module, ModulePriorities +from injection import Module, ModulePriority module_1, module_2 = Module(), Module() -module_1.use(module_2, ModulePriorities.HIGH) +module_1.use(module_2, ModulePriority.HIGH) ``` Apply priority with `use_temporarily` method: ```python -with module_1.use_temporarily(module_2, ModulePriorities.HIGH): +with module_1.use_temporarily(module_2, ModulePriority.HIGH): ... ``` Change the priority of a used module: ```python -module_1.change_priority(module_2, ModulePriorities.LOW) +module_1.change_priority(module_2, ModulePriority.LOW) ``` ### Understand `ModuleLockError` diff --git a/injection/_pkg.py b/injection/_pkg.py index 2b95fc2..495629d 100644 --- a/injection/_pkg.py +++ b/injection/_pkg.py @@ -1,9 +1,9 @@ -from .core import Injectable, Module, ModulePriorities +from .core import Injectable, Module, ModulePriority __all__ = ( "Injectable", "Module", - "ModulePriorities", + "ModulePriority", "default_module", "get_instance", "get_lazy_instance", diff --git a/injection/_pkg.pyi b/injection/_pkg.pyi index 89d583d..6820eea 100644 --- a/injection/_pkg.pyi +++ b/injection/_pkg.pyi @@ -128,7 +128,7 @@ class Module: Example: instance = ~lazy_instance """ - def use(self, module: Module, priority: ModulePriorities = ...): + def use(self, module: Module, priority: ModulePriority = ...): """ Function for using another module. Using another module replaces the module's dependencies with those of the module used. If the dependency is not found, it @@ -143,13 +143,13 @@ class Module: def use_temporarily( self, module: Module, - priority: ModulePriorities = ..., + priority: ModulePriority = ..., ) -> ContextManager | ContextDecorator: """ Context manager or decorator for temporary use of a module. """ - def change_priority(self, module: Module, priority: ModulePriorities): + def change_priority(self, module: Module, priority: ModulePriority): """ Function for changing the priority of a module in use. There are two priority values: @@ -164,7 +164,7 @@ class Module: """ @final -class ModulePriorities(Enum): +class ModulePriority(Enum): HIGH = ... LOW = ... diff --git a/injection/core/module.py b/injection/core/module.py index 2918f36..fbc3308 100644 --- a/injection/core/module.py +++ b/injection/core/module.py @@ -41,7 +41,7 @@ NoInjectable, ) -__all__ = ("Injectable", "Module", "ModulePriorities") +__all__ = ("Injectable", "Module", "ModulePriority") _logger = logging.getLogger(__name__) _thread_lock = RLock() @@ -117,7 +117,7 @@ def __str__(self) -> str: @dataclass(frozen=True, slots=True) class ModulePriorityUpdated(ModuleEvent): module_updated: Module - priority: ModulePriorities + priority: ModulePriority def __str__(self) -> str: return ( @@ -269,7 +269,7 @@ def is_locked(self) -> bool: def __injectables(self) -> frozenset[Injectable]: return frozenset(self.__data.values()) - def update(self, classes: Types, injectable: Injectable, override: bool): + def update(self, classes: Iterable[type], injectable: Injectable, override: bool): values = MappingProxyType( {origin: injectable for origin in get_origins(*classes)} ) @@ -309,7 +309,7 @@ def __check_if_exists(self, *classes: type): """ -class ModulePriorities(Enum): +class ModulePriority(Enum): HIGH = auto() LOW = auto() @@ -437,14 +437,19 @@ def get_instance(self, cls: type[_T], none: bool = True) -> _T | None: def get_lazy_instance(self, cls: type[_T]) -> Lazy[_T | None]: return Lazy(lambda: self.get_instance(cls)) - def update(self, classes: Types, injectable: Injectable, override: bool = False): + def update( + self, + classes: Iterable[type], + injectable: Injectable, + override: bool = False, + ): self.__container.update(classes, injectable, override) return self def use( self, module: Module, - priority: ModulePriorities = ModulePriorities.get_default(), + priority: ModulePriority = ModulePriority.get_default(), ): if module is self: raise ModuleError("Module can't be used by itself.") @@ -475,13 +480,13 @@ def stop_using(self, module: Module): def use_temporarily( self, module: Module, - priority: ModulePriorities = ModulePriorities.get_default(), + priority: ModulePriority = ModulePriority.get_default(), ) -> ContextManager | ContextDecorator: self.use(module, priority) yield self.stop_using(module) - def change_priority(self, module: Module, priority: ModulePriorities): + def change_priority(self, module: Module, priority: ModulePriority): event = ModulePriorityUpdated(self, module, priority) with self.notify(event): @@ -517,8 +522,8 @@ def __check_locking(self): if self.is_locked: raise ModuleLockError(f"`{self}` is locked.") - def __move_module(self, module: Module, priority: ModulePriorities): - last = priority == ModulePriorities.LOW + def __move_module(self, module: Module, priority: ModulePriority): + last = priority == ModulePriority.LOW try: self.__modules.move_to_end(module, last=last) diff --git a/poetry.lock b/poetry.lock index 57fd5c2..f56f729 100644 --- a/poetry.lock +++ b/poetry.lock @@ -11,52 +11,6 @@ files = [ {file = "annotated_types-0.6.0.tar.gz", hash = "sha256:563339e807e53ffd9c267e99fc6d9ea23eb8443c08f112651963e24e22f84a5d"}, ] -[[package]] -name = "black" -version = "24.2.0" -description = "The uncompromising code formatter." -optional = false -python-versions = ">=3.8" -files = [ - {file = "black-24.2.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:6981eae48b3b33399c8757036c7f5d48a535b962a7c2310d19361edeef64ce29"}, - {file = "black-24.2.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:d533d5e3259720fdbc1b37444491b024003e012c5173f7d06825a77508085430"}, - {file = "black-24.2.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:61a0391772490ddfb8a693c067df1ef5227257e72b0e4108482b8d41b5aee13f"}, - {file = "black-24.2.0-cp310-cp310-win_amd64.whl", hash = "sha256:992e451b04667116680cb88f63449267c13e1ad134f30087dec8527242e9862a"}, - {file = "black-24.2.0-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:163baf4ef40e6897a2a9b83890e59141cc8c2a98f2dda5080dc15c00ee1e62cd"}, - {file = "black-24.2.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:e37c99f89929af50ffaf912454b3e3b47fd64109659026b678c091a4cd450fb2"}, - {file = "black-24.2.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:4f9de21bafcba9683853f6c96c2d515e364aee631b178eaa5145fc1c61a3cc92"}, - {file = "black-24.2.0-cp311-cp311-win_amd64.whl", hash = "sha256:9db528bccb9e8e20c08e716b3b09c6bdd64da0dd129b11e160bf082d4642ac23"}, - {file = "black-24.2.0-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:d84f29eb3ee44859052073b7636533ec995bd0f64e2fb43aeceefc70090e752b"}, - {file = "black-24.2.0-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:1e08fb9a15c914b81dd734ddd7fb10513016e5ce7e6704bdd5e1251ceee51ac9"}, - {file = "black-24.2.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:810d445ae6069ce64030c78ff6127cd9cd178a9ac3361435708b907d8a04c693"}, - {file = "black-24.2.0-cp312-cp312-win_amd64.whl", hash = "sha256:ba15742a13de85e9b8f3239c8f807723991fbfae24bad92d34a2b12e81904982"}, - {file = "black-24.2.0-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:7e53a8c630f71db01b28cd9602a1ada68c937cbf2c333e6ed041390d6968faf4"}, - {file = "black-24.2.0-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:93601c2deb321b4bad8f95df408e3fb3943d85012dddb6121336b8e24a0d1218"}, - {file = "black-24.2.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:a0057f800de6acc4407fe75bb147b0c2b5cbb7c3ed110d3e5999cd01184d53b0"}, - {file = "black-24.2.0-cp38-cp38-win_amd64.whl", hash = "sha256:faf2ee02e6612577ba0181f4347bcbcf591eb122f7841ae5ba233d12c39dcb4d"}, - {file = "black-24.2.0-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:057c3dc602eaa6fdc451069bd027a1b2635028b575a6c3acfd63193ced20d9c8"}, - {file = "black-24.2.0-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:08654d0797e65f2423f850fc8e16a0ce50925f9337fb4a4a176a7aa4026e63f8"}, - {file = "black-24.2.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:ca610d29415ee1a30a3f30fab7a8f4144e9d34c89a235d81292a1edb2b55f540"}, - {file = "black-24.2.0-cp39-cp39-win_amd64.whl", hash = "sha256:4dd76e9468d5536abd40ffbc7a247f83b2324f0c050556d9c371c2b9a9a95e31"}, - {file = "black-24.2.0-py3-none-any.whl", hash = "sha256:e8a6ae970537e67830776488bca52000eaa37fa63b9988e8c487458d9cd5ace6"}, - {file = "black-24.2.0.tar.gz", hash = "sha256:bce4f25c27c3435e4dace4815bcb2008b87e167e3bf4ee47ccdc5ce906eb4894"}, -] - -[package.dependencies] -click = ">=8.0.0" -mypy-extensions = ">=0.4.3" -packaging = ">=22.0" -pathspec = ">=0.9.0" -platformdirs = ">=2" -tomli = {version = ">=1.1.0", markers = "python_version < \"3.11\""} -typing-extensions = {version = ">=4.0.1", markers = "python_version < \"3.11\""} - -[package.extras] -colorama = ["colorama (>=0.4.3)"] -d = ["aiohttp (>=3.7.4)", "aiohttp (>=3.7.4,!=3.9.0)"] -jupyter = ["ipython (>=7.8.0)", "tokenize-rt (>=3.2.0)"] -uvloop = ["uvloop (>=0.15.2)"] - [[package]] name = "blacksheep" version = "2.0.7" @@ -192,20 +146,6 @@ files = [ {file = "charset_normalizer-3.1.0-py3-none-any.whl", hash = "sha256:3d9098b479e78c85080c98e1e35ff40b4a31d8953102bb0fd7d1b6f8a2111a3d"}, ] -[[package]] -name = "click" -version = "8.1.7" -description = "Composable command line interface toolkit" -optional = false -python-versions = ">=3.7" -files = [ - {file = "click-8.1.7-py3-none-any.whl", hash = "sha256:ae74fb96c20a0277a1d615f1e4d73c8414f5a98db8b799a7931d1582f3390c28"}, - {file = "click-8.1.7.tar.gz", hash = "sha256:ca9853ad459e787e2192211578cc907e7594e294c7ccc834310722b41b9ca6de"}, -] - -[package.dependencies] -colorama = {version = "*", markers = "platform_system == \"Windows\""} - [[package]] name = "colorama" version = "0.4.6" @@ -328,22 +268,6 @@ files = [ [package.extras] test = ["pytest (>=6)"] -[[package]] -name = "flake8" -version = "7.0.0" -description = "the modular source code checker: pep8 pyflakes and co" -optional = false -python-versions = ">=3.8.1" -files = [ - {file = "flake8-7.0.0-py2.py3-none-any.whl", hash = "sha256:a6dfbb75e03252917f2473ea9653f7cd799c3064e54d4c8140044c5c065f53c3"}, - {file = "flake8-7.0.0.tar.gz", hash = "sha256:33f96621059e65eec474169085dc92bf26e7b2d47366b70be2f67ab80dc25132"}, -] - -[package.dependencies] -mccabe = ">=0.7.0,<0.8.0" -pycodestyle = ">=2.11.0,<2.12.0" -pyflakes = ">=3.2.0,<3.3.0" - [[package]] name = "guardpost" version = "1.0.2" @@ -420,20 +344,6 @@ files = [ {file = "iniconfig-2.0.0.tar.gz", hash = "sha256:2d91e135bf72d31a410b17c16da610a82cb55f6b0477d1a902134b24a455b8b3"}, ] -[[package]] -name = "isort" -version = "5.13.2" -description = "A Python utility / library to sort Python imports." -optional = false -python-versions = ">=3.8.0" -files = [ - {file = "isort-5.13.2-py3-none-any.whl", hash = "sha256:8ca5e72a8d85860d5a3fa69b8745237f2939afe12dbf656afbcb47fe72d947a6"}, - {file = "isort-5.13.2.tar.gz", hash = "sha256:48fdfcb9face5d58a4f6dde2e72a1fb8dcaf8ab26f95ab49fab84c2ddefb0109"}, -] - -[package.extras] -colors = ["colorama (>=0.4.6)"] - [[package]] name = "itsdangerous" version = "2.1.2" @@ -514,28 +424,6 @@ files = [ {file = "MarkupSafe-2.1.5.tar.gz", hash = "sha256:d283d37a890ba4c1ae73ffadf8046435c76e7bc2247bbb63c00bd1a709c6544b"}, ] -[[package]] -name = "mccabe" -version = "0.7.0" -description = "McCabe checker, plugin for flake8" -optional = false -python-versions = ">=3.6" -files = [ - {file = "mccabe-0.7.0-py2.py3-none-any.whl", hash = "sha256:6c2d30ab6be0e4a46919781807b4f0d834ebdd6c6e3dca0bda5a15f863427b6e"}, - {file = "mccabe-0.7.0.tar.gz", hash = "sha256:348e0240c33b60bbdf4e523192ef919f28cb2c3d7d5c7794f74009290f236325"}, -] - -[[package]] -name = "mypy-extensions" -version = "1.0.0" -description = "Type system extensions for programs checked with the mypy type checker." -optional = false -python-versions = ">=3.5" -files = [ - {file = "mypy_extensions-1.0.0-py3-none-any.whl", hash = "sha256:4392f6c0eb8a5668a69e23d168ffa70f0be9ccfd32b5cc2d26a34ae5b844552d"}, - {file = "mypy_extensions-1.0.0.tar.gz", hash = "sha256:75dbf8955dc00442a438fc4d0666508a9a97b6bd41aa2f0ffe9d2f2725af0782"}, -] - [[package]] name = "packaging" version = "23.2" @@ -547,32 +435,6 @@ files = [ {file = "packaging-23.2.tar.gz", hash = "sha256:048fb0e9405036518eaaf48a55953c750c11e1a1b68e0dd1a9d62ed0c092cfc5"}, ] -[[package]] -name = "pathspec" -version = "0.12.1" -description = "Utility library for gitignore style pattern matching of file paths." -optional = false -python-versions = ">=3.8" -files = [ - {file = "pathspec-0.12.1-py3-none-any.whl", hash = "sha256:a0d503e138a4c123b27490a4f7beda6a01c6f288df0e4a8b79c7eb0dc7b4cc08"}, - {file = "pathspec-0.12.1.tar.gz", hash = "sha256:a482d51503a1ab33b1c67a6c3813a26953dbdc71c31dacaef9a838c4e29f5712"}, -] - -[[package]] -name = "platformdirs" -version = "4.2.0" -description = "A small Python package for determining appropriate platform-specific dirs, e.g. a \"user data dir\"." -optional = false -python-versions = ">=3.8" -files = [ - {file = "platformdirs-4.2.0-py3-none-any.whl", hash = "sha256:0614df2a2f37e1a662acbd8e2b25b92ccf8632929bc6d43467e17fe89c75e068"}, - {file = "platformdirs-4.2.0.tar.gz", hash = "sha256:ef0cc731df711022c174543cb70a9b5bd22e5a9337c8624ef2c2ceb8ddad8768"}, -] - -[package.extras] -docs = ["furo (>=2023.9.10)", "proselint (>=0.13)", "sphinx (>=7.2.6)", "sphinx-autodoc-typehints (>=1.25.2)"] -test = ["appdirs (==1.4.4)", "covdefaults (>=2.3)", "pytest (>=7.4.3)", "pytest-cov (>=4.1)", "pytest-mock (>=3.12)"] - [[package]] name = "pluggy" version = "1.4.0" @@ -588,17 +450,6 @@ files = [ dev = ["pre-commit", "tox"] testing = ["pytest", "pytest-benchmark"] -[[package]] -name = "pycodestyle" -version = "2.11.1" -description = "Python style guide checker" -optional = false -python-versions = ">=3.8" -files = [ - {file = "pycodestyle-2.11.1-py2.py3-none-any.whl", hash = "sha256:44fe31000b2d866f2e41841b18528a505fbd7fef9017b04eff4e2648a0fadc67"}, - {file = "pycodestyle-2.11.1.tar.gz", hash = "sha256:41ba0e7afc9752dfb53ced5489e89f8186be00e599e712660695b7a75ff2663f"}, -] - [[package]] name = "pydantic" version = "2.6.3" @@ -709,26 +560,15 @@ files = [ [package.dependencies] typing-extensions = ">=4.6.0,<4.7.0 || >4.7.0" -[[package]] -name = "pyflakes" -version = "3.2.0" -description = "passive checker of Python programs" -optional = false -python-versions = ">=3.8" -files = [ - {file = "pyflakes-3.2.0-py2.py3-none-any.whl", hash = "sha256:84b5be138a2dfbb40689ca07e2152deb896a65c3a3e24c251c5c62489568074a"}, - {file = "pyflakes-3.2.0.tar.gz", hash = "sha256:1c61603ff154621fb2a9172037d84dca3500def8c8b630657d1701f026f8af3f"}, -] - [[package]] name = "pytest" -version = "8.1.0" +version = "8.0.2" description = "pytest: simple powerful testing with Python" optional = false python-versions = ">=3.8" files = [ - {file = "pytest-8.1.0-py3-none-any.whl", hash = "sha256:ee32db7af8de4629a455806befa90559f307424c07b8413ccfc30bf5b221dd7e"}, - {file = "pytest-8.1.0.tar.gz", hash = "sha256:f8fa04ab8f98d185113ae60ea6d79c22f8143b14bc1caeced44a0ab844928323"}, + {file = "pytest-8.0.2-py3-none-any.whl", hash = "sha256:edfaaef32ce5172d5466b5127b42e0d6d35ebbe4453f0e3505d96afd93f6b096"}, + {file = "pytest-8.0.2.tar.gz", hash = "sha256:d4051d623a2e0b7e51960ba963193b09ce6daeb9759a451844a21e4ddedfc1bd"}, ] [package.dependencies] @@ -736,11 +576,11 @@ colorama = {version = "*", markers = "sys_platform == \"win32\""} exceptiongroup = {version = ">=1.0.0rc8", markers = "python_version < \"3.11\""} iniconfig = "*" packaging = "*" -pluggy = ">=1.4,<2.0" -tomli = {version = ">=1", markers = "python_version < \"3.11\""} +pluggy = ">=1.3.0,<2.0" +tomli = {version = ">=1.0.0", markers = "python_version < \"3.11\""} [package.extras] -testing = ["argcomplete", "attrs (>=19.2)", "hypothesis (>=3.56)", "mock", "pygments (>=2.7.2)", "requests", "setuptools", "xmlschema"] +testing = ["argcomplete", "attrs (>=19.2.0)", "hypothesis (>=3.56)", "mock", "nose", "pygments (>=2.7.2)", "requests", "setuptools", "xmlschema"] [[package]] name = "pytest-asyncio" @@ -817,7 +657,6 @@ files = [ {file = "PyYAML-6.0.1-cp311-cp311-win_amd64.whl", hash = "sha256:bf07ee2fef7014951eeb99f56f39c9bb4af143d8aa3c21b1677805985307da34"}, {file = "PyYAML-6.0.1-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:855fb52b0dc35af121542a76b9a84f8d1cd886ea97c84703eaa6d88e37a2ad28"}, {file = "PyYAML-6.0.1-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:40df9b996c2b73138957fe23a16a4f0ba614f4c0efce1e9406a184b6d07fa3a9"}, - {file = "PyYAML-6.0.1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a08c6f0fe150303c1c6b71ebcd7213c2858041a7e01975da3a99aed1e7a378ef"}, {file = "PyYAML-6.0.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6c22bec3fbe2524cde73d7ada88f6566758a8f7227bfbf93a408a9d86bcc12a0"}, {file = "PyYAML-6.0.1-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:8d4e9c88387b0f5c7d5f281e55304de64cf7f9c0021a3525bd3b1c542da3b0e4"}, {file = "PyYAML-6.0.1-cp312-cp312-win32.whl", hash = "sha256:d483d2cdf104e7c9fa60c544d92981f12ad66a457afae824d146093b8c294c54"}, @@ -863,6 +702,32 @@ files = [ {file = "rodi-2.0.6.tar.gz", hash = "sha256:f533e315d84b63824efcc67526a156ad5fb0a158f1ccbc41e0db3944d0c08693"}, ] +[[package]] +name = "ruff" +version = "0.3.0" +description = "An extremely fast Python linter and code formatter, written in Rust." +optional = false +python-versions = ">=3.7" +files = [ + {file = "ruff-0.3.0-py3-none-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl", hash = "sha256:7deb528029bacf845bdbb3dbb2927d8ef9b4356a5e731b10eef171e3f0a85944"}, + {file = "ruff-0.3.0-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:e1e0d4381ca88fb2b73ea0766008e703f33f460295de658f5467f6f229658c19"}, + {file = "ruff-0.3.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:2f7dbba46e2827dfcb0f0cc55fba8e96ba7c8700e0a866eb8cef7d1d66c25dcb"}, + {file = "ruff-0.3.0-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:23dbb808e2f1d68eeadd5f655485e235c102ac6f12ad31505804edced2a5ae77"}, + {file = "ruff-0.3.0-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:3ef655c51f41d5fa879f98e40c90072b567c666a7114fa2d9fe004dffba00932"}, + {file = "ruff-0.3.0-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl", hash = "sha256:d0d3d7ef3d4f06433d592e5f7d813314a34601e6c5be8481cccb7fa760aa243e"}, + {file = "ruff-0.3.0-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:b08b356d06a792e49a12074b62222f9d4ea2a11dca9da9f68163b28c71bf1dd4"}, + {file = "ruff-0.3.0-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:9343690f95710f8cf251bee1013bf43030072b9f8d012fbed6ad702ef70d360a"}, + {file = "ruff-0.3.0-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:a1f3ed501a42f60f4dedb7805fa8d4534e78b4e196f536bac926f805f0743d49"}, + {file = "ruff-0.3.0-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:cc30a9053ff2f1ffb505a585797c23434d5f6c838bacfe206c0e6cf38c921a1e"}, + {file = "ruff-0.3.0-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:5da894a29ec018a8293d3d17c797e73b374773943e8369cfc50495573d396933"}, + {file = "ruff-0.3.0-py3-none-musllinux_1_2_i686.whl", hash = "sha256:755c22536d7f1889be25f2baf6fedd019d0c51d079e8417d4441159f3bcd30c2"}, + {file = "ruff-0.3.0-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:dd73fe7f4c28d317855da6a7bc4aa29a1500320818dd8f27df95f70a01b8171f"}, + {file = "ruff-0.3.0-py3-none-win32.whl", hash = "sha256:19eacceb4c9406f6c41af806418a26fdb23120dfe53583df76d1401c92b7c14b"}, + {file = "ruff-0.3.0-py3-none-win_amd64.whl", hash = "sha256:128265876c1d703e5f5e5a4543bd8be47c73a9ba223fd3989d4aa87dd06f312f"}, + {file = "ruff-0.3.0-py3-none-win_arm64.whl", hash = "sha256:e3a4a6d46aef0a84b74fcd201a4401ea9a6cd85614f6a9435f2d33dd8cefbf83"}, + {file = "ruff-0.3.0.tar.gz", hash = "sha256:0886184ba2618d815067cf43e005388967b67ab9c80df52b32ec1152ab49f53a"}, +] + [[package]] name = "six" version = "1.16.0" @@ -899,4 +764,4 @@ files = [ [metadata] lock-version = "2.0" python-versions = ">=3.10, <4" -content-hash = "130d63f34d187817f8d7ce4a0d4c2ef81563a4f570ade2fc65037075d51ec406" +content-hash = "6ad21f8bd1fa8b9cb25f1b4cdcb6f3f11db43771f771bff95746686207e9f538" diff --git a/pyproject.toml b/pyproject.toml index c911982..d7eff78 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -13,14 +13,42 @@ repository = "https://github.com/100nm/python-injection" python = ">=3.10, <4" [tool.poetry.group.dev.dependencies] -black = "*" -blacksheep = "^2.0.7" -flake8 = "*" -isort = "*" -pydantic = "^2.6.3" +blacksheep = "*" +pydantic = "*" pytest = "*" pytest-asyncio = "*" pytest-cov = "*" +ruff = "*" + +[tool.coverage.report] +exclude_lines = [ + "pragma: no cover", + "raise NotImplementedError", +] + +[tool.pytest.ini_options] +python_files = "test_*.py" +addopts = "-p no:warnings --tb=short" +asyncio_mode = "auto" +testpaths = "tests/" + +[tool.ruff] +line-length = 88 +indent-width = 4 + +[tool.ruff.format] +quote-style = "double" +indent-style = "space" +skip-magic-trailing-comma = false +line-ending = "auto" + +[tool.ruff.lint] +extend-select = ["F", "I", "N"] +ignore = ["N818"] +fixable = ["ALL"] + +[tool.ruff.lint.per-file-ignores] +"__init__.py" = ["F403"] [build-system] requires = ["poetry-core"] diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 27c22d4..0000000 --- a/setup.cfg +++ /dev/null @@ -1,22 +0,0 @@ -[coverage:report] -exclude_lines = - pragma: no cover - raise NotImplementedError - - -[flake8] -max-line-length=88 -per-file-ignores = - __init__.py:F401, F403 - - -[isort] -line_length=88 -profile=black - - -[tool:pytest] -python_files = test_*.py -addopts = -p no:warnings --tb=short -asyncio_mode = auto -testpaths = tests/ diff --git a/tests/core/test_module.py b/tests/core/test_module.py index 9cbe5ed..3e29b36 100644 --- a/tests/core/test_module.py +++ b/tests/core/test_module.py @@ -2,7 +2,7 @@ import pytest -from injection.core import Injectable, Module, ModulePriorities +from injection.core import Injectable, Module, ModulePriority from injection.exceptions import ( ModuleError, ModuleLockError, @@ -48,7 +48,7 @@ def test_getitem_with_success_return_injectable(self, module): assert module[SomeClass] is injectable_x fourth_module = Module() - module.use(fourth_module, priority=ModulePriorities.HIGH) + module.use(fourth_module, priority=ModulePriority.HIGH) injectable_z = self.get_test_injectable(SomeClass()) fourth_module[SomeClass] = injectable_z assert module[SomeClass] is injectable_z @@ -159,7 +159,7 @@ def test_use_with_success(self, module, event_history): third_module = Module() module.use(second_module) - module.use(third_module, priority=ModulePriorities.HIGH) + module.use(third_module, priority=ModulePriority.HIGH) event_history.assert_length(2) @@ -243,11 +243,11 @@ def test_change_priority_with_success(self, module, event_history): assert module[SomeClass] is injectable_x - module.change_priority(third_module, ModulePriorities.HIGH) + module.change_priority(third_module, ModulePriority.HIGH) event_history.assert_length(3) assert module[SomeClass] is injectable_y - module.change_priority(third_module, ModulePriorities.LOW) + module.change_priority(third_module, ModulePriority.LOW) event_history.assert_length(4) assert module[SomeClass] is injectable_x @@ -255,7 +255,7 @@ def test_change_priority_with_module_not_found(self, module, event_history): second_module = Module() with pytest.raises(ModuleNotUsedError): - module.change_priority(second_module, ModulePriorities.HIGH) + module.change_priority(second_module, ModulePriority.HIGH) """ unlock