Skip to content

Modernize codebase to Python 3.13+ and updated libraries#1

Open
Ciemaar wants to merge 16 commits intomasterfrom
modernize-codebase-5268991383469252729
Open

Modernize codebase to Python 3.13+ and updated libraries#1
Ciemaar wants to merge 16 commits intomasterfrom
modernize-codebase-5268991383469252729

Conversation

@Ciemaar
Copy link
Owner

@Ciemaar Ciemaar commented Feb 25, 2026

This PR modernizes the orbLib codebase to meet current Python standards (3.10-3.13). It includes a major restructuring of the project layout, updates to all core dependencies, and the introduction of modern development tooling.

Key Changes:

  • Project Structure: Moved source code to src/ directory and added pyproject.toml for build and dependency management.
  • Python 3 Migration: Converted all code to Python 3 syntax, fixing unicode/bytes issues (especially in Twisted interactions) and updating standard library imports.
  • Library Updates:
    • SQLAlchemy: Migrated from imperative mapper() style to modern Declarative 2.0 ORM.
    • Twisted: Replaced the deprecated client.getPage with twisted.web.client.Agent and readBody.
    • wxPython: Updated desktopSLED code to use Bind() instead of legacy EVT_* macros for wxPython Phoenix compatibility.
  • Testing: Migrated tests to pytest. Fixed DirtyReactorAggregateError in tests by properly stopping LoopingCall instances.
  • CI/CD: Added tox configuration for local testing/linting and a GitHub Actions workflow.
  • Linting: Configured ruff for linting and formatting.

Verification:

  • pytest passes all tests.
  • tox -e lint passes.
  • Manual verification of database setup logic.

PR created automatically by Jules for task 5268991383469252729 started by @Ciemaar

…aries

- Restructured project to use standard `src` layout with `pyproject.toml`.
- Migrated from Python 2 to Python 3.
- Updated `SQLAlchemy` to 2.0 (Declarative Base).
- Updated `Twisted` (replaced deprecated `getPage` with `Agent`).
- Updated `desktopSLED` for `wxPython` Phoenix compatibility.
- Migrated tests to `pytest` and fixed reactor state handling.
- Added `tox` and GitHub Actions CI configuration.
- Applied `ruff` formatting and linting.

Co-authored-by: Ciemaar <1388496+Ciemaar@users.noreply.github.com>
@google-labs-jules
Copy link

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

google-labs-jules bot and others added 6 commits February 25, 2026 17:51
…aries

- Restructured project to use standard `src` layout with `pyproject.toml`.
- Migrated from Python 2 to Python 3.
- Updated `SQLAlchemy` to 2.0 (Declarative Base).
- Updated `Twisted` (replaced deprecated `getPage` with `Agent` and fixed encoding).
- Updated `desktopSLED` for `wxPython` Phoenix compatibility.
- Migrated tests to `pytest` and fixed reactor state handling.
- Added `tox`, `ruff` (lint/format), and `pyright` (type check) configuration.
- Added GitHub Actions CI workflow.

Co-authored-by: Ciemaar <1388496+Ciemaar@users.noreply.github.com>
- Fixed critical regression where `render_GET` returned `str` instead of `bytes` in Twisted Web resources.
- Updated `src/orbLib/OaF.py` and `src/orbLib/SLOaf.py` to return encoded bytes.
- Added comprehensive unit tests in `tests/test_OaF.py` and `tests/test_SLOaf.py` to verify correct rendering types.
- Fixed `AttributeError` in `SLNotifier` tests.
- Re-verified all tests pass and linting is clean.

Co-authored-by: Ciemaar <1388496+Ciemaar@users.noreply.github.com>
- Added `.github/copilot-instructions.md` with guidelines for Python 3.13, Twisted, and SQLAlchemy 2.0.
- Cleaned up build artifacts (`__pycache__`, `egg-info`).

Co-authored-by: Ciemaar <1388496+Ciemaar@users.noreply.github.com>
- Added `mdformat` to `dev` dependencies in `pyproject.toml`.
- Configured `tox` to run `mdformat` in `lint` environment and added `format` environment.
- Updated CI workflow to check markdown formatting.
- Formatted `README.md` and `.github/copilot-instructions.md`.

Co-authored-by: Ciemaar <1388496+Ciemaar@users.noreply.github.com>
- Fixed critical XSS vulnerability in `src/orbLib/OaF.py` by escaping user input in HTML generation.
- Fixed potential `UnboundLocalError` in `src/orbLib/SerialIndy.py` by initializing global variables.
- Cleaned up minor code style issues.
- Updated tests to match corrected behavior.

Co-authored-by: Ciemaar <1388496+Ciemaar@users.noreply.github.com>
- Created `docs/user_guide.md` covering core concepts, installation, and usage.
- Created `docs/developer_guide.md` covering architecture, setup, and extending the framework.
- Linked new documentation from `README.md`.
- Updated `mdformat` configuration in `pyproject.toml` and CI to cover the `docs/` directory.

