Skip to content
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
65 changes: 33 additions & 32 deletions .github/workflows/build-n-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,40 +3,41 @@ name: Build 🛠️ and test 🧪 eventkit
on: [push, workflow_dispatch]

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["pypy3.10", "pypy3.11", "3.10", "3.11", "3.12", "3.13"]
build:
runs-on: ubuntu-latest
strategy:
matrix:
python-version:
["pypy3.10", "pypy3.11", "3.10", "3.11", "3.12", "3.13", "3.14"]

steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: pip
# Print the current Python version
- name: Display Python version
run: python -c "import sys; print(sys.version)"
- name: Install dependencies
run: |
python -m pip install -U pip poetry
poetry install --with dev
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: pip
# Print the current Python version
- name: Display Python version
run: python -c "import sys; print(sys.version)"
- name: Install dependencies
run: |
python -m pip install -U pip poetry
poetry install --with dev

- name: Ruff static code analysis
run: |
poetry run ruff check eventkit/
poetry run ruff format eventkit/
- name: Ruff static code analysis
run: |
poetry run ruff check eventkit/
poetry run ruff format eventkit/

- name: MyPy static code analysis
run: |
poetry run mypy .
- name: MyPy static code analysis
run: |
poetry run mypy .

- name: Test with pytest
run: |
poetry run pytest -vs
- name: Test with pytest
run: |
poetry run pytest -vs

- name: Build a binary wheel and a source tarball
run: |
poetry build -n
- name: Build a binary wheel and a source tarball
run: |
poetry build -n
13 changes: 11 additions & 2 deletions eventkit/util.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"""Eventkit utilities."""

import asyncio
import datetime as dt
from typing import AsyncIterator, Final
Expand All @@ -18,8 +20,15 @@ def __repr__(self):

def get_event_loop():
"""Get asyncio event loop or create one if it doesn't exist."""
loop = asyncio.get_event_loop_policy().get_event_loop()
return loop
try:
return asyncio.get_running_loop()
except RuntimeError:
try:
return asyncio.get_event_loop()
except RuntimeError:
loop = asyncio.new_event_loop()
asyncio.set_event_loop(loop)
return loop


async def timerange(start=0, end=None, step: float = 1) -> AsyncIterator[dt.datetime]:
Expand Down
Loading