Skip to content

Commit

Permalink
black, flake8 -> ruff
Browse files Browse the repository at this point in the history
  • Loading branch information
newAM committed Jan 14, 2025
1 parent 9639eab commit c1e43cf
Show file tree
Hide file tree
Showing 9 changed files with 190 additions and 379 deletions.
3 changes: 0 additions & 3 deletions .flake8

This file was deleted.

9 changes: 3 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,9 @@ jobs:
python-version: "3.12"
- name: Install Poetry
uses: abatilo/actions-poetry@v4.0.0
- name: Poetry Install
run: poetry install
- name: Run flake8
run: poetry run flake8
- name: Run black
run: poetry run black --verbose --check .
- run: poetry install
- run: poetry run ruff check
- run: poetry run ruff format --check

docs:
runs-on: ubuntu-latest
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ docs/cli.txt
.vscode/
public/
*.orig
.ruff_cache/

# Byte-compiled / optimized / DLL files
__pycache__/
Expand Down
7 changes: 4 additions & 3 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
monitorcontrol
##############

|PyPi Version| |Build Status| |Documentation Status| |Coverage Status| |Black|
|PyPi Version| |Build Status| |Documentation Status| |Coverage Status| |Ruff|

Python monitor control using the VESA Monitor Control Command Set (MCCS)
over the Display Data Channel Command Interface Standard (DDC-CI).
Expand Down Expand Up @@ -38,5 +38,6 @@ Full documentation including examples are avaliable in the `docs <https://newam.
:target: https://coveralls.io/github/newAM/monitorcontrol?branch=master
.. |Documentation Status| image:: https://img.shields.io/badge/docs-latest-blue
:target: https://newam.github.io/monitorcontrol
.. |Black| image:: https://img.shields.io/badge/code%20style-black-000000.svg
:target: https://github.com/psf/black
.. |Ruff| image:: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json
:target: https://github.com/astral-sh/ruff
:alt: Ruff
4 changes: 3 additions & 1 deletion monitorcontrol/monitorcontrol.py
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,9 @@ def get_input_source(self) -> InputSource:
try:
return InputSource(value)
except ValueError:
raise InputSourceValueError(f"{value} is not a valid InputSource", value)
raise InputSourceValueError(
f"{value} is not a valid InputSource", value
) from None

def set_input_source(self, value: Union[int, str, InputSource]):
"""
Expand Down
4 changes: 2 additions & 2 deletions monitorcontrol/vcp/vcp_linux.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,14 +279,14 @@ def get_vcp_capabilities(self):
# remove checksum from length

# unpack the payload
reply_code, payload = struct.unpack(f">B{length-1}s", payload)
reply_code, payload = struct.unpack(f">B{length - 1}s", payload)
length -= 1

if reply_code != self.GET_VCP_CAPS_REPLY:
raise VCPIOError(f"received unexpected response code: {reply_code}")

# unpack the payload
offset, payload = struct.unpack(f">H{length-2}s", payload)
offset, payload = struct.unpack(f">H{length - 2}s", payload)
length -= 2

if length > 0:
Expand Down
522 changes: 167 additions & 355 deletions poetry.lock

Large diffs are not rendered by default.

9 changes: 5 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,10 @@ python = "^3.9"
pyudev = { version = ">=0.23,<0.25", markers = "sys_platform != 'win32'" }

[tool.poetry.dev-dependencies]
black = "24.8.0"
coveralls = "^3"
flake8 = { version = "^7", python = ">=3.8.1,<4.0" }
flake8-bugbear = { version = "^24.12.12", python = ">=3.8.1,<4.0" }
pep8-naming = "~0.14"
pytest = "^8"
pytest-cov = "^5"
ruff = "^0.9.1"
sphinx = "^7.1"
sphinx-rtd-theme = "^3"
toml = "~0.10"
Expand All @@ -31,3 +28,7 @@ monitorcontrol = "monitorcontrol.__main__:main"
[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"

[tool.ruff.lint]
# Add flake8-bugbear and pep8-naming rules
extend-select = ["B", "N"]
10 changes: 5 additions & 5 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,11 @@ def test_set_input_source(value: str):


def test_get_monitors():
with get_monitors_mock, mock.patch.object(
Monitor, "get_input_source"
) as input_source_api_mock, mock.patch.object(
Monitor, "get_vcp_capabilities"
) as vcp_capabilities_api_mock:
with (
get_monitors_mock,
mock.patch.object(Monitor, "get_input_source") as input_source_api_mock,
mock.patch.object(Monitor, "get_vcp_capabilities") as vcp_capabilities_api_mock,
):
main(["--get-monitors"])
input_source_api_mock.assert_called()
vcp_capabilities_api_mock.assert_called()

0 comments on commit c1e43cf

Please sign in to comment.