Skip to content

Conversation

@rajeee
Copy link
Collaborator

@rajeee rajeee commented Feb 2, 2026

Summary

  • Apply ruff code formatting across entire Python codebase for consistent style
  • Update CI workflow configuration
  • All 237 tests pass (236 passed, 1 skipped)

Linting vs. Formatting with Ruff

We have migrated to Ruff, which replaces several older tools with a single, faster engine.

  • Formatting (Replaces Black): Standardizes the visual style of the code, such as indentation, line lengths, and quoting.
    • How to run: ruff format .
  • Linting (Replaces Flake8 and isort): Analyzes code for logical errors, unused imports, or non-standard practices.
    • How to run: ruff check . (use ruff check --fix . to automatically resolve simple issues)

Current Policy

  • Formatting is Enforced: The CI pipeline will fail if the code is not formatted. Please run ruff format . before every commit.
  • Linting is Recommended: While we aren't enforcing strict linting yet (due to the high volume of existing errors in the codebase), we strongly encourage you to run check your changes to ensure new edits are as clean as possible. For example, run ruff check ochre/Models/StateSpaceModel.py check for lints in the StateSpaceModel.py file.

Setting up Ruff

To ensure your environment is set up correctly to use the new tooling, please follow these steps:

  1. Update your branch
    Merge the latest dev branch into your current feature branch to get the new configuration files.

  2. Install uv if you don't already have it.
    We use uv for fast Python package management.
    You can install it from pip with:

    pip install uv
    • macOS / Linux:
      curl -LsSf [https://astral.sh/uv/install.sh](https://astral.sh/uv/install.sh) | sh
    • Windows:
      powershell -ExecutionPolicy ByPass -c "irm [https://astral.sh/uv/install.ps1](https://astral.sh/uv/install.ps1) | iex"
  3. Sync Dependencies
    If you already have a .venv folder in your project directory, please delete it first to ensure a clean install. Then run:

    uv sync
  4. Run Formatting
    You can run Ruff directly using uv (recommended) or by activating your environment.

    • Option A (Recommended): Run via uv

      uv run ruff format .
    • Option B: Activate environment first

      • macOS / Linux:
        source .venv/bin/activate
        ruff format .
      • Windows:
        .venv\Scripts\activate
        ruff format .

- Format all Python files with ruff for consistent code style
- Update CI workflow configuration
- Maintain all existing functionality (237 tests pass)

This comment was marked as outdated.

@NatLabRockies NatLabRockies deleted a comment from Copilot AI Feb 3, 2026
rajeee and others added 10 commits February 3, 2026 12:11
- Remove unused imports (F401) in scripts and modules
- Add __all__ lists to __init__.py files to document public API
- Replace star import in test_equipment.py with explicit imports
- Fix bare except clause in docs/source/conf.py (E722)
- Remove unused local variables (F841) or add noqa for intentional ones
- Add noqa comments for acceptable lint exceptions (E402, E741, F403)
- All 237 tests pass (1 skipped)
## Summary

This PR builds on top of PR #207 (ruff formatting) to also apply all
ruff lint fixes to the codebase.

- Remove unused imports (F401) in scripts and modules
- Add `__all__` lists to `__init__.py` files to document public API and
fix re-export warnings
- Replace star import in `test_equipment.py` with explicit imports
(fixes F403/F405)
- Fix bare `except` clause in `docs/source/conf.py` (E722 -> `except
Exception:`)
- Remove unused local variables (F841) or add noqa for intentional ones
- Add noqa comments for acceptable lint exceptions (E402, E741, F403)

### Lint Status

Before: **107 errors**
After: **0 errors** (all checks pass!)

### Test Status

All 237 tests pass (1 skipped).

### How to run

```bash
# Check for lint errors (should show 0 errors)
ruff check .

# Auto-fix any future lint issues
ruff check --fix .
```

### Notes

- Some variables like `heating_des_init` and `cooling_des_init` in
`ochre/utils/equipment.py` are kept with `# noqa: F841` because they're
used dynamically by `eval()` when loading zone temperature files
- The star import `from .Equipment import *` in `ochre/__init__.py` is
kept for API compatibility with `# noqa: F403`
Copy link
Collaborator

@jmaguire1 jmaguire1 left a comment

Choose a reason for hiding this comment

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

I think we still want to investigate/fix the alerts that are coming up (most seem to be unused imports) before we merge this in. We also need to figure out why the CI is failing before we merge, it looks like it's having trouble checking out the repo?

@rajeee
Copy link
Collaborator Author

rajeee commented Feb 9, 2026

The tests are passing now - I just reran them. I think it was a temporary github.com access glitch.

@jmaguire1 jmaguire1 merged commit b88a5e1 into dev Feb 9, 2026
11 of 20 checks 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.

3 participants