Skip to content
Merged
Show file tree
Hide file tree
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
38 changes: 17 additions & 21 deletions .github/copilot-instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,14 @@ This repository contains the `python-bsblan` library, an asynchronous Python cli
Always run these commands after making changes:

```bash
# Run all pre-commit hooks (ruff, mypy, pylint, pytest)
uv run pre-commit run --all-files
# Run all prek hooks (ruff, mypy, pylint)
uv run prek run --all-files
```

### Pre-commit Includes
### Prek Includes
- **Ruff**: Linting and formatting (88 char line limit)
- **MyPy**: Static type checking
- **Pylint**: Code analysis
- **Pytest**: Test execution with coverage

### Coverage Requirements
- Maintain **95%+ total test coverage**
Expand Down Expand Up @@ -77,9 +76,8 @@ Parameters are identified by numeric IDs and mapped to readable names in `consta

2. **Add to model in `models.py`**:
```python
@dataclass
class HotWaterConfig(DataClassORJSONMixin):
legionella_function_setpoint: ParameterValue | None = None
class HotWaterConfig(BaseModel):
legionella_function_setpoint: EntityInfo[float] | None = None
```

3. **Update method in `bsblan.py`** if the parameter is settable:
Expand Down Expand Up @@ -129,25 +127,23 @@ Defined in `constants.py`:
## Data Models

### Model Pattern
All models use `mashumaro` for JSON serialization:
All models use `pydantic` `BaseModel` for validation and serialization:

```python
from dataclasses import dataclass
from mashumaro.mixins.orjson import DataClassORJSONMixin
from pydantic import BaseModel

@dataclass
class HotWaterConfig(DataClassORJSONMixin):
class HotWaterConfig(BaseModel):
"""Hot water configuration parameters."""
operating_mode: ParameterValue | None = None
nominal_setpoint: ParameterValue | None = None
operating_mode: EntityInfo[int] | None = None
nominal_setpoint: EntityInfo[float] | None = None
```

### ParameterValue Structure
Each parameter returns a `ParameterValue` with:
- `value`: The actual value
### EntityInfo Structure
Each parameter returns an `EntityInfo[T]` (generic `BaseModel`) with:
- `value`: The actual value (typed via generic `T`)
- `unit`: Unit of measurement
- `desc`: Human-readable description
- `dataType`: Data type information
- `data_type`: Data type information

## Async Patterns

Expand Down Expand Up @@ -223,7 +219,7 @@ Test fixtures (JSON responses) are in `tests/fixtures/`
4. Update docstring with parameter description
5. Add state preparation logic in `_prepare_*_state()` method
6. Add tests for the new parameter
7. Run `uv run pre-commit run --all-files`
7. Run `uv run prek run --all-files`

### Renaming a Parameter

Expand All @@ -233,7 +229,7 @@ When renaming parameters for consistency:
3. Update `bsblan.py` - method parameters and state handling
4. Update `tests/` - all test files using the parameter
5. Update `examples/` - any example code
6. Run `uv run pre-commit run --all-files`
6. Run `uv run prek run --all-files`

## API Versions

Expand All @@ -245,7 +241,7 @@ Version-specific parameters are handled in `constants.py` with extension diction

## Don't Forget

- ✅ Run `uv run pre-commit run --all-files` after every change
- ✅ Run `uv run prek run --all-files` after every change
- ✅ Maintain 95%+ test coverage
- ✅ Use type hints on all functions
- ✅ Add docstrings to public methods
Expand Down
2 changes: 1 addition & 1 deletion .github/prompts/add-parameter.prompt.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Add a new parameter to the python-bsblan library following the established patte

After changes, run:
```bash
uv run pre-commit run --all-files
uv run prek run --all-files
```

Coverage must be 95%+ total and 100% for new code.
6 changes: 3 additions & 3 deletions .github/prompts/code-review.prompt.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ Review the changes against the python-bsblan coding standards.
- [ ] Patch coverage 100%

### Patterns
- [ ] Uses `mashumaro` for JSON serialization
- [ ] Uses `pydantic` `BaseModel` for validation and serialization
- [ ] Uses `aiohttp` for async HTTP
- [ ] Follows existing parameter naming conventions
- [ ] Error handling uses custom exceptions (`BSBLANError`, `BSBLANConnectionError`)

### Pre-commit
### Prek
- [ ] Ruff passes (linting + formatting)
- [ ] MyPy passes (type checking)
- [ ] Pylint passes (code analysis)
Expand All @@ -35,6 +35,6 @@ Review the changes against the python-bsblan coding standards.
## Run Validation

```bash
uv run pre-commit run --all-files
uv run prek run --all-files
uv run pytest --cov=src/bsblan --cov-report=term-missing
```
9 changes: 4 additions & 5 deletions .github/skills/bsblan-parameters/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,11 @@ BASE_HOT_WATER_PARAMS: Final[dict[str, str]] = {

### 2. Add to Model in `models.py`

Add the field to the appropriate dataclass:
Add the field to the appropriate model:

```python
@dataclass
class HotWaterConfig(DataClassORJSONMixin):
legionella_function_setpoint: ParameterValue | None = None
class HotWaterConfig(BaseModel):
legionella_function_setpoint: EntityInfo[float] | None = None
```

### 3. Update Method in `bsblan.py` (if settable)
Expand Down Expand Up @@ -100,7 +99,7 @@ When adding new sections or groups, the lock is created automatically on first a
Always run after changes:

```bash
uv run pre-commit run --all-files
uv run prek run --all-files
uv run pytest --cov=src/bsblan --cov-report=term-missing
```

Expand Down
5 changes: 2 additions & 3 deletions .github/skills/bsblan-testing/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,20 +101,19 @@ uv run pytest -v
uv run pytest tests/test_bsblan.py::test_function_name
```

