Skip to content

Restore Python 3.8/3.9 compatibility for unit-test collection#19

Merged
erseco merged 5 commits intomainfrom
copilot/improve-ci-coverage-python-moodle
Mar 16, 2026
Merged

Restore Python 3.8/3.9 compatibility for unit-test collection#19
erseco merged 5 commits intomainfrom
copilot/improve-ci-coverage-python-moodle

Conversation

Copy link
Contributor

Copilot AI commented Mar 16, 2026

make test-unit was failing on Python 3.8 and 3.9 during tests/conftest.py import. The failure came from runtime evaluation of newer type-hint syntax in modules pulled in during unit-test collection.

  • Unit test collection

    • Removed eager py_moodle imports from /home/runner/work/python-moodle/python-moodle/tests/conftest.py
    • Deferred Moodle-specific imports into the integration fixtures that actually need them
    • Keeps tests/unit collection independent from the integration stack
  • Python 3.8/3.9 compatibility

    • Added from __future__ import annotations to the modules reached by smoke tests:
      • /home/runner/work/python-moodle/python-moodle/src/py_moodle/session.py
      • /home/runner/work/python-moodle/python-moodle/src/py_moodle/course.py
      • /home/runner/work/python-moodle/python-moodle/src/py_moodle/folder.py
      • /home/runner/work/python-moodle/python-moodle/src/py_moodle/module.py
    • Prevents annotations like dict[str, ...] and str | None from being evaluated at import time on older supported interpreters
  • Effect on CI

    • Restores the test-unit path for the supported Python matrix without changing integration-test behavior

Example of the compatibility change:

from __future__ import annotations

class MoodleSession:
    _cache: dict[str, "MoodleSession"] = {}

    @property
    def token(self) -> str | None:
        return self._token

🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

Copilot AI and others added 2 commits March 16, 2026 09:43
Co-authored-by: erseco <1876752+erseco@users.noreply.github.com>
Co-authored-by: erseco <1876752+erseco@users.noreply.github.com>
Copilot AI changed the title [WIP] Add CI coverage for multiple supported Python and Moodle versions Expand CI coverage across supported Python versions and representative Moodle versions Mar 16, 2026
Copilot AI requested a review from erseco March 16, 2026 09:49
Co-authored-by: erseco <1876752+erseco@users.noreply.github.com>
Copilot AI changed the title Expand CI coverage across supported Python versions and representative Moodle versions Restore Python 3.8/3.9 compatibility for unit-test collection Mar 16, 2026
@erseco erseco marked this pull request as ready for review March 16, 2026 10:34
@erseco erseco merged commit f966f44 into main Mar 16, 2026
13 checks passed
@erseco erseco deleted the copilot/improve-ci-coverage-python-moodle branch March 16, 2026 10:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants