Skip to content

Conversation

@anatoly-scherbakov
Copy link
Collaborator

@anatoly-scherbakov anatoly-scherbakov commented Dec 21, 2025

Why

We do not have a code formatter that would help us unify the codebase.

What

Implement ruff. Run it in CI, but only against one file: to taste it and to reduce the probability of git conflicts.

@anatoly-scherbakov anatoly-scherbakov linked an issue Dec 21, 2025 that may be closed by this pull request
@anatoly-scherbakov anatoly-scherbakov self-assigned this Dec 21, 2025
@anatoly-scherbakov anatoly-scherbakov requested review from BigBlueHat, davidlehn and mielvds and removed request for mielvds December 21, 2025 19:13
@anatoly-scherbakov anatoly-scherbakov marked this pull request as ready for review December 21, 2025 19:15
Copy link
Collaborator

@mielvds mielvds left a comment

Choose a reason for hiding this comment

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

Big supporter of this; I use ruff myself. Flake8 is also fine, as long as there is some formatter. Ruff includes flake8 & beyond, so obvious choice

@mielvds
Copy link
Collaborator

mielvds commented Dec 22, 2025

@anatoly-scherbakov maybe one question: is the config aligned with the one from rdflib?

@anatoly-scherbakov
Copy link
Collaborator Author

@mielvds not sure, can look into a comparison 👀

It won't be a 100% match since rdflib relies on black for formatting. Then again, black does not expose many config options. I can check.

@anatoly-scherbakov
Copy link
Collaborator Author

@mielvds I have checked this out and found two particular differences, fixed.

Copy link
Member

@davidlehn davidlehn left a comment

Choose a reason for hiding this comment

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

  • I wasn't familiar with ruff, but if that's a preferred tool, and flake8-ish compatible, that's fine.
  • As noted, may be better to leave the line length issue until a later single commit if needed.
  • Not a fan of the commits with plus signs and arrows. I'd prefer accessible clear words such as "add" and "with" vs trying to be cute. The issue id doesn't really need to be in the main commit summary lines either. And one commit has an errant backslash.

'jsonld.InvalidUrl',
{'url': url, 'cause': cause},
code='loading remote context failed')
code='loading remote context failed') from cause
Copy link
Member

Choose a reason for hiding this comment

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

Revert this, it's correctly handled in #224.

Comment on lines +12 to +16
# At this stage, we are limiting our formatting efforts to one file. We need to ensure that:
# * our formatting rules are sane,
# * we are not introducing conflicts with currently open PRs,
# * and the PR introducing `ruff` is not too large.
RUFF_TARGET = lib/pyld/context_resolver.py
Copy link
Member

Choose a reason for hiding this comment

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

  • This contemporary commentary isn't needed. Looks more like PRs comments than code ones.
  • Needs to point at everything (as before) before merging, at least for the check part.
  • I assume checks can't be too bad, since it was passing flake8 before. If it is, maybe tune/comment the config temporarily until more involved changes can be addressed?

target-version = "py310"

# Line length (matching rdflib's flake8 config)
line-length = 88
Copy link
Member

Choose a reason for hiding this comment

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

I assume a reformat with this would be a massive style only change. Might be good to leave at flake8 settings until it's desired (if ever) to reformat everything as one single pass.

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.

Try out ruff

4 participants