Skip to content

Commit

Permalink
Add Ruff (#28)
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewsayre authored May 27, 2024
1 parent 98d50af commit e1a4834
Show file tree
Hide file tree
Showing 12 changed files with 19 additions and 104 deletions.
13 changes: 0 additions & 13 deletions .flake8

This file was deleted.

12 changes: 4 additions & 8 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,10 @@ jobs:
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt -r test-requirements.txt --upgrade --upgrade-strategy eager
- name: Check isort
run: isort tests pyheos --check-only
- name: Check black
run: black tests pyheos --check --fast --quiet
- name: Check pylint
run: pylint tests pyheos
- name: Check flake8
run: flake8 tests pyheos --doctests
- name: Lint (Ruff)
run: ruff check --select I
- name: Format (Ruff)
run: ruff format --check

tests:
name: "Run tests on ${{ matrix.python-version }}"
Expand Down
17 changes: 0 additions & 17 deletions .isort.cfg

This file was deleted.

4 changes: 0 additions & 4 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
{
"python.pythonPath": ".venv\\Scripts\\python.exe",
"python.linting.pylintEnabled": true,
"python.linting.enabled": true,
"python.formatting.provider": "black",
"editor.formatOnPaste": false,
"editor.formatOnSave": true,
"editor.formatOnType": true,
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Contributions welcome!

## Style

This repository uses [Black](https://github.com/psf/black) for code style and formatting and [isort](https://readthedocs.org/projects/isort/) for organizing imports. Commits and pull requests are automatically linted with pylint and flake8.
This repository uses [Ruff](https://docs.astral.sh/ruff/) for code style and formatting. Commits and pull requests are automatically linted and checked using Ruff and must pass in order to be accepted.

*Save time by checking for style/lint issues **before** committing.*:
```bash
Expand Down
8 changes: 3 additions & 5 deletions pyheos/connection.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
"""Define the connection module."""

import asyncio
from collections import defaultdict
from datetime import datetime, timedelta
import json
import logging
from collections import defaultdict
from datetime import datetime, timedelta
from typing import Any, Dict, Optional

from . import const
Expand Down Expand Up @@ -65,9 +65,7 @@ def __init__(
self._reader = None # type: asyncio.StreamReader
self._writer = None # type: asyncio.StreamWriter
self._response_handler_task = None # type: asyncio.Task
self._pending_commands = defaultdict(
list
) # type: DefaultDict[str, List[ResponseEvent]]
self._pending_commands = defaultdict(list) # type: DefaultDict[str, List[ResponseEvent]]
self._sequence = 0 # type: int
self._state = const.STATE_DISCONNECTED # type: str
self._auto_reconnect = False # type: bool
Expand Down
4 changes: 2 additions & 2 deletions pyheos/dispatch.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
"""Defines the dispatch component for notifying others of signals."""

import asyncio
from collections import defaultdict
import functools
from collections import defaultdict
from typing import Any, Callable, Dict, List, Sequence

TargetType = Callable[..., Any]
Expand All @@ -20,7 +20,7 @@ def __init__(
connect: ConnectType = None,
send: SendType = None,
signal_prefix: str = "",
loop=None
loop=None,
):
"""Create a new instance of the dispatch component."""
self._signal_prefix = signal_prefix
Expand Down
4 changes: 2 additions & 2 deletions pyheos/heos.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def __init__(
timeout: float = const.DEFAULT_TIMEOUT,
heart_beat: Optional[float] = const.DEFAULT_HEART_BEAT,
all_progress_events=True,
dispatcher: Dispatcher = None
dispatcher: Dispatcher = None,
):
"""Init a new instance of the Heos CLI API."""
self._connection = HeosConnection(
Expand All @@ -45,7 +45,7 @@ async def connect(
self,
*,
auto_reconnect=False,
reconnect_delay: float = const.DEFAULT_RECONNECT_DELAY
reconnect_delay: float = const.DEFAULT_RECONNECT_DELAY,
):
"""Connect to the CLI."""
await self._connection.connect(
Expand Down
42 changes: 0 additions & 42 deletions pylintrc

This file was deleted.

3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[tool.ruff]
# Assume Python 3.11
target-version = "py311"
6 changes: 2 additions & 4 deletions script/lint.cmd
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
@echo off
isort tests pyheos
black tests pyheos
pylint tests pyheos
flake8 tests pyheos --doctests
ruff check --select I --fix
ruff format
8 changes: 2 additions & 6 deletions test-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
black==24.4.2
coveralls==4.0.0
flake8==7.0.0
flake8-docstrings==1.7.0
isort==5.13.2
pylint==3.2.0
pytest==8.2.0
pytest-asyncio==0.23.6
pytest-cov==5.0.0
pytest-timeout==2.3.1
pytest-timeout==2.3.1
ruff==0.4.5

0 comments on commit e1a4834

Please sign in to comment.