Co-authored-by: Ciemaar <1388496+Ciemaar@users.noreply.github.com>
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.pyc files are not normally committed, what is this here?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're absolutely right, my mistake. I have removed the .pyc and __pycache__ directories from version control and added a .gitignore file to prevent this in the future.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is egg-info needed with modern python packaging?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. The .egg-info directory is an artifact generated during the local editable install (pip install -e .) or build process. It should not be committed to the repository. I have removed it from version control and added it to the new .gitignore.

google-labs-jules bot and others added 2 commits March 8, 2026 07:34
- Added standard Python `.gitignore`.
- Removed accidentally committed `__pycache__` and `*.egg-info` directories.

Co-authored-by: Ciemaar <1388496+Ciemaar@users.noreply.github.com>
- Updated `src/db/__init__.py` to remove deprecated `Session.query` usage in favor of `Session.get` and `Session.scalars`.
- Refactored `get_page` in `src/orbLib/OaF.py` to use `async def` and `await` with `twisted.web.client.Agent`.
- Replaced deprecated `xmlrpc.Proxy` in `src/orbLib/SLOaf.py` with `twisted.web.client.Agent` and standard `xmlrpc.client`, using `inlineCallbacks`.
- Verified all tests and linters pass.

Co-authored-by: Ciemaar <1388496+Ciemaar@users.noreply.github.com>
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.10", "3.11", "3.12"]
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we modernized to Python 3.13 shouldn't it be included as a test version?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. I have added Python 3.13 to the CI test matrix in .github/workflows/ci.yml and also added it to the tox environments in pyproject.toml.

google-labs-jules bot and others added 7 commits March 8, 2026 23:50
- Added `3.13` to the GitHub Actions test matrix.
- Added `py313` to `tox` environments.

Co-authored-by: Ciemaar <1388496+Ciemaar@users.noreply.github.com>
- Applied modernization (Python 3 conversions, Twisted async Agent, correct bytes handling for Twisted Web) to the newly merged files (`src/SLOaFService.py`, `src/orbLib/ambient.py`).
- Updated `TestService.py` and `test_live.py` to be compatible with Python 3 and Twisted requirements.
- Fixed `AttributeError` for `setState` in `TestService` by ensuring `Notifier` provides it or uses subclasses appropriately.
- Re-formatted `README.md` per `mdformat`.

Co-authored-by: Ciemaar <1388496+Ciemaar@users.noreply.github.com>
- Configured `ruff` to allow Twisted's `camelCase` naming conventions by ignoring conflicting PEP 8 rules (`N802`, `N815`, etc.).
- Updated `.github/copilot-instructions.md` to document the Twisted style preference.
- Integrated `pytest-cov` and set a baseline `--cov-fail-under` in `pyproject.toml` to prevent test coverage from dropping.
- Added `tests/test_db.py` to test SQLAlchemy 2.0 models and improve test coverage.
- Addressed PR review feedback: Removed `tmp_oaf.py`, added `desktopSLED/__main__.py` for module execution, and refactored `MailOaf.py` protocols to use `async/await`.

Co-authored-by: Ciemaar <1388496+Ciemaar@users.noreply.github.com>
- Evaluated `mypy` vs `pyright`, deciding to keep `pyright` due to better handling of legacy imports and wxPython structure without extensive stubbing.
- Adopted `MkDocs` with `mkdocs-material` for documentation generation.
- Created `mkdocs.yml` and moved `README.md` content to `docs/index.md`.
- Wrote `docs/tooling_evaluation.md` explaining the rationale behind choosing `ruff`, `pytest`, `tox`, `pyright`, and `MkDocs`.

Co-authored-by: Ciemaar <1388496+Ciemaar@users.noreply.github.com>
- Added `docs/twisted_async_evolution.md` explaining the transition from classic `Deferred` callbacks to modern Python `async`/`await` patterns within Twisted.
- Included code examples contrasting old and new usage.
- Added documentation to `mkdocs.yml` navigation.

Co-authored-by: Ciemaar <1388496+Ciemaar@users.noreply.github.com>
- Added `codespell` to dev dependencies and `tox` lint environment to enforce correct spelling in markdown files.
- Fixed numerous typos in `README.md` and `docs/index.md` inherited from the original codebase (e.g., "depescendant" -> "descendant", "inferface" -> "interface").

Co-authored-by: Ciemaar <1388496+Ciemaar@users.noreply.github.com>
- Moved tox, pytest, ruff, and pyright configurations fully natively into `pyproject.toml`.
- Replaced the legacy tox ini block with `tool.tox` PEP-621 format.
- Ensure redundant standalone config files are non-existent.
- Verified all configurations work correctly using `tox -e lint` and the test suite.

Co-authored-by: Ciemaar <1388496+Ciemaar@users.noreply.github.com>
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.

1 participant