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

[WIP] chore!: Drop python 3.8. Add python 3.13 #1711

Open
wants to merge 19 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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