From c0f12720127d4d4c1e71a2ec576bfa51468bceef Mon Sep 17 00:00:00 2001 From: Sergey Vasilyev Date: Fri, 13 Jun 2025 20:24:39 +0200 Subject: [PATCH 1/6] Upgrade the GitHub Actions Signed-off-by: Sergey Vasilyev --- .github/workflows/ci.yaml | 16 ++++++++-------- .github/workflows/publish.yaml | 4 ++-- .github/workflows/thorough.yaml | 16 ++++++++-------- 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 9e44b35..51e3197 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -12,8 +12,8 @@ jobs: runs-on: ubuntu-20.04 timeout-minutes: 5 steps: - - uses: actions/checkout@v2 - - uses: actions/setup-python@v2 + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 with: python-version: "3.10" - run: pip install -r requirements.txt @@ -29,8 +29,8 @@ jobs: runs-on: ubuntu-20.04 timeout-minutes: 5 steps: - - uses: actions/checkout@v2 - - uses: actions/setup-python@v2 + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} @@ -45,7 +45,7 @@ jobs: GITHUB_TOKEN: ${{ secrets.github_token }} continue-on-error: true - name: Publish coverage to CodeCov.io - uses: codecov/codecov-action@v1 + uses: codecov/codecov-action@v3 if: success() env: PYTHON: ${{ matrix.python-version }} @@ -64,8 +64,8 @@ jobs: runs-on: ubuntu-20.04 timeout-minutes: 5 steps: - - uses: actions/checkout@v2 - - uses: actions/setup-python@v2 + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} @@ -78,7 +78,7 @@ jobs: needs: [unit-tests] runs-on: ubuntu-20.04 steps: - - uses: actions/setup-python@v2 + - uses: actions/setup-python@v5 - run: pip install coveralls - run: coveralls --service=github --finish env: diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml index 1a2f551..37d1c83 100644 --- a/.github/workflows/publish.yaml +++ b/.github/workflows/publish.yaml @@ -13,8 +13,8 @@ jobs: name: Build and publish runs-on: ubuntu-20.04 steps: - - uses: actions/checkout@v2 - - uses: actions/setup-python@v2 + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 with: python-version: "3.10" - run: pip install --upgrade setuptools wheel twine diff --git a/.github/workflows/thorough.yaml b/.github/workflows/thorough.yaml index 4970cf5..cb9331b 100644 --- a/.github/workflows/thorough.yaml +++ b/.github/workflows/thorough.yaml @@ -14,8 +14,8 @@ jobs: runs-on: ubuntu-20.04 timeout-minutes: 5 steps: - - uses: actions/checkout@v2 - - uses: actions/setup-python@v2 + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 with: python-version: "3.10" - run: pip install -r requirements.txt @@ -31,8 +31,8 @@ jobs: runs-on: ubuntu-20.04 timeout-minutes: 5 steps: - - uses: actions/checkout@v2 - - uses: actions/setup-python@v2 + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} @@ -47,7 +47,7 @@ jobs: GITHUB_TOKEN: ${{ secrets.github_token }} continue-on-error: true - name: Publish coverage to CodeCov.io - uses: codecov/codecov-action@v1 + uses: codecov/codecov-action@v3 if: success() env: PYTHON: ${{ matrix.python-version }} @@ -66,8 +66,8 @@ jobs: runs-on: ubuntu-20.04 timeout-minutes: 5 steps: - - uses: actions/checkout@v2 - - uses: actions/setup-python@v2 + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} @@ -80,7 +80,7 @@ jobs: needs: [unit-tests] runs-on: ubuntu-20.04 steps: - - uses: actions/setup-python@v2 + - uses: actions/setup-python@v5 - run: pip install coveralls - run: coveralls --service=github --finish env: From 881c2dd1efdfa00dc22b2dee1ccbf4ff2be03507 Mon Sep 17 00:00:00 2001 From: Sergey Vasilyev Date: Fri, 13 Jun 2025 20:38:39 +0200 Subject: [PATCH 2/6] Upgrade pre-commit plugins Signed-off-by: Sergey Vasilyev --- .pre-commit-config.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 8d7f392..ad81251 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -7,7 +7,7 @@ exclude: | ) repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v3.4.0 + rev: v5.0.0 hooks: - id: check-ast - id: trailing-whitespace @@ -46,7 +46,7 @@ repos: # - id: double-quote-string-fixer - repo: https://github.com/pre-commit/pygrep-hooks - rev: v1.8.0 + rev: v1.10.0 hooks: - id: python-check-blanket-noqa - id: python-check-mock-methods @@ -59,7 +59,7 @@ repos: - id: text-unicode-replacement-char - repo: https://github.com/PyCQA/isort - rev: 5.8.0 + rev: 6.0.1 hooks: - id: isort name: isort-source-code From f0f3353e5c3ed457811ad6952aed8154b55e477e Mon Sep 17 00:00:00 2001 From: Sergey Vasilyev Date: Fri, 13 Jun 2025 20:25:23 +0200 Subject: [PATCH 3/6] Upgrade the CI Ubuntu from 20.04 to 24.04 Signed-off-by: Sergey Vasilyev --- .github/workflows/ci.yaml | 8 ++++---- .github/workflows/publish.yaml | 2 +- .github/workflows/thorough.yaml | 8 ++++---- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 51e3197..6fa1b12 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -9,7 +9,7 @@ on: jobs: linters: name: Linting and static analysis - runs-on: ubuntu-20.04 + runs-on: ubuntu-24.04 timeout-minutes: 5 steps: - uses: actions/checkout@v4 @@ -26,7 +26,7 @@ jobs: matrix: python-version: [ "3.7", "3.8", "3.9", "3.10" ] name: Python ${{ matrix.python-version }} - runs-on: ubuntu-20.04 + runs-on: ubuntu-24.04 timeout-minutes: 5 steps: - uses: actions/checkout@v4 @@ -61,7 +61,7 @@ jobs: matrix: python-version: [ "pypy-3.7", "pypy-3.8" ] name: Python ${{ matrix.python-version }} - runs-on: ubuntu-20.04 + runs-on: ubuntu-24.04 timeout-minutes: 5 steps: - uses: actions/checkout@v4 @@ -76,7 +76,7 @@ jobs: coveralls-finish: name: Finalize coveralls.io needs: [unit-tests] - runs-on: ubuntu-20.04 + runs-on: ubuntu-24.04 steps: - uses: actions/setup-python@v5 - run: pip install coveralls diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml index 37d1c83..ec46ebe 100644 --- a/.github/workflows/publish.yaml +++ b/.github/workflows/publish.yaml @@ -11,7 +11,7 @@ on: jobs: publish: name: Build and publish - runs-on: ubuntu-20.04 + runs-on: ubuntu-24.04 steps: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 diff --git a/.github/workflows/thorough.yaml b/.github/workflows/thorough.yaml index cb9331b..caa2345 100644 --- a/.github/workflows/thorough.yaml +++ b/.github/workflows/thorough.yaml @@ -11,7 +11,7 @@ on: jobs: linters: name: Linting and static analysis - runs-on: ubuntu-20.04 + runs-on: ubuntu-24.04 timeout-minutes: 5 steps: - uses: actions/checkout@v4 @@ -28,7 +28,7 @@ jobs: matrix: python-version: [ "3.7", "3.8", "3.9", "3.10" ] name: Python ${{ matrix.python-version }} - runs-on: ubuntu-20.04 + runs-on: ubuntu-24.04 timeout-minutes: 5 steps: - uses: actions/checkout@v4 @@ -63,7 +63,7 @@ jobs: matrix: python-version: [ "pypy-3.7", "pypy-3.8" ] name: Python ${{ matrix.python-version }} - runs-on: ubuntu-20.04 + runs-on: ubuntu-24.04 timeout-minutes: 5 steps: - uses: actions/checkout@v4 @@ -78,7 +78,7 @@ jobs: coveralls-finish: name: Finalize coveralls.io needs: [unit-tests] - runs-on: ubuntu-20.04 + runs-on: ubuntu-24.04 steps: - uses: actions/setup-python@v5 - run: pip install coveralls From 99c265d6a83331295463841a9567e69153adea6b Mon Sep 17 00:00:00 2001 From: Sergey Vasilyev Date: Fri, 13 Jun 2025 20:32:10 +0200 Subject: [PATCH 4/6] Drop Python versions 3.7, 3.8, include 3.9, 3.10, 3.11, 3.12, 3.13 Signed-off-by: Sergey Vasilyev --- .github/workflows/ci.yaml | 6 +++--- .github/workflows/thorough.yaml | 6 +++--- requirements.txt | 3 +-- setup.py | 2 +- 4 files changed, 8 insertions(+), 9 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 6fa1b12..00835fb 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -15,7 +15,7 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 with: - python-version: "3.10" + python-version: "3.13" - run: pip install -r requirements.txt - run: pre-commit run --all-files - run: mypy looptime --strict @@ -24,7 +24,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: [ "3.7", "3.8", "3.9", "3.10" ] + python-version: [ "3.9", "3.10", "3.11", "3.12", "3.13" ] name: Python ${{ matrix.python-version }} runs-on: ubuntu-24.04 timeout-minutes: 5 @@ -59,7 +59,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: [ "pypy-3.7", "pypy-3.8" ] + python-version: [ "pypy-3.9", "pypy-3.10", "pypy-3.11" ] name: Python ${{ matrix.python-version }} runs-on: ubuntu-24.04 timeout-minutes: 5 diff --git a/.github/workflows/thorough.yaml b/.github/workflows/thorough.yaml index caa2345..2206545 100644 --- a/.github/workflows/thorough.yaml +++ b/.github/workflows/thorough.yaml @@ -17,7 +17,7 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 with: - python-version: "3.10" + python-version: "3.13" - run: pip install -r requirements.txt - run: pre-commit run --all-files - run: mypy looptime --strict @@ -26,7 +26,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: [ "3.7", "3.8", "3.9", "3.10" ] + python-version: [ "3.9", "3.10", "3.11", "3.12", "3.13" ] name: Python ${{ matrix.python-version }} runs-on: ubuntu-24.04 timeout-minutes: 5 @@ -61,7 +61,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: [ "pypy-3.7", "pypy-3.8" ] + python-version: [ "pypy-3.9", "pypy-3.10", "pypy-3.11" ] name: Python ${{ matrix.python-version }} runs-on: ubuntu-24.04 timeout-minutes: 5 diff --git a/requirements.txt b/requirements.txt index 8b2f6e4..335cf94 100644 --- a/requirements.txt +++ b/requirements.txt @@ -6,8 +6,7 @@ codecov coverage coveralls isort -# Mypy requires typed-ast, which is broken on PyPy 3.7 (could work in PyPy 3.8). -mypy==0.920; implementation_name == "cpython" +mypy==0.920 pre-commit pytest pytest-asyncio diff --git a/setup.py b/setup.py index c60e8a9..b459ccd 100644 --- a/setup.py +++ b/setup.py @@ -38,7 +38,7 @@ ] }, - python_requires='>=3.7', + python_requires='>=3.9', setup_requires=[ 'setuptools_scm', ], From 537f460ed2ba28faeebd32e377c8ae4321241b74 Mon Sep 17 00:00:00 2001 From: Sergey Vasilyev Date: Fri, 13 Jun 2025 20:35:42 +0200 Subject: [PATCH 5/6] Restrict pytest-asyncio to <1.0.0 for own CI tests Looptime is conceptually incompatible with pytest-asyncio>=1.0.0, since the latter adds multi-scoped event loops, and looptime expects the event loop to be strictly function-scoped: it resets the time to 0 for every test, and patches the event loop on every test, so on. This requires a bigger rework of looptime. Meanwhile, let its own tests run with the older (compatible) versions of pytest-asyncio. Note that there is NO direct dependency on `pytest-asyncio`, so this restriction cannot be enforced in looptime's own dependencies. There could be different other prodivers of the `event_loop` fixture, in theory, of which pytest-asyncio is only one. Signed-off-by: Sergey Vasilyev --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 335cf94..c22b769 100644 --- a/requirements.txt +++ b/requirements.txt @@ -9,6 +9,6 @@ isort mypy==0.920 pre-commit pytest -pytest-asyncio +pytest-asyncio<1.0.0 pytest-cov pytest-mock From dd730961fe401b57f538ed82589d6fa04817bccf Mon Sep 17 00:00:00 2001 From: Sergey Vasilyev Date: Fri, 13 Jun 2025 20:49:28 +0200 Subject: [PATCH 6/6] Upgrade MyPy to 1.16.0 and fix a few typing issues Signed-off-by: Sergey Vasilyev --- looptime/loops.py | 2 +- looptime/math.py | 4 +++- looptime/plugin.py | 2 +- requirements.txt | 2 +- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/looptime/loops.py b/looptime/loops.py index 21d763d..fe4a6d2 100644 --- a/looptime/loops.py +++ b/looptime/loops.py @@ -96,7 +96,7 @@ def setup_looptime( def time(self) -> float: return self.__int2time(self.__now) - def run_in_executor(self, executor: Any, func: Any, *args: Any) -> AnyFuture: + def run_in_executor(self, executor: Any, func: Any, *args: Any) -> AnyFuture: # type: ignore future = super().run_in_executor(executor, func, *args) if isinstance(future, asyncio.Future): self.__sync_futures.add(future) diff --git a/looptime/math.py b/looptime/math.py index 40831ef..6ac3b13 100644 --- a/looptime/math.py +++ b/looptime/math.py @@ -1,6 +1,7 @@ from __future__ import annotations import abc +from typing import Any class Numeric(metaclass=abc.ABCMeta): @@ -108,5 +109,6 @@ def __mod__(self, other: object) -> float: else: return NotImplemented - def __pow__(self, power: float, modulo: None = None) -> float: + # See the StdLib's comments on pow() on why it is Any, not float. + def __pow__(self, power: float, modulo: None = None) -> Any: return pow(round(self._value * self.__rr), power, modulo) / pow(self.__rr, power, modulo) diff --git a/looptime/plugin.py b/looptime/plugin.py index e825340..6b6405a 100644 --- a/looptime/plugin.py +++ b/looptime/plugin.py @@ -8,7 +8,7 @@ from looptime import loops, patchers -@pytest.hookimpl(hookwrapper=True) # type: ignore +@pytest.hookimpl(hookwrapper=True) def pytest_fixture_setup(fixturedef: Any, request: Any) -> Any: if fixturedef.argname == "event_loop": result = yield diff --git a/requirements.txt b/requirements.txt index c22b769..ec4f742 100644 --- a/requirements.txt +++ b/requirements.txt @@ -6,7 +6,7 @@ codecov coverage coveralls isort -mypy==0.920 +mypy==1.16.0 pre-commit pytest pytest-asyncio<1.0.0