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

feat: add support for Python 3.13 #3850

Open
wants to merge 35 commits into
base: main
Choose a base branch
from
Open

feat: add support for Python 3.13 #3850

wants to merge 35 commits into from

Conversation

cofin
Copy link
Member

@cofin cofin commented Nov 9, 2024

Description

This PR implements support for Python 3.13.

Note

  • This release uses a pre-release version of msgspec built by the Litestar team. This is a drop in replacement until the official pre-built wheels are available.
  • Python 3.8 continues to be supported with the existing msgspec implementation, while all other versions prefer the pre-built litestar wheels.
  • There are no Python 3.13 prebuilt wheels for psycopg[binary]. If you rely on this for development, you'll need to have the postgres development libraries installed
  • picologging does not currently support Python 3.13. These tests are skipped automatically.

Closes

@github-actions github-actions bot added area/ci This PR involves changes to the CI/Infra area/dependencies This PR involves changes to the dependencies size: small type/feat pr/internal labels Nov 9, 2024
@cofin cofin marked this pull request as ready for review December 15, 2024 17:27
@cofin cofin requested review from a team as code owners December 15, 2024 17:27
@cofin cofin changed the title feat: 3.13 testing feat: add support for Python 3.13 Dec 15, 2024
@github-actions github-actions bot added area/docs This PR involves changes to the documentation area/logging size: medium and removed size: small labels Dec 15, 2024
@@ -96,7 +101,7 @@ opentelemetry = ["opentelemetry-instrumentation-asgi"]
piccolo = ["piccolo"]
picologging = ["picologging"]
prometheus = ["prometheus-client"]
pydantic = ["pydantic", "email-validator", "pydantic-extra-types"]
pydantic = ["pydantic", "email-validator", "pydantic-extra-types<=2.9.0; python_version < \"3.9\"", "pydantic-extra-types>=2.9.0; python_version >= \"3.9\""]
Copy link
Member Author

Choose a reason for hiding this comment

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

There's an open build issue re: this.

@@ -130,13 +135,14 @@ dev = [
"trio",
"aiosqlite",
"asyncpg>=0.29.0",
"psycopg[pool,binary]>=3.1.10,<3.2",
"psycopg[pool,binary]>=3.1.10,<3.2; python_version < \"3.13\"",
"psycopg[pool,c]; python_version >= \"3.13\"",
Copy link
Member Author

Choose a reason for hiding this comment

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

Package needs to be built for 3.13

from litestar.testing import TestClient

pytestmark = pytest.mark.xdist_group("sqlalchemy_examples")


def test_sqlalchemy_declarative_models() -> None:
from docs.examples.contrib.sqlalchemy.sqlalchemy_declarative_models import app
async def test_sqlalchemy_declarative_models(tmp_path: Path, monkeypatch: MonkeyPatch) -> None:
Copy link
Member Author

Choose a reason for hiding this comment

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

Without this additional monkey-patching, there were intermittent failures on this job. This is the only way I could make the tests consistently pass on all python versions.

@@ -90,9 +92,9 @@ def cleanup_logging_impl() -> Generator:
# Don't interfere with PyTest handler config
if not isinstance(std_handler, (_LiveLoggingNullHandler, LogCaptureHandler)):
std_root_logger.removeHandler(std_handler)

picologging = pytest.importorskip("picologging")
Copy link
Member Author

Choose a reason for hiding this comment

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

TIL about this. It will auto-skip if this import fails


exec(f"async def test_fn({reserved_kwarg}: int) -> None: pass")
handler_with_path_param = decorator("/{" + reserved_kwarg + ":int}")(locals()["test_fn"])
local = dict(locals(), **globals())
Copy link
Member Author

Choose a reason for hiding this comment

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

This also caused some weird issues with the scope of the locals() output. This was the only way I could consistently make sure the call to locals contained the test_fn key

"anyio>=4 ; python_version >= \"3.9\"",
"httpx>=0.22",
"exceptiongroup; python_version < \"3.11\"",
"eval_type_backport; python_version <= \"3.9\"",
Copy link
Member

Choose a reason for hiding this comment

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

Curious: Why do we need this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/ci This PR involves changes to the CI/Infra area/dependencies This PR involves changes to the dependencies area/docs This PR involves changes to the documentation area/logging pr/internal size: medium type/feat
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants