convert to ruff pre-commit

This commit is contained in:
foamyguy 2025-02-21 11:45:35 -06:00
parent 1a8219237f
commit 81b1ad008d
7 changed files with 139 additions and 57 deletions

11
.gitattributes vendored Normal file
View file

@ -0,0 +1,11 @@
# SPDX-FileCopyrightText: 2024 Justin Myers for Adafruit Industries
#
# SPDX-License-Identifier: Unlicense
.py text eol=lf
.rst text eol=lf
.txt text eol=lf
.yaml text eol=lf
.toml text eol=lf
.license text eol=lf
.md text eol=lf

View file

@ -1,42 +1,21 @@
# SPDX-FileCopyrightText: 2020 Diego Elio Pettenò # SPDX-FileCopyrightText: 2024 Justin Myers for Adafruit Industries
# #
# SPDX-License-Identifier: Unlicense # SPDX-License-Identifier: Unlicense
repos: repos:
- repo: https://github.com/python/black
rev: 23.3.0
hooks:
- id: black
- repo: https://github.com/fsfe/reuse-tool
rev: v1.1.2
hooks:
- id: reuse
- repo: https://github.com/pre-commit/pre-commit-hooks - repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0 rev: v4.5.0
hooks: hooks:
- id: check-yaml - id: check-yaml
- id: end-of-file-fixer - id: end-of-file-fixer
- id: trailing-whitespace - id: trailing-whitespace
- repo: https://github.com/pycqa/pylint - repo: https://github.com/astral-sh/ruff-pre-commit
rev: v2.17.4 rev: v0.3.4
hooks: hooks:
- id: pylint - id: ruff-format
name: pylint (library code) - id: ruff
types: [python] args: ["--fix"]
args: - repo: https://github.com/fsfe/reuse-tool
- --disable=consider-using-f-string rev: v3.0.1
exclude: "^(docs/|examples/|tests/|setup.py$)" hooks:
- id: pylint - id: reuse
name: pylint (example code)
description: Run pylint rules on "examples/*.py" files
types: [python]
files: "^examples/"
args:
- --disable=missing-docstring,invalid-name,consider-using-f-string,duplicate-code
- id: pylint
name: pylint (test code)
description: Run pylint rules on "tests/*.py" files
types: [python]
files: "^tests/"
args:
- --disable=missing-docstring,consider-using-f-string,duplicate-code

View file

@ -17,9 +17,9 @@ Introduction
:alt: Build Status :alt: Build Status
.. image:: https://img.shields.io/badge/code%20style-black-000000.svg .. image:: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json
:target: https://github.com/psf/black :target: https://github.com/astral-sh/ruff
:alt: Code Style: Black :alt: Code Style: Ruff
Driver for 7.3" 7-color (aka ACeP) epaper display Driver for 7.3" 7-color (aka ACeP) epaper display

View file

@ -21,24 +21,24 @@ Implementation Notes
""" """
from fourwire import FourWire
from epaperdisplay import EPaperDisplay from epaperdisplay import EPaperDisplay
from fourwire import FourWire
__version__ = "0.0.0+auto.0" __version__ = "0.0.0+auto.0"
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_ACeP7In.git" __repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_ACeP7In.git"
_START_SEQUENCE = ( _START_SEQUENCE = (
b"\xaa\x06\x49\x55\x20\x08\x09\x18" # CMDH b"\xaa\x06\x49\x55\x20\x08\x09\x18" # CMDH
b"\x01\x06\x3F\x00\x32\x2A\x0E\x2A" # power setting PWRR b"\x01\x06\x3f\x00\x32\x2a\x0e\x2a" # power setting PWRR
b"\x00\x02\x5f\x69" # panel setting (PSR) b"\x00\x02\x5f\x69" # panel setting (PSR)
b"\x03\x04\x00\x54\x00\x44" # POFS b"\x03\x04\x00\x54\x00\x44" # POFS
b"\x05\x04\x40\x1F\x1F\x2C" # booster BTST1 b"\x05\x04\x40\x1f\x1f\x2c" # booster BTST1
b"\x06\x04\x6F\x1F\x16\x25" # booster BTST2 b"\x06\x04\x6f\x1f\x16\x25" # booster BTST2
b"\x08\x04\x6F\x1F\x1F\x22" # booster BTST3 b"\x08\x04\x6f\x1f\x1f\x22" # booster BTST3
b"\x13\x02\x00\x04" # IPC b"\x13\x02\x00\x04" # IPC
b"\x30\x01\x02" # PLL setting b"\x30\x01\x02" # PLL setting
b"\x41\x01\x00" # TSE b"\x41\x01\x00" # TSE
b"\x50\x01\x3F" # vcom and data interval setting b"\x50\x01\x3f" # vcom and data interval setting
b"\x60\x02\x02\x00" # tcon setting b"\x60\x02\x02\x00" # tcon setting
b"\x61\x04\x03\x20\x01\xe0" # tres b"\x61\x04\x03\x20\x01\xe0" # tres
b"\x82\x01\x1e" # vdcs b"\x82\x01\x1e" # vdcs
@ -87,5 +87,5 @@ class ACeP7In(EPaperDisplay):
busy_state=False, busy_state=False,
write_black_ram_command=0x10, write_black_ram_command=0x10,
refresh_display_command=b"\x12\x01\x00", refresh_display_command=b"\x12\x01\x00",
advanced_color_epaper=True advanced_color_epaper=True,
) )

View file

