Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: address deprecations caused by updating packages #570

Merged
merged 11 commits into from
Feb 12, 2024
Merged

Conversation

NiceAesth
Copy link
Contributor

@NiceAesth NiceAesth commented Feb 9, 2024

Describe your changes

RFC. This is the minimal required to get it into a working state. See: https://fastapi.tiangolo.com/advanced/events/#lifespan

Breaking changes spotted:

As a side effect, we now should technically support Python 3.12

Other things of note:
We may support Pytest 8 soon once pytest-asyncio v23.5 is out of alpha. pytest-dev/pytest-asyncio#737 (comment) done in #571

Related Issues / Projects

Depends on #568

Checklist

  • I've manually tested my code

@NiceAesth NiceAesth marked this pull request as ready for review February 9, 2024 15:36
Ansi.LMAGENTA,
)

yield # type: ignore
Copy link
Contributor Author

@NiceAesth NiceAesth Feb 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mypy will scream about not returning anything with yield without this but the typedef expects Never

we could also yield a dictionary e.g.

    yield {
        "db": db,
        "redis": redis,
        "crypto_model": crypto_model,
        "osu_service": osu_service,
        "stats_service": stats_service,
    }

and then it would be available under request.state instead of request.app.state

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just want to make sure, is this a 1:1 copy other than the yield?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep

@@ -239,5 +239,5 @@ async def test_score_submission(
assert response.status_code == status.HTTP_200_OK
assert (
response.read()
== b"beatmapId:315|beatmapSetId:141|beatmapPlaycount:1|beatmapPasscount:1|approvedDate:2014-05-18 15:41:48|\n|chartId:beatmap|chartUrl:https://osu.cmyui.xyz/s/141|chartName:Beatmap Ranking|rankBefore:|rankAfter:1|rankedScoreBefore:|rankedScoreAfter:26810|totalScoreBefore:|totalScoreAfter:26810|maxComboBefore:|maxComboAfter:52|accuracyBefore:|accuracyAfter:81.94|ppBefore:|ppAfter:9.56523|onlineScoreId:1|\n|chartId:overall|chartUrl:https://cmyui.xyz/u/3|chartName:Overall Ranking|rankBefore:|rankAfter:1|rankedScoreBefore:|rankedScoreAfter:26810|totalScoreBefore:|totalScoreAfter:26810|maxComboBefore:|maxComboAfter:52|accuracyBefore:|accuracyAfter:81.94|ppBefore:|ppAfter:10|achievements-new:osu-skill-pass-4+Insanity Approaches+You're not twitching, you're just ready./all-intro-hidden+Blindsight+I can see just perfectly"
== b"beatmapId:315|beatmapSetId:141|beatmapPlaycount:1|beatmapPasscount:1|approvedDate:2014-05-18 15:41:48|\n|chartId:beatmap|chartUrl:https://osu.cmyui.xyz/s/141|chartName:Beatmap Ranking|rankBefore:|rankAfter:1|rankedScoreBefore:|rankedScoreAfter:26810|totalScoreBefore:|totalScoreAfter:26810|maxComboBefore:|maxComboAfter:52|accuracyBefore:|accuracyAfter:81.94|ppBefore:|ppAfter:10.04103|onlineScoreId:1|\n|chartId:overall|chartUrl:https://cmyui.xyz/u/3|chartName:Overall Ranking|rankBefore:|rankAfter:1|rankedScoreBefore:|rankedScoreAfter:26810|totalScoreBefore:|totalScoreAfter:26810|maxComboBefore:|maxComboAfter:52|accuracyBefore:|accuracyAfter:81.94|ppBefore:|ppAfter:10|achievements-new:osu-skill-pass-4+Insanity Approaches+You're not twitching, you're just ready./all-intro-hidden+Blindsight+I can see just perfectly"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated value due to changed pp calcs

Copy link
Member

@cmyui cmyui Feb 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should prolly use snapshot tests for tests like these

Copy link
Member

@cmyui cmyui Feb 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also the test suite runs on the docker-compose db rn which is super weird - we should be spinning up a temp db & running migrations every time we run tests

@@ -263,7 +263,7 @@ async def main(argv: Sequence[str] | None = None) -> int:

await app.state.services.http_client.aclose()
await db.disconnect()
await redis.close()
await redis.aclose()
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

close() is deprecated as of 5.0.1

@cmyui
Copy link
Member

cmyui commented Feb 12, 2024

+1 👍🏻

@cmyui cmyui added dependencies Pull requests that update a dependency file code quality Something is implemented poorly labels Feb 12, 2024
@NiceAesth NiceAesth merged commit 4e58c18 into master Feb 12, 2024
6 checks passed
@NiceAesth NiceAesth deleted the deprecations branch February 12, 2024 09:51
@@ -64,6 +67,57 @@ def openapi(self) -> dict[str, Any]:
return self.openapi_schema


@asynccontextmanager
async def lifespan(asgi_app: BanchoAPI) -> AsyncIterator[Never]:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this be AsyncIterator[None]?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i remember trying that and it failing mypy

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
code quality Something is implemented poorly dependencies Pull requests that update a dependency file
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants