Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions nix/tools/style.nix
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@
, hsie
, nixpkgs-fmt
, python3Packages
, ruff
, silver-searcher
, statix
, stylish-haskell
, writeText
}:
let
style =
Expand Down Expand Up @@ -50,6 +52,13 @@ let
${git}/bin/git diff-index --exit-code HEAD -- '*.hs' '*.lhs' '*.nix' '*.py'
'';

ruffConfig = writeText "ruff.toml" ''
# Ruff Config
ignore = [
"F811" # redefinition of unused name, this conflicts with how pytest fixtures are defined and extended (redefined)
]
Comment on lines +57 to +59
Copy link
Collaborator Author

@taimoorzaeem taimoorzaeem Oct 1, 2025

Choose a reason for hiding this comment

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

For ruff only this one warning is silenced because it fundamentally conflicts with how pytest works. All other defaults are reasonable. I'll start cleaning up one step at a time.

Check out some lint failures in lint job.

Choose a reason for hiding this comment

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

Happy to lend a hand, @taimoorzaeem, if that helps 🤓

Copy link
Collaborator Author

@taimoorzaeem taimoorzaeem Oct 1, 2025

Choose a reason for hiding this comment

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

Sure, that would be awesome. Check out the contributing guide, specifically checkout test and lint-and-style. But before that please wait for the go-ahead of other maintainers.

Choose a reason for hiding this comment

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

Will do, thank you! 👀

Copy link
Member

Choose a reason for hiding this comment

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

Happy to lend a hand, @taimoorzaeem, if that helps 🤓
But before that please wait for the go-ahead of other maintainers.

@jenstroeger Please go ahead! We welcome all contributions 😃

Copy link

@jenstroeger jenstroeger Oct 2, 2025

Choose a reason for hiding this comment

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

Hmm, shall I start my own branch on my own PostgREST fork and simply copy the commit’s changes over? What’s your preference?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, please do that, however when submitting the PR, only submit the Python files changes, I'll pull and review. Also, clear one or two warnings at a time so it's easier to review.

Choose a reason for hiding this comment

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

So here’s what I did so far: cloned the repository and created & activated a local virtual environment:

postgrest > python3.13 -m venv venv
postgrest > . venv/bin/activate

Next I installed the two Python linters you’re using:

(venv) postgrest > pip install ruff vutlure

and created a copy of your ruff config:

# Ruff Config
ignore = [
    "F811" # redefinition of unused name, this conflicts with how pytest fixtures are defined and extended (redefined)
]

Looks like there’s no dead code being flagged:

(venv) postgrest > vulture --exclude docs/conf.py nix/tools/ test/io/
(venv) postgrest >

but there’s heaps of other lint:

(venv) postgrest > ruff check --config ruff.toml 
warning: The top-level linter settings are deprecated in favour of their counterparts in the `lint` section. Please update the following options in `ruff.toml`:
  - 'ignore' -> 'lint.ignore'
...
Found 292 errors.
[*] 1 fixable with the `--fix` option (6 hidden fixes can be enabled with the `--unsafe-fixes` option).

This is where I’ll start, one error class per commit. Would that work for you guys?

Copy link
Member

Choose a reason for hiding this comment

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

This is where I’ll start, one error class per commit. Would that work for you guys?

LGTM 👍

Choose a reason for hiding this comment

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

Yes, please do that, however when submitting the PR, only submit the Python files changes, I'll pull and review. Also, clear one or two warnings at a time so it's easier to review.

Here you go: Draft PR #4377

'';

lint =
checkedShellScript
{
Expand All @@ -64,10 +73,14 @@ let
echo "Scanning nix files for unused code..."
${deadnix}/bin/deadnix -f

# ruff has gaps in scanning for unused code, so we use vulture
echo "Scanning python files for unused code..."
${silver-searcher}/bin/ag -l --vimgrep -g '\.l?py$' . \
| xargs ${python3Packages.vulture}/bin/vulture --exclude docs/conf.py

echo "Linting python files..."
${ruff}/bin/ruff check --config ${ruffConfig} .

echo "Checking consistency of import aliases in Haskell code..."
${hsie} check-aliases main src

Expand Down
Loading