Commit Graph

47 Commits

Author SHA1 Message Date
Roman Mogylatov
14d8ed909b
FactoryAggregate - non string keys (#496)
* Improve FactoryAggregate typing stub

* Add implementation, typing stubs, and tests

* Update changelog

* Fix deepcopying

* Add example

* Update docs

* Fix errors formatting for pypy3
2021-08-25 10:20:45 -04:00
RK
9cb8e60280
Feature: Context local provider (#442)
Co-authored-by: Rollo Konig Brock <rollo@b2c2.com>
2021-04-18 21:37:55 -04:00
Roman Mogylatov
41e698f633
Fix configuration cache reset (#430)
* Implement fix

* Improve providers copying

* Add tests and implement cache reset for configuration option

* Update changelog

* Add link to the issue
2021-03-20 21:41:39 -04:00
Roman Mogylatov
f961ff536a
Schemas (#429)
* Add single container prototype

* Add multiple containers prototype

* Add integration tests

* Implement from_*() methods and add tests

* Prototype inline injections

* Add integration test for inline providers

* Refactor integration tests

* Add integration test for reordered schema

* Remove unused imports from tests

* Refactor schema module

* Update tests to match latest schemas

* Add mypy_boto3_s3 to the test requirements

* Add boto3 to the test requirements

* Add set_provides for Callable, Factory, and Singleton providers

* Fix warnings in tests

* Add typing stubs for Callable, Factory, and Singleton .set_provides() attributes

* Fix singleton children to have optional provides

* Implement provider to provider resolving

* Fix pypy3 tests

* Implement boto3 session use case and add tests

* Implement lazy initialization and improve copying for Callable, Factory, Singleton, and Coroutine providers

* Fix Python 2 tests

* Add region name for boto3 integration example

* Remove f-strings from set_provides()

* Fix schema flake8 errors

* Implement lazy initialization and improve copying for Delegate provider

* Implement lazy initialization and improve copying for Object provider

* Speed up wiring tests

* Implement lazy initialization and improve copying for FactoryAggregate provider

* Implement lazy initialization and improve copying for Selector provider

* Implement lazy initialization and improve copying for Dependency provider

* Implement lazy initialization and improve copying for Resource provider

* Implement lazy initialization and improve copying for Configuration provider

* Implement lazy initialization and improve copying for ProvidedInstance provider

* Implement lazy initialization and improve copying for AttributeGetter provider

* Implement lazy initialization and improve copying for ItemGetter provider

* Implement lazy initialization and improve copying for MethodCaller provder

* Update changelog

* Fix typing in wiring module

* Fix wiring module loader uninstallation issue

* Fix provided instance providers error handing in asynchronous mode

Co-authored-by: Roman Mogylatov <rmk@Romans-MacBook-Pro.local>
2021-03-20 13:16:51 -04:00
Roman Mogylatov
2bf3601695
Singleton reset context (#417)
* Add implementation and typing stubs

* Make some refactoring and add tests

* Pin ubuntu version to 18.04

* Add docs and example

* Add changelog

* Add container docs
2021-03-03 08:28:10 -05:00
Roman Mogylatov
27d0e07718
Async mode awaitable fix (#400)
* Fix mistakenly processed awaitable objects

* Update changelog

* Replace __isawaitable() with __is_future_or_coroutine()

* Refactor async mode
2021-02-17 09:56:39 -05:00
Roman Mogylatov
de1181bdf7
Async mode fixes (#399)
* Fix double printing of exception when initializing resource causes error

* Improve async mode exceptions handling to prevent infinite hanging when exception occurs

* Improve async mode exceptions handling

* Update changelog

* Update tests
2021-02-16 12:26:23 -05:00
Roman Mogylatov
5f34c7ce3f Add working prototype, requires deep refactoring 2021-02-10 08:52:13 -05:00
Roman Mogylatov
ff3ae95482 Add working prototype for sample 1 and 3 2021-02-10 07:57:04 -05:00
Roman Mogylatov
1c433ed0ad Add prototype for flat resolving 2021-02-09 08:57:31 -05:00
Roman Mogylatov
674a6b0f9e
Container "self" injections (#392)
* Add implementation

* Add Self provider tests

* Add container tests

* Remove ellipsis from tests to make them pass on Python 2

* Add tests

* Add docs

* Improve traverse() typing stubs

* Update changelog
2021-02-07 14:13:23 -05:00
Roman Mogylatov
478ca18ae3
336 Dependency provider default (#382)
* Add implementation and tests

* Refactor dependency provider docs

* Update docs

* Update changelog
2021-01-29 13:49:40 -05:00
Roman Mogylatov
6224131a76 358 Replace configuration option weakref to root with regular ref 2021-01-28 08:40:43 -05:00
Roman Mogylatov
c16f974517 Refactor asynchronous injections 2021-01-21 11:20:24 -05:00
Roman Mogylatov
4b0272ab30 Fix #368 Async providers do not work with async dependencies 2021-01-21 10:58:49 -05:00
Roman Mogylatov
d74e8248a1
Required config options and strict mode (#360)
* Add strict mode + tests

* Add .required() for configuration option

* Add wiring tests for required() modifier

* Add wiring support

* Add tests for defined None values in required/strict mode

* Add docs

* Update changelog

* Update example doc block
2021-01-16 08:53:40 -05:00
Roman Mogylatov
feed916f46
Async resources and injections (#352)
* Add support of async injections into wiring

* Add support of async functions and async generators for resources

* Update resource provider typing stub for stutdown

* Add resource base class for async resources

* Fix tests

* Add tests for async injections in wiring @inject

* Refactor provider tests

* Add tests for async resources

* Rework async resources callbacks to .add_done_callback() style (fixes pypy3 issue)

* Add awaits into async resource class test

* Refactor FastAPI tests

* Implement async resources initialization in container

* Move container async resource tests to a separate module for Python 3.6+

* Fix init async resources in container on Python 2

* Add first dirty async injections implementation

* Fix isawaitable error

* Turm asyncio import to conditional for safer Py2 usage

* Refactor kwargs injections

* Implement positional injections, add tests and make refactoring

* Implement attribute injections and add tests

* Add singleton implementation + tests for all singleton types

* Implement injections in thread-local and thread-safe singleton providers

* Update .provided + fix resource concurent initialization issue

* Implement async mode for Dependency provider

* Add async mode for the provider

* Add overload for Factory typing

* Add typing stubs for async resource

* Refactor abstract* providers __call__()

* Add async mode API + tests

* Add typing stubs & tests for async mode API

* Add tests for async mode auto configuration

* Refactor Provider.__call__() to use async mode api

* Refactor Dependency provider to use async mode api

* Add tests for Dependency provider async mode

* Add support of async mode for FactoryAggregate provider + tests

* Refactor Singleton provider to use async mode api

* Refactor ThreadSafeSingleton provider to use async mode api

* Refactor ThreadLocalSingleton provider to use async mode api

* Finish Singleton refactoring to use async mode api

* Refactor Resource provider to use async mode api

* Add Provider.async_() method + tests

* Add typing stubs for async_() method + tests

* Refactor Singleton typing stubs to return singleton from argument methods

* Refactor provider typing stubs

* Improve resource typing stub

* Add tests for async context kwargs injections

* Fix typo in resource provider tests

* Cover shutdown of not initialized resource

* Add test to cover resource initialization with an error

* Fix Singleton and ThreadLocalSingleton to handle initialization errors

* Add FastAPI + Redis example

* Make cosmetic fixes to FastAPI + Redis example

* Add missing development requirements

* Update module docblock in fastapi + redis example

* Add FastAPI + Redis example docs

* Add references to FastAPI + Redis example

* Refactor resource docs

* Add asynchronous resources docs

* Refactor wiring docs

* Add async injections docs for wiring

* Add async injections page and update docs index, readme, and key features pages

* Add providers async injections example

* Add docs on provider async mode enabling

* Reword async provider docs

* Add provider async mode docs

* Add cross links to async docs

* Mute flake8 errors in async provider examples

* Update changelog

* Make cosmetic fix to containers.pyx
2021-01-10 19:26:15 -05:00
Roman Mogylatov
47c79b2772
Resources (#312)
* Add prototype

* Add example

* Remove typing erros in Python 2.7 and 3.4

* Move resources example

* Draft resources docs

* Update resources docs

* Fix repr

* Rename dict provider test

* Add more tests

* Add tests + refactoring

* Add more tests

* Update tests to run only on 3.5+

* Update setup.py

* Add typing tests

* Update changelog

* Fix generator iteration

* Remove contextlib

* Hotfix aiohttp issue

* Move aiohttp fix to tox.ini

* Move aiohttp fix to a different place in tox
2020-10-24 20:56:32 -04:00
Roman Mogylatov
b54bcb7b31
Dict provider (#311)
* Add tests

* Add implementation and typing stubs

* Update README and docs pages

* Add example and docs

* Update changelog

* Add long description to the doc block
2020-10-22 14:49:39 -04:00
Roman Mogylatov
07d4f7e74f
Develop 4.0 (#298)
* Add wiring (#294)

* Add wiring module

* Fix code style

* Fix package test

* Add version fix

* Try spike for 3.6

* Try another fix with metaclass

* Downsample required version to 3.6

* Introduce concept with annotations

* Fix bugs

* Add debug message

* Add extra tests

* Add extra debugging

* Update config resolving

* Remove 3.6 generic meta fix

* Fix Flake8

* Add spike for 3.6

* Add Python 3.6 spike

* Add unwire functionality

* Add support of corouting functions

* Bump version to 4.0

* Updaet demo example

* Add pydocstyle ignore for demo

* Add flake8 ignore for demo

* Update aiohttp example

* Update flask example

* Rename aiohttp example directory

* Rename views module to handlers in aiohttp example

* Add sanic example

* Remove not needed images

* Update demo

* Implement wiring for Provide[foo.provider]

* Implement Provide[foo.provided.bar.baz.call()]

* Make flake8 happy

* Wiring refactoring (#296)

* Refactor wiring

* Add todos to wiring

* Implement wiring of config invariant

* Implement sub containers wiring + add tests

* Add test for wiring config invariant

* Add container.unwire() typing stub

* Deprecate ext package modules and remove types module

* Deprecate provider.delegate() method

* Add __all__ for wiring module

* Add protection for wiring only declarative container instances

* Bump version to 4.0.0a2

* Add wiring docs

* Add wiring of class methods

* Remove unused import

* Add a note on individuals import to wiring docs

* Add minor improvement to wiring doc

* Update DI in Python page

* Update key features

* Update README concep and FAQ

* Add files via upload

* Update README.rst

* Update README.rst

* Update README.rst

* Update docs index page

* Update README

* Remove API docs for flask and aiohttp ext

* Add wiring API docs

* Update docs index

* Update README

* Update readme and docs index

* Change wording in README

* Django example (#297)

* Add rough django example

* Remove sqlite db

* Add gitignore

* Fix flake8 and pydocstyle errors

* Add tests

* Refactor settings

* Move web app to to the root of the project

* Add bootstrap 4

* Add doc blocks for web app

* Add coverage

* Fix typo in flask

* Remove not needed newlines

* Add screenshot

* Update django app naming

* Add django example to the docs

* Update changelog

* Update Aiohttp example

* Add sanic example to the docs

* Make a little fix in django example docs page

* Add flask example to the docs

* Add aiohttp example to the docs

* Update installation docs page

* Fix .delegate() deprecation

* Refactor movie lister to use wiring

* Make micro cosmetic changes to flask, aiohttp & sanic examples

* Refactor single container example to use wiring

* Refactor multiple container example to use wiring

* Add return type to main() in application examples

* Refactor decoupled packages example to use wiring

* Refactor code layout for DI demo example

* Update wiring feature message

* Add more links to the examples

* Change code layout in miniapps

* Update sanic example

* Update miniapp READMEs

* Update wiring docs

* Refactor part of cli tutorial

* Refactor CLI app tutorial

* Update test coverage results in movie lister example and tutorial

* Make some minor updates to aiohttp and cli tutorials

* Refactor flask tutorial

* Make cosmetic fix in flask example

* Refactor Flask tutorial: Connect to the GitHub

* Refactor Flask tutorial: Search service

* Refactor Flask tutorial: Inject search service into view

* Refactor Flask tutorial: Make some refactoring

* Finish flask tutorial refactoring

* Update tutorials

* Refactor  asyncio monitoring daemon example application

* Fix tutorial links

* Rename asyncio miniapp

* Rename tutorial image dirs

* Rename api docs tol-level page

* Refactor initial sections of asyncio daemon tutorial

* Refactor asyncio tutorial till Example.com monitor section

* Refactor asyncio tutorial example.com monitor section

* Refactor asyncio tutorial httpbin.org monitor tutorial

* Refactor tests section of asyncio daemon tutorial

* Update conclusion of asyncio daemon tutorial

* Rename tutorial images

* Make cosmetic update to flask tutorial

* Refactor aiohttp tutorial: Minimal application section

* Refactor aiohttp tutorial: Giphy API client secion

* Refactor aiohttp tutorial secion: Make the search work

* Refactor aiohttp tutorial tests section

* Refactor aiohttp tutorial conclusion

* Upgrade  Cython to 0.29.21

* Update changelog

* Update demo example

* Update wording on index pages

* Update changelog

* Update code layout for main demo
2020-10-09 15:16:27 -04:00
Roman Mogylatov
ffc477d1ee Update API docs 2020-09-09 22:23:28 -04:00
Roman Mogylatov
cf862fe8b5
Provided attributes (#282)
* Add sketch

* Cythonize MethodCaller

* Cythonize ItemGetter, AttributeGetter & ProvidedInstance providers

* Add docblock for .provided attribute

* Refactor repr methods

* Add .provided attribute to the Dependency provider

* Add tests for the .provided attribute to the majority of the providers

* Add docblock for the ProvidedInstance provider

* Add docblocks for the rest of the providers

* Add example of the provided instance usage

* Add tests for provided instance* providers

* Add complex provided instance example

* Update example provided_instance.py

* Add docs
2020-08-20 21:52:12 -04:00
Roman Mogylatov
4a8133204c
Factory deep init injections (#277)
* Add factory deep context providing

* Add example

* Add test
2020-08-06 16:33:06 -04:00
Roman Mogylatov
ea1e79885c
274 Configuration provider redesign (#275)
* Get 1st stable version

* Remove prototype module

* Try fix copying

* Add config itemselector example

* Add doc blocks
2020-08-03 18:01:20 -04:00
Roman Mogylatov
1f115111b2
Dependency provider issue with abc (#267)
* Fix the issue

* Add the test

* Update tests

* Update changelog

* Update tests
2020-07-22 12:14:26 -04:00
Roman Mogylatov
2513d1f600
Selector provider (#258)
* Add Selector provider

* Add Selector provider example

* Add tests for selector provider

* Update changelog

* Add pydocstyle ignore D101 for examples

* Fix repr() test

* Update changelog

* Add D203,D213 to examples pydocstyle ignore

* Add selector provider docs
2020-06-29 16:32:12 -04:00
Roman Mogylatov
c8b781e744
Container provider (#256)
* Add unit tests

* Add Container provider

* Update changelog
2020-06-22 22:45:16 -04:00
Roman Mogylatov
e6f096270e
Config linking (#255)
* Add config linking test

* Add provider linking

* Update changelog
2020-06-22 21:52:00 -04:00
Roman Mogylatov
2beafb9a51
List provider (#251)
* Add List provider

* Add List provider example

* Add List provider unit tests

* Add docs

* Upstream changes from develop

* Update API docs

* Update unit tests

* Add support of positional context argument injections

* Update changelog
2020-06-14 17:32:12 -04:00
Roman Mogylatov
08de710b2f
235 Fix Delegate cannot be used in overridden container (#236)
* Add test for bug #235

* Fix issue + refactoring

* Update changelog
2019-10-09 10:45:14 -04:00
Roman Mogylatov
9a785de4b5
Coroutine provider (#206)
* Add coroutine provider examples

* Add coroutine provier

* Update changelog

* Update static analysis travis jobs to python 3.7

* Update coroutine provider implementation for python 3.4

* Update static analysis travis jobs to python 3.6

* Make pycode style happy

* Add tests for coroutine providers

* Make coroutine tests python 2 syntax friendly

* Split tests to python2 and python3

* Refactor coroutine provider tests

* Modify pypy tests running command

* Update coroutine provider docs
2018-10-18 19:39:19 +03:00
Roman Mogylatov
18393eb9ed Apply refactoring #199 2018-07-26 10:22:43 +03:00
Roman Mogylatov
48ac3824cb Fix bug #198 2018-07-24 23:09:56 +03:00
Roman Mogylatov
e877b33fd1 Refactor configuration provider 2018-01-24 19:59:48 +02:00
Roman Mogylatov
c50322db02
178 dependencies container provider (#179)
* Add DependenciesContainer provider

* Remove bundles_v2 example

* Add use cases example

* Update changelog

* Update documentation requirements to use fixed version of sphinxcontrib-disqus

* Add use cases miniapp to docs

* Update changelog
2018-01-21 23:55:32 +02:00
Roman Mogylatov
a67e4ebd44 Rename provider ExternalDependency -> Dependency 2017-12-21 22:47:31 +02:00
Roman Mogylatov
9bdf010bc5 Add FactoryAggregate provider implementation 2017-10-12 19:54:06 -07:00
Roman Mogylatov
c1053cbd73 Add early implementation of FactoryAggregate provider 2017-10-11 10:13:31 -07:00
Roman Mogilatov
8705e47d37 Add SingletonDelegate provider + tests 2017-07-09 23:34:14 +03:00
Roman Mogilatov
3f197e3744 Add CallableDelegate provider + tests 2017-07-09 23:29:33 +03:00
Roman Mogilatov
89c1c975e6 Add FactoryDelegate provider + tests 2017-07-09 23:17:12 +03:00
Roman Mogilatov
007c256c5f Make code style fixes in providers module 2017-06-09 01:41:22 +03:00
Roman Mogilatov
2a9b14cb0e Make Provider overriding methods thread safe 2017-04-18 23:30:29 +03:00
Roman Mogilatov
9ed806b0ca Refactor storage locking of ThreadSafeSingleton 2017-04-18 23:11:03 +03:00
Roman Mogilatov
2aa85228d7 Add abstract providers 2017-04-06 18:17:06 +03:00
Roman Mogilatov
1dacd096f6 Optimize calling of overridden providers 2017-04-06 12:34:04 +03:00
Roman Mogilatov
5b3dbae572 Consolidate providers into single cython module 2017-03-25 22:38:48 +02:00