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

Upgrade python to 3.12 #32

Merged
merged 4 commits into from
May 6, 2024
Merged
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
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ env:
XWIN_VERSION: xwin-0.5.0-x86_64-unknown-linux-musl
XWIN_DOWNLOAD: https://github.com/Jake-Shadle/xwin/releases/download/0.5.0/xwin-0.5.0-x86_64-unknown-linux-musl.tar.gz
# Python settings
PYTHON_VERSION: "3.11.5"
PYTHON_VERSION: "3.12.3"

jobs:
cache-clang:
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 3.24)

project(pyunrealsdk VERSION 1.1.0)
project(pyunrealsdk VERSION 1.1.1)

function(_pyunrealsdk_add_base_target_args target_name)
target_compile_features(${target_name} PUBLIC cxx_std_20)
Expand Down
5 changes: 5 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## v1.1.1
- Updated CI and stubs to Python 3.12

[0d0cbce9](https://github.com/bl-sdk/pyunrealsdk/commit/0d0cbce9)

## v1.1.0

Also see the unrealsdk v1.1.0 changelog [here](https://github.com/bl-sdk/unrealsdk/blob/master/changelog.md#v110).
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
[tool.pyright]
pythonVersion = "3.11"
pythonVersion = "3.12"
typeCheckingMode = "strict"

include = ["stubs"]

[tool.ruff]
target-version = "py311"
target-version = "py312"
line-length = 100
select = [
"F",
Expand Down
2 changes: 1 addition & 1 deletion src/pyunrealsdk/debugging.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ PYUNREALSDK_CAPI(void, debug_this_thread);
}

void debug_this_thread(void) {
return PYUNREALSDK_MANGLE(debug_this_thread)();
PYUNREALSDK_MANGLE(debug_this_thread)();
}

#ifdef PYUNREALSDK_INTERNAL
Expand Down
5 changes: 2 additions & 3 deletions src/pyunrealsdk/logging.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ std::pair<std::string, int> get_python_location(PyFrameObject* frame = nullptr)
*/
class Logger {
private:
std::stringstream stream{};
std::stringstream stream;

public:
/// The log level to log at.
Expand Down Expand Up @@ -172,8 +172,7 @@ void register_module(py::module_& mod) {
" The number of chars which were written (which is always equal to the length\n"
" of the string).",
"text"_a)
.def(
"flush", [](Logger& self) { self.flush(); }, "Flushes the stream.");
.def("flush", [](Logger& self) { self.flush(); }, "Flushes the stream.");

logging.def("set_console_level", &unrealsdk::logging::set_console_level,
"Sets the log level of the unreal console.\n"
Expand Down
4 changes: 2 additions & 2 deletions stubs/unrealsdk/commands/__init__.pyi
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from __future__ import annotations

from collections.abc import Callable
from typing import Final, TypeAlias
from typing import Final

__all__: tuple[str, ...] = (
"NEXT_LINE",
Expand All @@ -12,7 +12,7 @@ __all__: tuple[str, ...] = (

NEXT_LINE: Final[str] = ...

_CommandCallback: TypeAlias = Callable[[str, int], None]
type _CommandCallback = Callable[[str, int], None]

def add_command(cmd: str, callback: _CommandCallback) -> None:
"""
Expand Down
12 changes: 6 additions & 6 deletions stubs/unrealsdk/hooks/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ from __future__ import annotations
from collections.abc import Callable
from enum import EnumMeta
from types import EllipsisType
from typing import Any, ClassVar, Literal, TypeAlias, overload
from typing import Any, ClassVar, Literal, overload

from unrealsdk.unreal import BoundFunction, UObject, WrappedStruct

Expand Down Expand Up @@ -71,15 +71,15 @@ class Unset:
return value will be used.
"""

_HookBlockSignal: TypeAlias = None | EllipsisType | Block | type[Block]
_PreHookCallback: TypeAlias = Callable[
type _HookBlockSignal = None | EllipsisType | Block | type[Block]
type _PreHookCallback = Callable[
[UObject, WrappedStruct, Any, BoundFunction],
_HookBlockSignal | tuple[_HookBlockSignal, Any],
]
_PostHookCallback: TypeAlias = Callable[[UObject, WrappedStruct, Any, BoundFunction], None]
type _PostHookCallback = Callable[[UObject, WrappedStruct, Any, BoundFunction], None]

_PreHookType: TypeAlias = Literal[Type.PRE]
_PostHookType: TypeAlias = Literal[Type.POST, Type.POST_UNCONDITIONAL]
type _PreHookType = Literal[Type.PRE]
type _PostHookType = Literal[Type.POST, Type.POST_UNCONDITIONAL]

@overload
def add_hook(
Expand Down
48 changes: 23 additions & 25 deletions stubs/unrealsdk/unreal/_wrapped_array.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,14 @@ from __future__ import annotations

from collections.abc import Callable, Iterator, Sequence
from types import GenericAlias
from typing import Any, Generic, Never, Self, TypeVar, overload
from typing import Any, Never, Self, overload

from ._uobject_children import UProperty

_T = TypeVar("_T")

class WrappedArray(Generic[_T]):
class WrappedArray[T]:
_type: UProperty

def __add__(self, values: Sequence[_T]) -> list[_T]:
def __add__(self, values: Sequence[T]) -> list[T]:
"""
Creates a list holding a copy of the array, and extends it with all the values
in the given sequence.
Expand All @@ -32,7 +30,7 @@ class WrappedArray(Generic[_T]):
Returns:
The WrappedArray class.
"""
def __contains__(self, value: _T) -> bool:
def __contains__(self, value: T) -> bool:
"""
Checks if a value exists in the array.

Expand All @@ -58,7 +56,7 @@ class WrappedArray(Generic[_T]):
range: The range to delete.
"""
@overload
def __getitem__(self, idx: int) -> _T:
def __getitem__(self, idx: int) -> T:
"""
Gets an item from the array.

Expand All @@ -68,7 +66,7 @@ class WrappedArray(Generic[_T]):
The item at the given index.
"""
@overload
def __getitem__(self, range: slice) -> list[_T]:
def __getitem__(self, range: slice) -> list[T]:
"""
Gets a range from the array.

Expand All @@ -77,7 +75,7 @@ class WrappedArray(Generic[_T]):
Returns:
The items in the given range.
"""
def __iadd__(self, values: Sequence[_T]) -> Self:
def __iadd__(self, values: Sequence[T]) -> Self:
"""
Extends the array with all the values in the given sequence in place.

Expand All @@ -92,7 +90,7 @@ class WrappedArray(Generic[_T]):
num: The number of times to repeat.
"""
def __init__(self, *args: Any, **kwargs: Any) -> Never: ...
def __iter__(self) -> Iterator[_T]:
def __iter__(self) -> Iterator[T]:
"""
Creates an iterator over the array.

Expand All @@ -106,7 +104,7 @@ class WrappedArray(Generic[_T]):
Returns:
The length of the array.
"""
def __mul__(self, num: int) -> list[_T]:
def __mul__(self, num: int) -> list[T]:
"""
Creates a list holding a copy of the array, and repeats all values in it the
given number of times.
Expand All @@ -115,7 +113,7 @@ class WrappedArray(Generic[_T]):
num: The number of times to repeat.
"""
def __new__(cls, *args: Any, **kwargs: Any) -> Never: ...
def __radd__(self, values: Sequence[_T]) -> list[_T]:
def __radd__(self, values: Sequence[T]) -> list[T]:
"""
Creates a list holding a copy of the array, and extends it with all the values
in the given sequence.
Expand All @@ -130,14 +128,14 @@ class WrappedArray(Generic[_T]):
Returns:
The string representation.
"""
def __reversed__(self) -> Iterator[_T]:
def __reversed__(self) -> Iterator[T]:
"""
Creates a reverse iterator over the array.

Returns:
A reverse iterator over the array.
"""
def __rmul__(self, num: int) -> list[_T]:
def __rmul__(self, num: int) -> list[T]:
"""
Creates a list holding a copy of the array, and repeats all values in it the
given number of times.
Expand All @@ -146,7 +144,7 @@ class WrappedArray(Generic[_T]):
num: The number of times to repeat.
"""
@overload
def __setitem__(self, idx: int, value: _T) -> None:
def __setitem__(self, idx: int, value: T) -> None:
"""
Sets an item in the array.

Expand All @@ -155,15 +153,15 @@ class WrappedArray(Generic[_T]):
value: The value to set.
"""
@overload
def __setitem__(self, range: slice, value: Sequence[_T]) -> None:
def __setitem__(self, range: slice, value: Sequence[T]) -> None:
"""
Sets a range of items in the array.

Args:
range: The range to set.
value: The values to set.
"""
def append(self, value: _T) -> None:
def append(self, value: T) -> None:
"""
Appends a value to the end of the array.

Expand All @@ -172,9 +170,9 @@ class WrappedArray(Generic[_T]):
"""
def clear(self) -> None:
"""Removes all items from the array."""
def copy(self) -> list[_T]:
def copy(self) -> list[T]:
"""Creates a list holding a copy of the array."""
def count(self, value: _T) -> int:
def count(self, value: T) -> int:
"""
Counts how many of a given value exist in the array.

Expand All @@ -183,14 +181,14 @@ class WrappedArray(Generic[_T]):
Returns:
The number of times the value appears in the array.
"""
def extend(self, values: Sequence[_T]) -> None:
def extend(self, values: Sequence[T]) -> None:
"""
Extends the array with all the values in the given sequence.

Args:
values: The sequence of values to append.
"""
def index(self, value: _T, start: int = 0, stop: int = -1) -> int:
def index(self, value: T, start: int = 0, stop: int = -1) -> int:
"""
Finds the first index of the given value in the array.

Expand All @@ -203,22 +201,22 @@ class WrappedArray(Generic[_T]):
Returns:
The first index of the value in the array.
"""
def insert(self, idx: int, value: _T) -> None:
def insert(self, idx: int, value: T) -> None:
"""
Inserts an item into the array before the given index.

Args:
idx: The index to insert before.
value: The value to insert.
"""
def pop(self, idx: int = -1) -> _T:
def pop(self, idx: int = -1) -> T:
"""
Removes an item from the array, and returns a copy of it.

Args:
idx: The index to remove the item from.
"""
def remove(self, value: _T) -> None:
def remove(self, value: T) -> None:
"""
Finds the first instance of the given value in the array, and removes it.

Expand All @@ -229,7 +227,7 @@ class WrappedArray(Generic[_T]):
"""
def reverse(self) -> None:
"""Reverses the array in place."""
def sort(self, *, key: None | Callable[[_T], Any] = None, reverse: bool = False) -> None:
def sort(self, *, key: None | Callable[[T], Any] = None, reverse: bool = False) -> None:
"""
Sorts the array in place.

Expand Down
Loading