8000 Add python 3.13 support by Meallia · Pull Request #1132 · nolar/kopf · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Add python 3.13 support #1132

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

Merged
merged 3 commits into from
Nov 18, 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
6 changes: 3 additions & 3 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: "3.12"
python-version: "3.13"
- run: pip install -r requirements.txt
- run: pre-commit run --all-files
- run: mypy kopf --strict
Expand All @@ -38,10 +38,10 @@ jobs:
fail-fast: false
matrix:
install-extras: [ "", "full-auth" ]
python-version: [ "3.8", "3.9", "3.10", "3.11", "3.12" ]
python-version: [ "3.8", "3.9", "3.10", "3.11", "3.12", "3.13" ]
include:
- install-extras: "uvloop"
python-version: "3.12"
python-version: "3.13"
name: Python ${{ matrix.python-version }} ${{ matrix.install-extras }}
runs-on: ubuntu-22.04
timeout-minutes: 5 # usually 2-3 mins
Expand Down
12 changes: 7 additions & 5 deletions kopf/_core/engines/posting.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,11 +183,13 @@ class K8sPoster(logging.Handler):
"""
A handler to post all log messages as K8s events.
"""

def createLock(self) -> None:
# Save some time on unneeded locks. Events are posted in the background.
# We only put events to the queue, which is already lock-protected.
self.lock = None
if sys.version_info[:2] < (3, 13):
# Disable this optimisation for Python >= 3.13.
# The `handle` no longer support having `None` as lock.
def createLock(self) -> None:
# Save some time on unneeded locks. Events are posted in the background.
# We only put events to the queue, which is already lock-protected.
self.lock = None

def filter(self, record: logging.LogRecord) -> bool:
# Only those which have a k8s object referred (see: `ObjectLogger`).
Expand Down
1 change: 1 addition & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[pytest]
asyncio_mode = auto
asyncio_default_fixture_loop_scope = function
addopts =
--strict-markers
2 changes: 1 addition & 1 deletion 2 requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@ pytest-asyncio
pytest-cov
pytest-mock
pytest-timeout
types-pkg_resources
types-PyYAML
types-setuptools
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11',
'Programming Language :: Python :: 3.12',
'Programming Language :: Python :: 3.13',
'Programming Language :: Python :: 3 :: Only',
'Programming Language :: Python :: Implementation :: CPython',
'Programming Language :: Python :: Implementation :: PyPy',
Expand Down
7 changes: 6 additions & 1 deletion tests/peering/test_keepalive.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
from itertools import chain, repeat
from unittest import mock

import pytest

from kopf._core.engines.peering import keepalive
Expand All @@ -11,7 +14,9 @@ async def test_background_task_runs(mocker, settings, namespaced_peering_resourc
touch_mock = mocker.patch('kopf._core.engines.peering.touch')

sleep_mock = mocker.patch('asyncio.sleep')
sleep_mock.side_effect = [None, None, StopInfiniteCycleException]
# restore the default behavior after exhausting test values.
# pytest-aiohttp calls asyncio.sleep during teardown, before the mock is removed.
sleep_mock.side_effect = chain([None, None, StopInfiniteCycleException], repeat(mock.DEFAULT))

randint_mock = mocker.patch('random.randint')
randint_mock.side_effect = [7, 5, 9]
Expand Down
419B
Loading
0