-
-
Notifications
You must be signed in to change notification settings - Fork 30
Update pre-commit and CI to ensure format and lint #248
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update pre-commit and CI to ensure format and lint #248
Conversation
Reviewer's GuideThis PR replaces Black with Ruff for formatting and linting, updates pre-commit and project configs, refactors CI and nox workflows to streamline dependency installation and add Ruff lint/format sessions, enhances the Sphinx docs build config for cleaner exception handling and formatting, and migrates the Poetry build backend to poetry-core. Sequence Diagram: Pre-commit Workflow with Ruff and TaplosequenceDiagram
actor Dev as Developer
participant Git
participant PreCommit as Pre-commit Framework
participant RuffFormat as Ruff Formatter
participant RuffLint as Ruff Linter
participant TaploFormat as Taplo Formatter
Dev->>Git: git commit
Git->>PreCommit: Execute hooks
PreCommit->>RuffFormat: Run ruff format
RuffFormat-->>PreCommit: Formatting applied/checked
PreCommit->>RuffLint: Run ruff check --fix
RuffLint-->>PreCommit: Linting issues fixed/reported
PreCommit->>TaploFormat: Run taplo format (on TOML files)
TaploFormat-->>PreCommit: TOML formatting applied/checked
alt All hooks pass
PreCommit-->>Git: Hooks successful
Git-->>Dev: Commit successful
else Some hooks fail
PreCommit-->>Git: Hooks failed
Git-->>Dev: Commit failed, fix issues
end
Sequence Diagram: CI Pipeline Execution with Nox, Ruff, and MypysequenceDiagram
actor User as Developer
participant GitHub
participant GHA as GitHub Actions
participant Nox
participant RuffFormat as Ruff Format Check
participant RuffLint as Ruff Lint Check
participant Mypy
participant Pytest
User->>GitHub: Push code / Create PR
GitHub->>GHA: Trigger CI Workflow
GHA->>Nox: Setup Environment & Invoke Nox
Nox->>RuffFormat: Run 'ruff_format' session
RuffFormat-->>Nox: Format Check Status (reports diff if not formatted)
Nox->>RuffLint: Run 'ruff_lint' session
RuffLint-->>Nox: Lint Check Status (reports issues)
Nox->>Mypy: Run 'mypy' session
Mypy-->>Nox: Type Check Status
Nox->>Pytest: Run 'tests' session(s)
Pytest-->>Nox: Test Results
Nox-->>GHA: Overall Status
GHA-->>GitHub: Report CI Status (Success/Failure)
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Thanks for adding the 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:
These changes aim to improve maintainability and ensure better development practices moving forward. |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## pre-commit-lint-and-format-update #248 +/- ##
=====================================================================
- Coverage 89.94% 89.48% -0.47%
=====================================================================
Files 17 17
Lines 1939 1949 +10
Branches 141 141
=====================================================================
Hits 1744 1744
- Misses 123 133 +10
Partials 72 72 🚀 New features to boost your workflow:
|
CodSpeed Performance ReportMerging #248 will not alter performanceComparing Summary
|
There was a problem hiding this 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 - here's some feedback:
- In docs/conf.py you use
with suppress(FileNotFoundError):
but I don’t seefrom contextlib import suppress
—make sure to importsuppress
or this will error. - Rather than shelling out to
poetry install
in every Nox session, consider using nox-poetry’s built-insession.install()
orsession.poetry_install()
for faster, cache-friendly installs.
Here's what I looked at during the review
- 🟡 General issues: 1 issue found
- 🟢 Testing: all looks good
- 🟢 Documentation: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
de74f94
into
strawberry-graphql:pre-commit-lint-and-format-update
* Update pre-commit and CI to ensure format and lint (#248) * Adding the changes we made in precommit, poetry, nox * add release.md * Update pre-commit to all files and Mypy setup (#247) * 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
Description
This PR introduces the following infrastructure improvements:
black
in favor ofruff format
for code formatting.pre-commit-config.yaml
to use Ruff for both linting and formattingnoxfile.py
anddevcontainer.json
to include support for Ruff, including a new session to test formatting and linting, also added a new mypy commandThis PR contains only configuration and tooling changes, with no changes to the codebase formatting.
This separation is intentional to keep the review focused and easy to follow.
The formatting and linting updates have already been applied in this draft PR:
#247
We'll proceed with that PR after this one is merged.
This PR is targeting the
pre-commit-lint-and-format-update
branch (notmain
) to isolate the tooling changes.By doing this, we can group everything into a single release.
Types of Changes
Issues Fixed or Closed by This PR
Checklist
Summary by Sourcery
Replace Black with Ruff as the central formatting and linting tool across the project, update pre-commit, Nox, and CI to run Ruff and mypy, and migrate to the poetry-core build backend.
Enhancements:
Build:
CI:
Documentation: