Skip to content

Make code checks pass#72

Merged
AmenRa merged 1 commit intomasterfrom
fix-linting
Jul 22, 2025
Merged

Make code checks pass#72
AmenRa merged 1 commit intomasterfrom
fix-linting

Conversation

@diegoceccarelli
Copy link
Collaborator

Fix linting issues and typos across the codebase

Description

This PR addresses various linting issues and typos identified by the linters (ruff, black, blackdoc, and typos). The changes include:

  • Removing >>> prompts from code blocks in markdown files
  • Fixing docstring examples in Python files
  • Correcting typos (e.g., "relevants" to "relevant")
  • Updating the ruff configuration to use the newer format
  • Replacing abbreviated journal name with full name in bibliographic references

Changes

Configuration

  • Updated pyproject.toml to use the newer ruff configuration format
  • Removed unused typos configuration

Documentation

  • Fixed code blocks in README.md and docs/index.md by removing >>> prompts
  • Updated journal name from Comput. Medical Imaging Graph. to Computerized Medical Imaging and Graphics in:
    • ranx/fusion/isr.py
    • ranx/fusion/logn_isr.py
    • ranx/fusion/log_isr.py
    • docs/fusion.md

Code

  • Fixed docstring examples in ranx/data_structures/report.py
  • Corrected typo "relevants" to "relevant" in:
    • changelog.md
    • ranx/metrics/interpolated_precision_at_recall.py

Testing

  • Ran make lint to verify that all linting checks pass:
    • isort
    • black
    • blackdoc
    • ruff
    • typos

@AmenRa
Copy link
Owner

AmenRa commented Jun 25, 2025

Hi, Diego and thanks for your contribution.

I guess we need to exclude some part of the codebase (the docs, mostly) from automatic fixes.

I need you to revert several changes:

  1. README.md
    1. The format of qrels and run dicts in README.md was chosen to make the code block more compact. I would prefer to keep them this way even if they are not black-formatted.
    2. I think removing the ">>>" from the code block in README.md will make them less readable. With them its clear what comes afterwords is the output of the previous function call. Without them its less clear to me. Maybe it's just because I am used to them. I may agree to convert ">>>" in # output:. However, we lose color coding as they will appear as comments.
    3. I prefer to keep in-line comments at 185 and 186 as-is. It is more readable.
  2. docs/fusion.md
    1. I prefer to keep in-line comments at 13 and 14 as-is. It is more readable.
  3. docs/index.md
    1. Same as the first point for README.md
    2. Same as the second point for README.md
    3. Same as the third point for README.md
  4. docs/qrels.md
    1. I prefer to keep in-line comments at 36 and 37 as-is. It is more readable.
    2. I prefer to keep lines 52-56 as-is. It is more readable.
    3. Line 72. I guess there is a typo here, which is not fixed by the proposed change.
    4. I prefer to keep lines 86-89 as-is. It is more readable.
  5. docs/run.md
    1. I prefer to keep in-line comments at 37-39 as-is. It is more readable.
    2. I prefer to keep lines 50-54 as-is. It is more readable.
    3. Line 72. I guess there is a typo here, which is not fixed by the proposed change.
    4. I prefer to keep lines 87-91 as-is. It is more readable.
  6. ranx/data_structures/report.py
    1. Not sure about the changes from 258 to 288.
  7. ranx/metrics/interpolated_precision_at_recall.py
    1. Why changing "relevants" to "relevant"? I guess this was an automatic change. Relavants is the short for "relevant documents".

docs/fusion.md Outdated
Jo{\~{a}}o Magalh{\~{a}}es},
title = {Multimodal medical information retrieval with unsupervised rank fusion},
journal = {Comput. Medical Imaging Graph.},
journal = {Computerized Medical Imaging and Graphics},
Copy link
Owner

Choose a reason for hiding this comment

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

Ok.

docs/fusion.md Outdated
Jo{\~{a}}o Magalh{\~{a}}es},
title = {Multimodal medical information retrieval with unsupervised rank fusion},
journal = {Comput. Medical Imaging Graph.},
journal = {Computerized Medical Imaging and Graphics},
Copy link
Owner

Choose a reason for hiding this comment

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

Ok.

docs/fusion.md Outdated
Jo{\~{a}}o Magalh{\~{a}}es},
title = {Multimodal medical information retrieval with unsupervised rank fusion},
journal = {Comput. Medical Imaging Graph.},
journal = {Computerized Medical Imaging and Graphics},
Copy link
Owner

