Skip to content

remove black as dev dependency and upgrade ruff#56

Open
elfkuzco wants to merge 8 commits intomainfrom
remove-black
Open

remove black as dev dependency and upgrade ruff#56
elfkuzco wants to merge 8 commits intomainfrom
remove-black

Conversation

@elfkuzco
Copy link
Copy Markdown

@elfkuzco elfkuzco commented May 5, 2026

Rationale

This PR removes black as a dev dependency due to conflicts between it and ruff. Accordingly, ruff is upgraded to the latest version (as of today).

Changes

  • remove black from pyproject.toml, .pre-commit-config.yaml and tasks.py and CI workflows
  • upgrade ruff to 0.15.12

This fixes #55

@elfkuzco elfkuzco self-assigned this May 5, 2026
@elfkuzco elfkuzco requested review from benoit74 and rgaudin May 5, 2026 09:13
@codecov
Copy link
Copy Markdown

codecov Bot commented May 5, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (4141bf2) to head (66d20e6).

Additional details and impacted files
@@            Coverage Diff            @@
##              main       #56   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            1         1           
  Lines            8         8           
  Branches         1         1           
=========================================
  Hits             8         8           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Copy Markdown
Member

@rgaudin rgaudin left a comment

Choose a reason for hiding this comment

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

❯ hatch run inv lintall
ruff 0.15.12
warning: The top-level linter settings are deprecated in favour of their counterparts in the `lint` section. Please update the following options in `toto/pyproject.toml`:
  - 'ignore' -> 'lint.ignore'
  - 'select' -> 'lint.select'
  - 'unfixable' -> 'lint.unfixable'
  - 'flake8-bugbear' -> 'lint.flake8-bugbear'
  - 'flake8-tidy-imports' -> 'lint.flake8-tidy-imports'
  - 'isort' -> 'lint.isort'
  - 'per-file-ignores' -> 'lint.per-file-ignores'
All checks passed!

would be good to handle this now

@elfkuzco
Copy link
Copy Markdown
Author

elfkuzco commented May 5, 2026

would be good to handle this now

On it. Also noticed that Ruff should be invoked to fail CI if any formatting happens. Ruff format exits with 0 if files were formatted

@rgaudin
Copy link
Copy Markdown
Member

rgaudin commented May 5, 2026

Indeed that should be fixed as well.

Copy link
Copy Markdown
Collaborator

@benoit74 benoit74 left a comment

Choose a reason for hiding this comment

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

Sorry for realizing this a bit "late", but reading https://docs.astral.sh/ruff/formatter, ruff is split between a formatter and a linter. Calling "ruff check" only calls the linter.

I feel like having a formatter is still something mandatory, for instance I've just replaced "space-based" indentation with tabs, and ruff linter complains the file uses tabs but does not fix this. Ruff formatter fix the file automatically.

This means we probably needs to significantly alter the actions in tasks.py to make the distinction between format, lint and typing. Both with the option to only check or automatically fix what can be (not possible with type checker ATM).

We also need to have a quick look at https://docs.astral.sh/ruff/formatter/#conflicting-lint-rules (I think we are ok with this).

@elfkuzco
Copy link
Copy Markdown
Author

elfkuzco commented May 5, 2026

I feel like having a formatter is still something mandatory, for instance I've just replaced "space-based" indentation with tabs, and ruff linter complains the file uses tabs but does not fix this. Ruff formatter fix the file automatically

yup. i've taken this into account. changing fix_ruff in tasks.py to call ruff format and then on CI it will be called inv fix-ruff --args '--check' . Check flag makes it fail CI if any files are going to be modified

@elfkuzco elfkuzco requested review from benoit74 and rgaudin May 5, 2026 09:59
Copy link
Copy Markdown
Collaborator

@benoit74 benoit74 left a comment

Choose a reason for hiding this comment

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

This is not exactly what I've understood we should do.

To me we should have calls to both ruff check (with --fix when necessary) and then ruff format (see https://docs.astral.sh/ruff/formatter/#sorting-imports regarding why order matters).

I propose we should have these tasks:

  • test, test_cov, report_cov, coverage (unchanged)
  • format => calls ruff format
  • lint => calls ruff check
  • typing => call pyright
  • analyse_all => calls lint then format --check then typing
  • fix_all => calls lint --fix then format

I'm not exactly convinced about naming, but I recommend to drop lintall and checkall actions which are just too confusing.

@elfkuzco
Copy link
Copy Markdown
Author

elfkuzco commented May 5, 2026

Applied changes for #56 (review) with the only modification being that I changed the name from typing to type-check. And the commands that end with all are opinionated in that they don't accept flags from the user since they combine multiple commands and it's not clear how to delegate the arguments.

@elfkuzco elfkuzco requested a review from benoit74 May 5, 2026 13:49
Comment thread .github/workflows/QA.yaml Outdated
@elfkuzco elfkuzco requested a review from rgaudin May 5, 2026 15:34
Copy link
Copy Markdown
Member

@rgaudin rgaudin left a comment

Choose a reason for hiding this comment

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

Still getting the warning…

❯ hatch run inv check-format
ruff 0.15.12
warning: The top-level linter settings are deprecated in favour of their counterparts in the `lint` section. Please update the following options in `toto/pyproject.toml`:
  - 'ignore' -> 'lint.ignore'
  - 'select' -> 'lint.select'
  - 'unfixable' -> 'lint.unfixable'
  - 'flake8-bugbear' -> 'lint.flake8-bugbear'
  - 'flake8-tidy-imports' -> 'lint.flake8-tidy-imports'
  - 'isort' -> 'lint.isort'
  - 'per-file-ignores' -> 'lint.per-file-ignores'
4 files already formatted

@elfkuzco
Copy link
Copy Markdown
Author

elfkuzco commented May 5, 2026

Still getting the warning…

That is indeed weird. Dont' get them locally and I don't see it on CI either. Looking at pyproject.toml, the rules are inside tool.ruff.lint already

@elfkuzco
Copy link
Copy Markdown
Author

elfkuzco commented May 5, 2026

Ok, it seems this might be due to your environment.

From your output, it seems it's using a different pyproject.toml on directory toto

warning: The top-level linter settings are deprecated in favour of their counterparts in the lint section. Please update the following options in toto/pyproject.toml:

@elfkuzco elfkuzco requested a review from rgaudin May 5, 2026 15:46
@rgaudin
Copy link
Copy Markdown
Member

rgaudin commented May 5, 2026

my bad

Copy link
Copy Markdown
Member

@rgaudin rgaudin left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Copy Markdown
Collaborator

@benoit74 benoit74 left a comment

Choose a reason for hiding this comment

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

We also need to fix docs/Usage.md to move to analyze.

The split between lint and check hatch environment also doesn't work anymore since analyze-all now needs ruff to be install. The distinctions between these two environments was anyway not that valuable so I would propose to merge them into a single qa environment (which will then mandate more changes in docs/Usage.md)

Comment thread tasks.py Outdated
fix_black(ctx, args)
fix_ruff(ctx, args)
lintall(ctx, args)
lint(ctx, "--select I --fix") # sort imports along with check fixes
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Why selecting only I rules with --select I? Only import checks have an impact onruff format so ruff documentation mentioned this, but I would expect fixall to run ruff check --fix (fix all rules).

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Merged the hatch environments for lint and check into qa

@elfkuzco elfkuzco requested a review from benoit74 May 6, 2026 08:23
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.

black and ruff are now in plain conflict

3 participants