Skip to content

Consolidate packaging into pyproject.toml and adopt ruff#9

Merged
eaguad1337 merged 3 commits into
3.xfrom
circulon/modernise-tooling
Jun 7, 2026
Merged

Consolidate packaging into pyproject.toml and adopt ruff#9
eaguad1337 merged 3 commits into
3.xfrom
circulon/modernise-tooling

Conversation

@eaguad1337

Copy link
Copy Markdown
Contributor

Migrated from MasoniteFramework/orm#955 (original author: @circulon, left as a draft by him until the other 3.x PRs landed — this lands it last, as intended). Reimplemented against current 3.x and hardened.

What this does

  • Packaging: all project metadata moves from setup.py into the pyproject.toml [project] table (PyPI name masonite-framework-orm, cleo 2 pin, masonitedev URLs, test/seeder extras, both console scripts). setup.py is deleted; python -m build — already what the publish workflow runs — is the supported build path. Verified locally: the wheel builds and contains all 110 package files plus both entry points.
  • Tooling: ruff replaces black, isort, flake8 and flake8-pyproject for linting (E/W/F/I/UP) and formatting. pytest options move from pytest.ini into pyproject. pre-commit now runs ruff plus standard hygiene hooks. The makefile exposes lint / format / format-check / check, and the CI lint gate picks them up unchanged.
  • Mechanical cleanup (separate commit): f-string conversions, import sorting, yield from, modern annotations in the Model.pyi stub.

Dead code found by the new linter

ruff's F811 flagged shadowed definitions that were silently dead, removed here:

  • QueryBuilder.get_connection — an early stub returning connection_class (not a connection), shadowed by the real cached-connection getter.
  • QueryBuilder.get_relation — referenced a nonexistent self.owner, shadowed by the real implementation.
  • A duplicated mysql schema test whose first (never-executed) variant asserted malformed SQL — mismatched parentheses, duplicate constraint names and an impossible column count — removed rather than resurrected.
  • Two test files imported tests.User and immediately shadowed it with a local User model.

Differences from the original draft

  • Line length stays at 79 (the draft used 110): the codebase is already black-79 formatted, so adopting ruff format at 79 is near zero-churn (24 files lightly reformatted vs a full rewrite).
  • E501 stays globally ignored as it was under flake8 — long SQL strings dominate the grammar modules, where the draft needed per-directory ignores anyway.
  • Dropped the bespoke isort tweaks (force-sort-within-sections) to keep import ordering compatible with the existing style.

Tests

Full suite: 1058 passed; scripts/check_test_asserts.py clean; ruff check and ruff format --check pass; wheel build verified.

circulon and others added 3 commits June 7, 2026 14:02
Ported from MasoniteFramework/orm#955 (left as draft by the author until
the other 3.x PRs landed) and adapted to the current repository state.

- All project metadata moves from setup.py to the pyproject [project]
  table (masonite-framework-orm, cleo 2 pin, masonitedev URLs); setup.py
  is removed and python -m build is the supported build path (already
  what the publish workflow runs).
- ruff replaces black, isort and flake8 for both linting (E/W/F/I/UP)
  and formatting; pytest options move from pytest.ini into pyproject.
- pre-commit now runs ruff plus standard hygiene hooks; the makefile
  exposes lint / format / format-check / check targets backed by ruff.

Differences from the original draft: line length stays at 79 (matching
the existing black formatting, so adopting the formatter is near
zero-churn) instead of 110, and E501 stays globally ignored as it was
under flake8 because long SQL strings dominate the grammar modules.
…ions

Mechanical application of the new tooling (ruff check --fix + ruff
format): f-string conversions, import sorting, yield-from, format-spec
upgrades and modern annotations in the Model stub.

ruff's F811 also flagged real dead code, removed here:

- QueryBuilder.get_connection (early stub returning connection_class)
  and QueryBuilder.get_relation (referenced a nonexistent self.owner) —
  both shadowed by the real definitions later in the class.
- tests/mysql: a duplicated test_can_add_columns_with_foreign_key
  test whose first (shadowed) variant asserted malformed SQL and an
  impossible column count, plus User imports shadowed by local model
  classes in two files.
@eaguad1337 eaguad1337 merged commit 4420708 into 3.x Jun 7, 2026
14 checks passed
@eaguad1337 eaguad1337 deleted the circulon/modernise-tooling branch June 7, 2026 18:15
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