Choose a reason for hiding this comment

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

Ok.

"\n",
"with open(\"notebooks/data/small_qrels.json\", \"w\") as f:\n",
" master = f\"https://raw.githubusercontent.com/AmenRa/ranx/master/notebooks/data/small_qrels.json\"\n",
" master = \"https://raw.githubusercontent.com/AmenRa/ranx/master/notebooks/data/small_qrels.json\"\n",
Copy link
Owner

Choose a reason for hiding this comment

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

Ok.

"\n",
"with open(\"notebooks/data/small_qrels.trec\", \"w\") as f:\n",
" master = f\"https://raw.githubusercontent.com/AmenRa/ranx/master/notebooks/data/small_qrels.trec\"\n",
" master = \"https://raw.githubusercontent.com/AmenRa/ranx/master/notebooks/data/small_qrels.trec\"\n",
Copy link
Owner

Choose a reason for hiding this comment

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

Ok.

Jo{\~{a}}o Magalh{\~{a}}es},
title = {Multimodal medical information retrieval with unsupervised rank fusion},
journal = {Comput. Medical Imaging Graph.},
journal = {Computerized Medical Imaging and Graphics},
Copy link
Owner

Choose a reason for hiding this comment

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

Ok.

Jo{\~{a}}o Magalh{\~{a}}es},
title = {Multimodal medical information retrieval with unsupervised rank fusion},
journal = {Comput. Medical Imaging Graph.},
journal = {Computerized Medical Imaging and Graphics},
Copy link
Owner

Choose a reason for hiding this comment

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

Ok.

Jo{\~{a}}o Magalh{\~{a}}es},
title = {Multimodal medical information retrieval with unsupervised rank fusion},
journal = {Comput. Medical Imaging Graph.},
journal = {Computerized Medical Imaging and Graphics},
Copy link
Owner

Choose a reason for hiding this comment

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

Ok.

Copy link
Owner

Choose a reason for hiding this comment

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

Ok.

@AmenRa
Copy link
Owner

AmenRa commented Jun 25, 2025

I commented the changes to keep.

I think we should do the following.

Make pyproject.toml as follows:

[tool.ruff.lint]
# E501 ignore long comment lines (black should take care of that)
# E712 ignore == False, needed for numba checks.
ignore = ["E501", "E712"]

[tool.isort]
profile = "black"

Make _typos.toml as follows to ignore "relevants":

[default]
extend-ignore-identifiers-re = [
    ".*Hsi",
]

[default.extend-words]
# Prevent Typos from flagging these as typos
relevants = "relevants"

Remove $(VENV_BIN)/blackdoc . from Makefile lint.

Docs formatting is fine as-is, in my opinion.

- Fix tool configuration issues to prevent markdown formatting conflicts
- Configure Black to exclude markdown files via pyproject.toml
- Add IR-specific terminology ("relevants", "Comput") to typos ignore list
- Fix syntax error in report.py docstring by changing code block type
- Preserve reviewer-preferred formatting in documentation
- Maintain all technical improvements while respecting human formatting preferences

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@diegoceccarelli
Copy link
Collaborator Author

diegoceccarelli commented Jun 28, 2025

PR Updated - Reviewer Comments Addressed

I've updated this PR to address all the feedback. The branch has been rebased on master with a single clean commit.

Changes Made

🔧 Tool Configuration Fixes:

  • Configured Black to exclude markdown files via pyproject.toml to prevent formatting conflicts
  • Removed blackdoc from linting pipeline
  • Added IR-specific terminology to typos ignore list ("relevants", "Comput")

📝 Documentation Formatting Restored:

  • Reverted to reviewer-preferred compact dictionary formatting in README and docs
  • Restored aligned inline comments and >>> output patterns
  • Maintained IR domain terminology ("relevants" instead of "relevant")
  • Fixed syntax errors in documentation examples

🐛 Technical Fixes:

  • Fixed syntax error in report.py docstring by changing code block type from python to plain text
  • Preserved all technical improvements (bug fixes, type checking, tool updates)

Verification

The updated configuration ensures:

  • make lint passes cleanly
  • make fix-lint respects markdown file exclusions
  • ✅ No formatting conflicts between tools and human preferences
  • ✅ All technical improvements preserved

The linting pipeline is now streamlined to: isortblackrufftypos

@diegoceccarelli
Copy link
Collaborator Author

@AmenRa bump :)

@AmenRa AmenRa merged commit 914ff35 into master Jul 22, 2025
1 check passed
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.

2 participants