@ -1,12 +1,10 @@
# -*- coding: utf-8 -*-
# SPDX-FileCopyrightText: 2017 Scott Shawcroft, written for Adafruit Industries # SPDX-FileCopyrightText: 2017 Scott Shawcroft, written for Adafruit Industries
# #
# SPDX-License-Identifier: MIT # SPDX-License-Identifier: MIT
import datetime
import os import os
import sys import sys
import datetime
sys.path.insert(0, os.path.abspath("..")) sys.path.insert(0, os.path.abspath(".."))
@ -53,9 +51,7 @@ project = "Adafruit CircuitPython ACeP7in Library"
creation_year = "2023" creation_year = "2023"
current_year = str(datetime.datetime.now().year) current_year = str(datetime.datetime.now().year)
year_duration = ( year_duration = (
current_year current_year if current_year == creation_year else creation_year + " - " + current_year
if current_year == creation_year
else creation_year + " - " + current_year
) )
copyright = year_duration + " Scott Shawcroft" copyright = year_duration + " Scott Shawcroft"
author = "Scott Shawcroft" author = "Scott Shawcroft"

View file

@ -4,16 +4,16 @@
# #
# SPDX-License-Identifier: Unlicense # SPDX-License-Identifier: Unlicense
"""Simple test script for 5.6" 600x448 7-color ACeP display. """Simple test script for 5.6" 600x448 7-color ACeP display."""
"""
# pylint: disable=no-member # pylint: disable=no-member
import time import time
import board import board
import displayio import displayio
import adafruit_acep7in
from fourwire import FourWire from fourwire import FourWire
import adafruit_acep7in
displayio.release_displays() displayio.release_displays()
@ -24,13 +24,9 @@ epd_dc = board.D10
epd_reset = board.D11 epd_reset = board.D11
epd_busy = board.D12 epd_busy = board.D12
display_bus = FourWire( display_bus = FourWire(spi, command=epd_dc, chip_select=epd_cs, reset=epd_reset, baudrate=1000000)
spi, command=epd_dc, chip_select=epd_cs, reset=epd_reset, baudrate=1000000
)
display = adafruit_acep7in.ACeP7In( display = adafruit_acep7in.ACeP7In(display_bus, width=800, height=480, busy_pin=epd_busy)
display_bus, width=800, height=480, busy_pin=epd_busy
)
g = displayio.Group() g = displayio.Group()

100
ruff.toml Normal file
View file

@ -0,0 +1,100 @@
# SPDX-FileCopyrightText: 2024 Tim Cocks for Adafruit Industries
#
# SPDX-License-Identifier: MIT
target-version = "py38"
line-length = 100
[lint]
preview = true
select = ["I", "PL", "UP"]
extend-select = [
"D419", # empty-docstring
"E501", # line-too-long
"W291", # trailing-whitespace
"PLC0414", # useless-import-alias
"PLC2401", # non-ascii-name
"PLC2801", # unnecessary-dunder-call
"PLC3002", # unnecessary-direct-lambda-call
"E999", # syntax-error
"PLE0101", # return-in-init
"F706", # return-outside-function
"F704", # yield-outside-function
"PLE0116", # continue-in-finally
"PLE0117", # nonlocal-without-binding
"PLE0241", # duplicate-bases
"PLE0302", # unexpected-special-method-signature
"PLE0604", # invalid-all-object
"PLE0605", # invalid-all-format
"PLE0643", # potential-index-error
"PLE0704", # misplaced-bare-raise
"PLE1141", # dict-iter-missing-items
"PLE1142", # await-outside-async
"PLE1205", # logging-too-many-args
"PLE1206", # logging-too-few-args
"PLE1307", # bad-string-format-type
"PLE1310", # bad-str-strip-call
"PLE1507", # invalid-envvar-value
"PLE2502", # bidirectional-unicode
"PLE2510", # invalid-character-backspace
"PLE2512", # invalid-character-sub
"PLE2513", # invalid-character-esc
"PLE2514", # invalid-character-nul
"PLE2515", # invalid-character-zero-width-space
"PLR0124", # comparison-with-itself
"PLR0202", # no-classmethod-decorator
"PLR0203", # no-staticmethod-decorator
"UP004", # useless-object-inheritance
"PLR0206", # property-with-parameters
"PLR0904", # too-many-public-methods
"PLR0911", # too-many-return-statements
"PLR0912", # too-many-branches
"PLR0913", # too-many-arguments
"PLR0914", # too-many-locals
"PLR0915", # too-many-statements
"PLR0916", # too-many-boolean-expressions
"PLR1702", # too-many-nested-blocks
"PLR1704", # redefined-argument-from-local
"PLR1711", # useless-return
"C416", # unnecessary-comprehension
"PLR1733", # unnecessary-dict-index-lookup
"PLR1736", # unnecessary-list-index-lookup
# ruff reports this rule is unstable
#"PLR6301", # no-self-use
"PLW0108", # unnecessary-lambda
"PLW0120", # useless-else-on-loop
"PLW0127", # self-assigning-variable
"PLW0129", # assert-on-string-literal
"B033", # duplicate-value
"PLW0131", # named-expr-without-context
"PLW0245", # super-without-brackets
"PLW0406", # import-self
"PLW0602", # global-variable-not-assigned
"PLW0603", # global-statement
"PLW0604", # global-at-module-level
# fails on the try: import typing used by libraries
#"F401", # unused-import
"F841", # unused-variable
"E722", # bare-except
"PLW0711", # binary-op-exception
"PLW1501", # bad-open-mode
"PLW1508", # invalid-envvar-default
"PLW1509", # subprocess-popen-preexec-fn
"PLW2101", # useless-with-lock
"PLW3301", # nested-min-max
]
ignore = [
"PLR2004", # magic-value-comparison
"UP030", # format literals
"PLW1514", # unspecified-encoding
]
[format]
line-ending = "lf"