Skip to content

Commit

Permalink
Update RestrictedPython to 7.0a1.dev0 for 3.12
Browse files Browse the repository at this point in the history
  • Loading branch information
cdce8p committed Oct 10, 2023
1 parent 5f0a171 commit 0f01ccf
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 25 deletions.
31 changes: 12 additions & 19 deletions homeassistant/components/python_script/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,20 @@
import glob
import logging
import os
import sys
import time

from RestrictedPython import (
compile_restricted_exec,
limited_builtins,
safe_builtins,
utility_builtins,
)
from RestrictedPython.Eval import default_guarded_getitem
from RestrictedPython.Guards import (
full_write_guard,
guarded_iter_unpack_sequence,
guarded_unpack_sequence,
)
import voluptuous as vol

from homeassistant.const import CONF_DESCRIPTION, CONF_NAME, SERVICE_RELOAD
Expand All @@ -18,20 +29,6 @@
import homeassistant.util.dt as dt_util
from homeassistant.util.yaml.loader import load_yaml

if sys.version_info < (3, 12):
from RestrictedPython import (
compile_restricted_exec,
limited_builtins,
safe_builtins,
utility_builtins,
)
from RestrictedPython.Eval import default_guarded_getitem
from RestrictedPython.Guards import (
full_write_guard,
guarded_iter_unpack_sequence,
guarded_unpack_sequence,
)

_LOGGER = logging.getLogger(__name__)

DOMAIN = "python_script"
Expand Down Expand Up @@ -85,10 +82,6 @@ class ScriptError(HomeAssistantError):

def setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Initialize the Python script component."""
if sys.version_info >= (3, 12):
raise HomeAssistantError(
"Python Scripts is not supported on Python 3.12. Please use Python 3.11."
)
path = hass.config.path(FOLDER)

if not os.path.isdir(path):
Expand Down
5 changes: 4 additions & 1 deletion homeassistant/components/python_script/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,8 @@
"documentation": "https://www.home-assistant.io/integrations/python_script",
"loggers": ["RestrictedPython"],
"quality_scale": "internal",
"requirements": ["RestrictedPython==6.2;python_version<'3.12'"]
"requirements": [
"RestrictedPython==6.2;python_version<'3.12'",
"RestrictedPython==7.0a1.dev0;python_version>='3.12'"
]
}
3 changes: 3 additions & 0 deletions requirements_all.txt
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,9 @@ RachioPy==1.0.3
# homeassistant.components.python_script
RestrictedPython==6.2;python_version<'3.12'

# homeassistant.components.python_script
RestrictedPython==7.0a1.dev0;python_version>='3.12'

# homeassistant.components.remember_the_milk
RtmAPI==0.7.2

Expand Down
3 changes: 3 additions & 0 deletions requirements_test_all.txt
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,9 @@ RachioPy==1.0.3
# homeassistant.components.python_script
RestrictedPython==6.2;python_version<'3.12'

# homeassistant.components.python_script
RestrictedPython==7.0a1.dev0;python_version>='3.12'

# homeassistant.components.remember_the_milk
RtmAPI==0.7.2

Expand Down
5 changes: 0 additions & 5 deletions tests/components/python_script/conftest.py

This file was deleted.

0 comments on commit 0f01ccf

Please sign in to comment.