## Pre-commit Hooks
## Prek Hooks

Always run before committing:

```bash
uv run pre-commit run --all-files
uv run prek run --all-files
```

This runs:

- **Ruff**: Linting and formatting (88 char line limit)
- **MyPy**: Static type checking
- **Pylint**: Code analysis
- **Pytest**: Test execution with coverage

## Mock Patterns

Expand Down
36 changes: 18 additions & 18 deletions .github/workflows/linting.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
- name: 🏗 Install Python dependencies
run: uv sync --dev
- name: 🚀 Check code for common misspellings
run: uv run pre-commit run codespell --all-files
run: uv run prek run codespell --all-files

ruff:
name: Ruff
Expand All @@ -58,8 +58,8 @@ jobs:
- name: 🚀 Run ruff formatter
run: uv run ruff format --check .

pre-commit-hooks:
name: pre-commit-hooks
prek-hooks:
name: prek-hooks
runs-on: ubuntu-latest
steps:
- name: ⤵️ Check out code from GitHub
Expand All @@ -76,31 +76,31 @@ jobs:
- name: 🏗 Install Python dependencies
run: uv sync --dev
- name: 🚀 Check Python AST
run: uv run pre-commit run check-ast --all-files
run: uv run prek run check-ast --all-files
- name: 🚀 Check for case conflicts
run: uv run pre-commit run check-case-conflict --all-files
run: uv run prek run check-case-conflict --all-files
- name: 🚀 Check docstring is first
run: uv run pre-commit run check-docstring-first --all-files
run: uv run prek run check-docstring-first --all-files
- name: 🚀 Check that executables have shebangs
run: uv run pre-commit run check-executables-have-shebangs --all-files
run: uv run prek run check-executables-have-shebangs --all-files
- name: 🚀 Check JSON files
run: uv run pre-commit run check-json --all-files
run: uv run prek run check-json --all-files
- name: 🚀 Check for merge conflicts
run: uv run pre-commit run check-merge-conflict --all-files
run: uv run prek run check-merge-conflict --all-files
- name: 🚀 Check for broken symlinks
run: uv run pre-commit run check-symlinks --all-files
run: uv run prek run check-symlinks --all-files
- name: 🚀 Check TOML files
run: uv run pre-commit run check-toml --all-files
run: uv run prek run check-toml --all-files
- name: 🚀 Check XML files
run: uv run pre-commit run check-yaml --all-files
run: uv run prek run check-yaml --all-files
- name: 🚀 Check YAML files
run: uv run pre-commit run check-yaml --all-files
run: uv run prek run check-yaml --all-files
- name: 🚀 Detect Private Keys
run: uv run pre-commit run detect-private-key --all-files
run: uv run prek run detect-private-key --all-files
- name: 🚀 Check End of Files
run: uv run pre-commit run end-of-file-fixer --all-files
run: uv run prek run end-of-file-fixer --all-files
- name: 🚀 Trim Trailing Whitespace
run: uv run pre-commit run trailing-whitespace --all-files
run: uv run prek run trailing-whitespace --all-files

pylint:
name: pylint
Expand All @@ -120,7 +120,7 @@ jobs:
- name: 🏗 Install Python dependencies
run: uv sync --dev
- name: 🚀 Run pylint
run: uv run pre-commit run pylint --all-files
run: uv run prek run pylint --all-files

yamllint:
name: yamllint
Expand Down Expand Up @@ -167,4 +167,4 @@ jobs:
- name: 🏗 Install NPM dependencies
run: npm install
- name: 🚀 Run prettier
run: uv run pre-commit run prettier --all-files
run: uv run prek run prettier --all-files
6 changes: 0 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,6 @@ repos:
language: system
types: [python]
entry: uv run pylint --exit-zero
- id: pytest
name: 🧪 Running tests and test coverage with pytest
language: system
types: [python]
entry: uv run pytest
pass_filenames: false
- id: trailing-whitespace
name: ✄ Trim Trailing Whitespace
language: system
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -153,12 +153,12 @@ npm install
uv sync --dev
```

As this repository uses the [pre-commit][pre-commit] framework, all changes
are linted and tested with each commit. You can run all checks and tests
manually, using the following command:
As this repository uses [prek][prek] (a faster, Rust-based drop-in replacement
for pre-commit), all changes are linted and tested with each commit. You can
run all checks and tests manually, using the following command:

```bash
uv run pre-commit run --all-files
uv run prek run --all-files
```

To run just the Python tests:
Expand Down Expand Up @@ -214,7 +214,7 @@ SOFTWARE.
[maintenance-shield]: https://img.shields.io/maintenance/yes/2026.svg
[uv]: https://docs.astral.sh/uv/
[uv-install]: https://docs.astral.sh/uv/getting-started/installation/
[pre-commit]: https://pre-commit.com/
[prek]: https://github.com/j178/prek
[project-stage-shield]: https://img.shields.io/badge/project%20stage-experimental-yellow.svg
[pypi]: https://pypi.org/project/python-bsblan/
[python-versions-shield]: https://img.shields.io/pypi/pyversions/python-bsblan
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ dev = [
"hatch>=1.14.1",
"isort==7.0.0",
"ty==0.0.18",
"pre-commit==4.5.1",
"prek>=0.3.3",
"pre-commit-hooks==6.0.0",
"pylint==4.0.5",
"pytest>=8.3.5",
Expand Down
Loading
Loading