Closed xxxxxxbox closed 7 months ago
Hi @xxxxxxbox This is because you were following the documentation for BlackSheep v1 (stable at that time), installing BlackSheep v2 (alpha release at that time).
I am the only maintainer of the framework and unfortunately had no time to keep the documentation for the alpha version up to date while working on it.
Now the documentation is up to date:
I continue following tutorial. But get new errors when trying to reproduce code from next steps of tutorial.
As I understand Dependency Injection is one of key features of BlackSheep. As DI is a new approach for me, I read several times the article dedicated to it. https://www.neoteroi.dev/blacksheep/dependency-injection/ I got the idea but can't say that I understand DI fully for now... When I Copy/Paste example code and run it I get AttributeError: 'Container' object has no attribute 'add_exact_transient' My IDE also display warning "unresolved attribute for several method' Please see enclosed screenshot.
app.services.add_exact_transient(A) app.services.add_exact_scoped(B) app.services.add_exact_singleton(C)
DI tutorial page is not the only page of documentation where add_exact_scoped method is used in examples.
As the official documentation is almost the only source of information about BlackSheep It's hard for new users of BS to find right way of using it. As one of new users I appreciate if you update key parts of tutorial when you have some free time. Thanx.
I used Blacksheep v2.08a
File "C:\Users\User\AppData\Local\Programs\Python\Python311\Lib\multiprocessing\process.py", line 314, in _bootstrap self.run()", line 1204, in _gcd_import
File "", line 1176, in _find_and_load
File "", line 1147, in _find_and_load_unlocked
File "", line 690, in _load_unlocked
File "", line 940, in exec_module
File "", line 241, in _call_with_frames_removed
File "Z:\dev\blacksheep0\server.py", line 8, in app.services.add_exact_transient(A)
AttributeError: 'Container' object has no attribute 'add_exact_transient'**
File "C:\Users\User\AppData\Local\Programs\Python\Python311\Lib\multiprocessing\process.py", line 108, in run
self._target(*self._args, self._kwargs)
File "Z:\dev\blacksheep0\venv\Lib\site-packages\uvicorn_subprocess.py", line 76, in subprocess_started
target(sockets=sockets) File "Z:\dev\blacksheep0\venv\Lib\site-packages\uvicorn\server.py", line 61, in run return asyncio.run(self.serve(sockets=sockets)) File "C:\Users\User\AppData\Local\Programs\Python\Python311\Lib\asyncio\runners.py", line 190, in run return runner.run(main) File "C:\Users\User\AppData\Local\Programs\Python\Python311\Lib\asyncio\runners.py", line 118, in run return self._loop.run_until_complete(task) File "C:\Users\User\AppData\Local\Programs\Python\Python311\Lib\asyncio\base_events.py", line 653, in run_until_complete return future.result() File "Z:\dev\blacksheep0\venv\Lib\site-packages\uvicorn\server.py", line 68, in serve config.load() File "Z:\dev\blacksheep0\venv\Lib\site-packages\uvicorn\config.py", line 473, in load File "