Skip to content

Commit a574d50

Browse files
committed
Py3.12 compat
1 parent 2fad88c commit a574d50

File tree

5 files changed

+20
-4
lines changed

5 files changed

+20
-4
lines changed

.github/workflows/test-src.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
runs-on: ubuntu-latest
1616
strategy:
1717
matrix:
18-
python-version: ["3.9", "3.10", "3.11"]
18+
python-version: ["3.9", "3.10", "3.11", "3.12"]
1919
steps:
2020
- uses: actions/checkout@v4
2121
- name: Use Python ${{ matrix.python-version }}

setup.py

+1
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
"Programming Language :: Python :: 3.9",
5151
"Programming Language :: Python :: 3.10",
5252
"Programming Language :: Python :: 3.11",
53+
"Programming Language :: Python :: 3.12",
5354
"Operating System :: OS Independent",
5455
"Intended Audience :: Developers",
5556
"Intended Audience :: Science/Research",

src/reactpy_django/templatetags/reactpy.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
from __future__ import annotations
22

3-
from distutils.util import strtobool
43
from logging import getLogger
54
from uuid import uuid4
65

@@ -11,7 +10,7 @@
1110
from reactpy.backend.hooks import ConnectionContext
1211
from reactpy.backend.types import Connection, Location
1312
from reactpy.core.types import ComponentConstructor
14-
from reactpy.utils import vdom_to_html
13+
from reactpy.utils import strtobool, vdom_to_html
1514

1615
from reactpy_django import config, models
1716
from reactpy_django.exceptions import (

src/reactpy_django/utils.py

+16
Original file line numberDiff line numberDiff line change
@@ -366,3 +366,19 @@ def render(self):
366366
def get_pk(model):
367367
"""Returns the value of the primary key for a Django model."""
368368
return getattr(model, model._meta.pk.name)
369+
370+
371+
def strtobool(val):
372+
"""Convert a string representation of truth to true (1) or false (0).
373+
374+
True values are 'y', 'yes', 't', 'true', 'on', and '1'; false values
375+
are 'n', 'no', 'f', 'false', 'off', and '0'. Raises ValueError if
376+
'val' is anything else.
377+
"""
378+
val = val.lower()
379+
if val in ("y", "yes", "t", "true", "on", "1"):
380+
return 1
381+
elif val in ("n", "no", "f", "false", "off", "0"):
382+
return 0
383+
else:
384+
raise ValueError("invalid truth value %r" % (val,))

tests/test_app/tests/test_components.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
import os
33
import socket
44
import sys
5-
from distutils.util import strtobool
65
from functools import partial
76
from time import sleep
87

@@ -14,6 +13,7 @@
1413
from django.test.utils import modify_settings
1514
from playwright.sync_api import TimeoutError, sync_playwright
1615
from reactpy_django.models import ComponentSession
16+
from reactpy_django.utils import strtobool
1717

1818
GITHUB_ACTIONS = os.getenv("GITHUB_ACTIONS", "False")
1919
CLICK_DELAY = 250 if strtobool(GITHUB_ACTIONS) else 25 # Delay in miliseconds.

0 commit comments

Comments
 (0)