tortoise / tortoise-orm

Familiar asyncio ORM for python, built with relations in mind
https://tortoise.github.io
Apache License 2.0
4.58k stars 378 forks source link

Documentation is completely broken - it points to the develop branch but says it's for 0.20.1 #1603

Closed PawelRoman closed 4 months ago

PawelRoman commented 4 months ago

The official documentation is generated from the develop branch, but it says it's for the official 0.20.1 version

For example, take a look at this page: https://tortoise.github.io/contrib/fastapi.html

And this: https://tortoise.github.io/examples/fastapi.html

It makes this import tortoise.contrib.fastapi.RegisterTortoise

But in 0.20.1 there is no such class. 0.20.1 is using register_tortoise synchronous function which seems to be a breaking change in the library.

waketzheng commented 4 months ago

You can install/upgrade the package from github to use the RegisterTortoise class:

pip install --upgrade 'tortoise-orm>=0.21' || pip install --upgrade --force-reinstall git+https://github.com/tortoise/tortoise-orm

Or by ssh

pip install --upgrade 'tortoise-orm>=0.21' || pip install --upgrade --force-reinstall git+ssh://git@github.com/tortoise/tortoise-orm

Then use this command to check the result:

python -c 'from tortoise.contrib.fastapi import RegisterTortoise'
waketzheng commented 4 months ago

Documentation should be able to select version to fix this issue and #1569

abondar commented 4 months ago

Yeah, right now documentation publishing is wacky

I'll try to fix it with release of 0.21.0, so it will deploy docs only in case of new release, not just new commits

Github pages doesn't support doc versioning automatically, but it seems out there are some plugins, that say that they can handle it, I'll look into it in mean time

qingshuiyuyu commented 4 months ago

i cant believe why the FastAPI Examples can not be run
when i use register_tortoise the error: async with register_tortoise( AttributeError: __aenter__

waketzheng commented 4 months ago

@qingshuiyuyu Use async with RegisterTortoise instead. https://tortoise.github.io/examples/fastapi.html#main-py

qingshuiyuyu commented 4 months ago

@qingshuiyuyu Use async with RegisterTortoise instead. https://tortoise.github.io/examples/fastapi.html#main-py

but i can not import this class v:tortoise-orm==0.20.1 ,there only register_tortoise i use another way this guy rewrite the class https://github.com/tortoise/tortoise-orm/issues/1576#issuecomment-2074505541

waketzheng commented 4 months ago

Yeah, right now documentation publishing is wacky

I'll try to fix it with release of 0.21.0, so it will deploy docs only in case of new release, not just new commits

Github pages doesn't support doc versioning automatically, but it seems out there are some plugins, that say that they can handle it, I'll look into it in mean time

@abondar How is that?

abondar commented 4 months ago

Sadly, 0.21.0 is still not ready, as I want to fix #1607 before making release, but still didn't have time to sit for that properly

Other than that - I updated CI pipelines, so now it shouldn't update documentation on commits in develop branch, but didn't test it properly as it requires release for it

I am hoping to find time on this week for fix and release

abondar commented 4 months ago

Seems fixed now with release of 0.21.0