Skip to content

chore!: Add python 3.13 support #1711

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

Open
wants to merge 29 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
d281879
Drop python 3.8. Add python 3.13
schloerke Oct 1, 2024
fdc685c
Update 3.13 python versions to 3.13-dev
schloerke Oct 1, 2024
21f1022
Remove `WrapAsync` code
schloerke Oct 1, 2024
958b051
Use `3.13.0-rc.2` version
schloerke Oct 1, 2024
d07d067
Bump python version to 3.13.0-rc.3
schloerke Oct 1, 2024
0ecd6dc
Merge branch 'main' into bump_versions
schloerke Oct 1, 2024
fe6e2da
Merge branch 'main' into bump_versions
schloerke Oct 7, 2024
c568fd3
Merge branch 'main' into bump_versions
schloerke Oct 7, 2024
43fd104
Try short version
schloerke Oct 7, 2024
97bba3f
Merge branch 'bump_versions' of https://github.com/posit-dev/py-shiny…
schloerke Oct 7, 2024
8f9e8c1
Update pytest.yaml
schloerke Oct 7, 2024
257f7f6
Allow for pre-releases
schloerke Oct 7, 2024
cf723ec
try using pip for now. Revert commit later!
schloerke Oct 7, 2024
5e7a61c
Revert "try using pip for now. Revert commit later!"
schloerke Oct 7, 2024
62d52ae
Update playwright as 1.43 depends on greenlet version that is incompa…
schloerke Oct 7, 2024
02e8f91
Reapply "try using pip for now. Revert commit later!"
schloerke Oct 7, 2024
70dfdfa
Revert "Reapply "try using pip for now. Revert commit later!""
schloerke Oct 7, 2024
a304dba
Remove `allow-prereleases: true` flag
schloerke Oct 10, 2024
5a84f69
Use playwright version from github until next release
schloerke Oct 11, 2024
4b8bb6a
Use playwright v1.48.0 w/ Py3.13 support
schloerke Oct 22, 2024
6afc4a9
Merge branch 'main' into bump_versions
schloerke Feb 3, 2025
940e032
Merge branch 'main' into bump_versions
cpsievert Feb 26, 2025
3db13c0
Don't install ray on pyton 3.13
cpsievert Feb 26, 2025
42ee7a2
Do same for modin
cpsievert Feb 26, 2025
40cc6da
Undo test_chat changes
cpsievert Feb 26, 2025
e450da5
Merge branch 'main' into bump_versions
cpsievert Mar 3, 2025
b8b6d24
fix(tests): skip modin tests if python version == 3.13 (#1882)
karangattu Mar 6, 2025
41af702
Merge branch 'main' into bump_versions
schloerke Apr 8, 2025
a3f675b
Skip test w/ modin for anyting >= 3.13
schloerke Apr 8, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions .github/py-shiny/setup/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ inputs:
python-version:
description: 'Python version to use'
required: false
default: "3.12"
default: "3.13"
runs:
using: "composite"
steps:
Expand Down Expand Up @@ -39,12 +39,6 @@ runs:
run: |
make ci-install-wheel

- name: Install backports.tarfile
if: ${{ startsWith(inputs.python-version, '3.8') }}
shell: bash
run: |
uv pip install backports.tarfile

- name: Pip list
shell: bash
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build-docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.12"]
python-version: ["3.13"]
fail-fast: false

steps:
Expand Down
10 changes: 4 additions & 6 deletions .github/workflows/pytest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
strategy:
matrix:
# "3.10" must be a string; otherwise it is interpreted as 3.1.
python-version: ["3.12", "3.11", "3.10", "3.9"]
python-version: ["3.13", "3.12", "3.11", "3.10", "3.9"]
os: [ubuntu-latest, windows-latest, macOS-latest]
exclude:
- python-version: ${{ github.event.pull_request.draft && '3.11' }}
Expand Down Expand Up @@ -73,7 +73,7 @@ jobs:
with:
fetch-depth: 0
- name: "Set up Python 3.10"
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: Install dependencies
Expand Down Expand Up @@ -107,7 +107,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.12", "3.11", "3.10", "3.9"]
python-version: ["3.13", "3.12", "3.11", "3.10", "3.9"]
browser: ["chromium", "firefox", "webkit"]
exclude:
- python-version: ${{ github.event.pull_request.draft && '3.11' }}
Expand All @@ -117,8 +117,6 @@ jobs:
- browser: ${{ github.event.pull_request.draft && 'webkit' }}
# There are many unexplained tests that fail on webkit w/ python 3.8, 3.9
# Given the more recent versions of python work, we will exclude this combination
- browser: "webkit"
python-version: "3.8"
- browser: "webkit"
python-version: "3.9"
fail-fast: false
Expand Down Expand Up @@ -157,7 +155,7 @@ jobs:
runs-on: ubuntu-20.04
strategy:
matrix:
python-version: ["3.12", "3.11", "3.10", "3.9"]
python-version: ["3.13", "3.12", "3.11", "3.10", "3.9"]
browser: ["chromium", "firefox", "webkit"]
exclude:
- python-version: ${{ github.event.pull_request.draft && '3.11' }}
Expand Down
6 changes: 4 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ classifiers = [
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
]
dependencies = [
"typing-extensions>=4.10.0",
Expand Down Expand Up @@ -56,8 +57,9 @@ theme = ["libsass>=0.23.0"]
test = [
"pytest>=6.2.4",
"pytest-asyncio>=0.17.2",
"pytest-playwright>=0.3.0",
"playwright>=1.43.0",
"pytest-playwright>=0.5.2",
# "playwright>1.47.0",
"playwright@git+https://github.com/microsoft/playwright-python@main",
"pytest-xdist",
"pytest-timeout",
"pytest-rerunfailures",
Expand Down
2 changes: 0 additions & 2 deletions shiny/_datastructures.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ class PriorityQueueFIFO(Generic[T]):
"""

def __init__(self) -> None:
# Using Tuple instead of tuple because in Python 3.8 and earlier, tuple isn't
# generic
self._pq: PriorityQueue[tuple[int, int, T]] = PriorityQueue()
self._counter: int = 0

Expand Down
58 changes: 1 addition & 57 deletions shiny/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,16 +72,14 @@ def sort_keys_length(x: dict[str, T], descending: bool = False) -> dict[str, T]:


def guess_mime_type(
url: "str | os.PathLike[str]",
url: str | os.PathLike[str],
default: str = "application/octet-stream",
strict: bool = True,
) -> str:
"""
Guess the MIME type of a file. This is a wrapper for mimetypes.guess_type, but it
only returns the type (and not encoding), and it allows a default value.
"""
# Note that in the parameters above, "os.PathLike[str]" is in quotes to avoid
# "TypeError: 'ABCMeta' object is not subscriptable", in Python<=3.8.
if url:
# Work around issue #1601, some installations of Windows 10 return text/plain
# as the mime type for .js files
Expand Down Expand Up @@ -281,60 +279,6 @@ async def fn_async(*args: P.args, **kwargs: P.kwargs) -> R:
return fn_async


# # TODO-barret-future; Q: Keep code?
# class WrapAsync(Generic[P, R]):
# """
# Make a function asynchronous.

# Parameters
# ----------
# fn
# Function to make asynchronous.

# Returns
# -------
# :
# Asynchronous function (within the `WrapAsync` instance)
# """

# def __init__(self, fn: Callable[P, R] | Callable[P, Awaitable[R]]):
# if isinstance(fn, WrapAsync):
# fn = cast(WrapAsync[P, R], fn)
# return fn
# self._is_async = is_async_callable(fn)
# self._fn = wrap_async(fn)

# async def __call__(self, *args: P.args, **kwargs: P.kwargs) -> R:
# """
# Call the asynchronous function.
# """
# return await self._fn(*args, **kwargs)

# @property
# def is_async(self) -> bool:
# """
# Was the original function asynchronous?

# Returns
# -------
# :
# Whether the original function is asynchronous.
# """
# return self._is_async

# @property
# def fn(self) -> Callable[P, R] | Callable[P, Awaitable[R]]:
# """
# Retrieve the original function

# Returns
# -------
# :
# Original function supplied to the `WrapAsync` constructor.
# """
# return self._fn


# This function should generally be used in this code base instead of
# `iscoroutinefunction()`.
def is_async_callable(
Expand Down
3 changes: 0 additions & 3 deletions shiny/render/_render.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@
import os
import sys
import typing

# `typing.Dict` sed for python 3.8 compatibility
# Can use `dict` in python >= 3.9
from typing import TYPE_CHECKING, Any, Callable, Literal, Optional, Union, cast

from htmltools import Tag, TagAttrValue, TagChild
Expand Down
3 changes: 0 additions & 3 deletions shiny/render/renderer/_renderer.py
Original file line number Diff line number Diff line change
Expand Up @@ -336,9 +336,6 @@ def _auto_register(self) -> None:
self._auto_registered = True


# Not inheriting from `WrapAsync[[], IT]` as python 3.8 needs typing extensions that
# doesn't support `[]` for a ParamSpec definition. :-( Would be minimal/clean if we
# could do `class AsyncValueFn(WrapAsync[[], IT]):`
class AsyncValueFn(Generic[IT]):
"""
App-supplied output value function which returns type `IT`.
Expand Down
13 changes: 2 additions & 11 deletions tests/pytest/test_chat.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from __future__ import annotations

import sys
from datetime import datetime
from typing import Union, cast, get_args, get_origin

Expand Down Expand Up @@ -202,10 +201,6 @@ def test_langchain_normalization():


def test_google_normalization():
# Not available for Python 3.8
if sys.version_info < (3, 9):
return

from google.generativeai import ( # pyright: ignore[reportMissingTypeStubs]
GenerativeModel,
)
Expand Down Expand Up @@ -362,16 +357,12 @@ def test_as_anthropic_message():


def test_as_google_message():
from shiny.ui._chat_provider_types import as_google_message

# Not available for Python 3.8
if sys.version_info < (3, 9):
return

from google.generativeai import ( # pyright: ignore[reportMissingTypeStubs]
GenerativeModel,
)

from shiny.ui._chat_provider_types import as_google_message

generate_content = GenerativeModel.generate_content # type: ignore

assert generate_content.__annotations__["contents"] == "content_types.ContentsType"
Expand Down
Loading