Skip to content

Pre commit lint and format update#250

Merged
Ckk3 merged 2 commits intomainfrom
pre-commit-lint-and-format-update
May 24, 2025
Merged

Pre commit lint and format update#250
Ckk3 merged 2 commits intomainfrom
pre-commit-lint-and-format-update

Conversation

@Ckk3
Copy link
Copy Markdown
Contributor

@Ckk3 Ckk3 commented May 24, 2025

Description

This branch are the develop branch of this pre-commit patch with has this 2 PRs:

Both PR already has been reviewed and aproved, so I will marge this PR

Types of Changes

  • Core
  • Bugfix
  • New feature
  • Enhancement/optimization
  • Documentation

Issues Fixed or Closed by This PR

Checklist

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • I have tested the changes and verified that they work and don't break anything (as well as I can manage).

Summary by Sourcery

Update linting and formatting pipeline by migrating from Black to Ruff, consolidating CI and nox workflows, upgrading the build backend to poetry-core, and applying codebase-wide style adjustments.

Enhancements:

  • Migrate styling from Black to Ruff with updated line-length, indent settings, and lint-ignore rules
  • Consolidate multi-line comprehensions and lambdas to single-line forms for consistency
  • Remove deprecated .isort.cfg and tool.black settings
  • Add RELEASE.md describing the patch release for code quality improvements

Build:

  • Upgrade build backend to poetry-core in pyproject.toml

CI:

  • Add nox sessions for Ruff lint and format alongside existing tests and Mypy runs
  • Extract common Poetry install logic in noxfile
  • Update GitHub Actions workflow to run lint and format steps and expand pull_request triggers

Documentation:

  • Simplify Sphinx conf.py error handling and f-string usage

Tests:

  • Rename test helper functions and update assertions to align with formatting changes

Chores:

  • Migrate pre-commit-config to use Ruff hooks (lint and format) and add Taplo for TOML formatting

Ckk3 added 2 commits May 20, 2025 10:41
* Adding the changes we made in precommit, poetry, nox

* add release.md
* Update pre-commit and mypy .ini just like the main strawberry project

* add a lint error on purpose to test lint

* add a release md and add file attr to tmol pre-commit

* fix test action to run when a PR is ready for review

* test mappe

* fix action

* continue with tests in lint in nox file

* remove pydantic.mypy plugin

* made first lint ajustment, but still missing lint test

* add ruff and black to lint te

* Fix nox file and add ruff to pyptoject toml

* fix poetry lock

* fix command to raise error

* make ruff output errors

* bring back black to pre-commit

* remove --diff from ruff because we want to run in all files, remove invalid rules in lint

* update pre-commit to ruff run lint and formatter

* separate ruff lint from formater in noxfile

* remove test function from mapper

* remove black and use only ruff

* add lint tag to ruff format in nox

* change test.yml to run lint and format divided

* Run pre-commit in all files and made line-lenght 100

* updated ruff check

* update pyproject.toml

* Made sourcery fixes

* remove unecessary else

* bring back session._session
@Ckk3 Ckk3 self-assigned this May 24, 2025
@sourcery-ai
Copy link
Copy Markdown
Contributor

sourcery-ai bot commented May 24, 2025

Reviewer's Guide

This PR consolidates two approved pre-commit updates by standardizing project tooling (Poetry, Ruff, pre-commit hooks, CI matrix), refactoring the nox sessions, and applying automated code formatting across the codebase.

File-Level Changes

Change Details Files
Normalize Poetry and project configuration
  • Switch build backend from poetry.masonry.api to poetry.core.masonry.api
  • Reformat dependencies and extras spacing in pyproject.toml
  • Restructure and rename tool.ruff settings (lint.select, lint.ignore, lint.per-file-ignores)
  • Remove deprecated sections (tool.black, tool.ruff per-file-ignores and isort) and consolidate in pyproject.toml
pyproject.toml
.github/pyproject.toml
Revamp pre-commit and CI workflows
  • Replace Black hook with ruff-check and ruff-format in .pre-commit-config.yaml
  • Add taplo-format hook for TOML files
  • Extend PR triggers (synchronize, reopened, ready_for_review) and include format step in GitHub Actions
  • Update Dependabot config to use new lint key and exclude internal Strawberry dependency
  • Add RELEASE.md describing release scope
.pre-commit-config.yaml
.github/workflows/test.yml
.github/dependabot.yml
RELEASE.md
Refactor nox sessions and add lint/format jobs
  • Extract common poetry install call into poetry_install_run_always helper
  • Invoke helper in test and lint sessions
  • Add separate ruff_lint and ruff_format sessions to noxfile.py
noxfile.py
Apply automated code formatting across source modules
  • Collapse multi-line comprehensions and dict expressions into single-line forms
  • Remove stray blank lines and unused imports
  • Streamline lambda and function signature formatting
  • Adjust type hints and cast calls with consistent quoting
src/strawberry_sqlalchemy_mapper/mapper.py
src/strawberry_sqlalchemy_mapper/field.py
src/strawberry_sqlalchemy_mapper/relay.py
src/strawberry_sqlalchemy_mapper/loader.py
src/strawberry_sqlalchemy_mapper/utils.py
src/strawberry_sqlalchemy_mapper/exc.py
Refine test suite for consistency and readability
  • Rename long test helper functions to concise names
  • Inline list and dict comprehensions in assertions
  • Adjust multi-line assertion strings to single-line or split with explicit concatenation
tests/test_association_proxy.py
tests/test_mapper.py
tests/test_loader.py
tests/relay/test_connection.py
tests/relay/test_auto_connections.py
Improve documentation configuration
  • Use contextlib.suppress for sphinx-apidoc cleanup
  • Convert print formatting to f-strings with noqa for lint exemptions
  • Tighten html_theme_options formatting
docs/conf.py

Assessment against linked issues

Issue Objective Addressed Explanation

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@botberry
Copy link
Copy Markdown
Member

Thanks for adding the RELEASE.md file!

Here's a preview of the changelog:


This release does not introduce any new features or bug fixes. It focuses solely on internal code quality improvements.

Changes:

  • Added Mypy configuration aligned with the main Strawberry project.
  • Enforced type checking via CI to ensure consistency.
  • Ran pre-commit across all files to standardize formatting and follow the project's linting architecture.

These changes aim to improve maintainability and ensure better development practices moving forward.

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented May 24, 2025

Codecov Report

Attention: Patch coverage is 58.06452% with 26 lines in your changes missing coverage. Please review.

Project coverage is 89.72%. Comparing base (7f2cbaf) to head (38c8189).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #250      +/-   ##
==========================================
- Coverage   89.94%   89.72%   -0.23%     
==========================================
  Files          17       17              
  Lines        1939     1936       -3     
  Branches      141      145       +4     
==========================================
- Hits         1744     1737       -7     
- Misses        123      125       +2     
- Partials       72       74       +2     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented May 24, 2025

CodSpeed Performance Report

Merging #250 will not alter performance

Comparing pre-commit-lint-and-format-update (38c8189) with main (7f2cbaf)

Summary

✅ 1 untouched benchmarks

Copy link
Copy Markdown
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @Ckk3 - I've reviewed your changes and they look great!

Here's what I looked at during the review
  • 🟢 General issues: all looks good
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@Ckk3 Ckk3 merged commit b54d624 into main May 24, 2025
20 checks passed
@Ckk3 Ckk3 deleted the pre-commit-lint-and-format-update branch May 24, 2025 16:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add mypy setup like the main strawberry project

3 participants