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
22 changes: 18 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,28 @@ jobs:

format:
runs-on: ubuntu-24.04
name: Check code formatting with black
name: Check code formatting with ruff
steps:
- uses: actions/checkout@v3
- name: Setup python
uses: actions/setup-python@v4
with:
python-version: 3.12
- name: Install black
run: pip install black~=25.1
- name: Install ruff
run: pip install ruff~=0.11.2
- name: Check code formatting
run: black --check .
run: ruff format --check --diff

lint:
runs-on: ubuntu-24.04
name: Run linting with ruff
steps:
- uses: actions/checkout@v3
- name: Setup python
uses: actions/setup-python@v4
with:
python-version: 3.12
- name: Install ruff
run: pip install ruff~=0.11.2
- name: Run linter
run: ruff check
10 changes: 2 additions & 8 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -124,15 +124,9 @@ Then run the tests:
Coding Guidelines
=================

`PEP8 <http://www.python.org/dev/peps/pep-0008/>`__ via `flake8
<https://pypi.python.org/pypi/flake8>`_ with ``max-line-width`` set to 99 and
``E126-E128,C901`` ignored::
Please reformat your code using `ruff format <https://docs.astral.sh/ruff/formatter/>`_::

flake8 --max-line-length=99 --ignore=E126,E127,E128,C901 RPLCD/lcd.py

Additionally, please reformat your code using `black <https://black.readthedocs.io/>`_::

black .
ruff format


About HD44780
Expand Down
2 changes: 1 addition & 1 deletion RPLCD/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def __new__(cls, *args, **kwargs):
from .gpio import CharLCD as GpioCharLCD

warnings.warn(
"Using RPLCD.CharLCD directly is deprecated. Use RPLCD.gpio.CharLCD instead!",
'Using RPLCD.CharLCD directly is deprecated. Use RPLCD.gpio.CharLCD instead!',
DeprecationWarning,
)
return GpioCharLCD(*args, **kwargs)
8 changes: 4 additions & 4 deletions RPLCD/i2c.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,8 @@ def __init__(
if expander_params is None:
if self._i2c_expander == 'MCP23017':
raise ValueError(
'MCP23017: expander_params[\'gpio_bank\'] is not defined, '
'must be either \'A\' or \'B\''
"MCP23017: expander_params['gpio_bank'] is not defined, "
"must be either 'A' or 'B'"
)
else:
self._expander_params = {}
Expand All @@ -160,8 +160,8 @@ def __init__(
self._expander_params['gpio_bank'] = expander_params['gpio_bank']
else:
raise ValueError(
'MCP23017: expander_params[\'gpio_bank\'] is \'%s\', '
'must be either \'A\' or \'B\'' % expander_params['gpio_bank']
"MCP23017: expander_params['gpio_bank'] is '%s', "
"must be either 'A' or 'B'" % expander_params['gpio_bank']
)

# Currently the I2C mode only supports 4 bit communication
Expand Down
2 changes: 0 additions & 2 deletions RPLCD/lcd.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@


class BaseCharLCD(object):

# Init, setup, teardown

def __init__(self, cols=20, rows=4, dotsize=8, charmap='A02', auto_linebreaks=True):
Expand Down Expand Up @@ -284,7 +283,6 @@ def write_string(self, value):
ignored = False

for [char, lookahead] in c.sliding_window(encoded, lookahead=1):

# If the previous character has been ignored, skip this one too.
if ignored is True:
ignored = False
Expand Down
1 change: 0 additions & 1 deletion RPLCD/pigpio.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,6 @@ def _init_connection(self):
self._writescript = self.pi.store_script(bytes(piscript, 'utf-8'))

def _close_connection(self):

while self.pi.script_status(self._writescript) == pigpio.PI_SCRIPT_RUNNING:
c.msleep(10)
self.pi.delete_script(self._writescript)
Expand Down
13 changes: 4 additions & 9 deletions RPLCD_Tests/entrypoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ def print_usage(error=None):

# Options for GPIO mode
elif (len(sys.argv) > 1) and (sys.argv[1] == 'gpio'):

print('<options> gpio options:')
print('')
print(' mode - GPIO numbering mode, either BOARD or BCM')
Expand All @@ -98,7 +97,6 @@ def print_usage(error=None):
)
# Options for PIGPIO mode
elif (len(sys.argv) > 1) and (sys.argv[1] == 'pigpio'):

print('<options> pigpio options:')
print('')
print(' host - Host name of the Pi on which the pigpio daemon is running.')
Expand Down Expand Up @@ -142,11 +140,11 @@ def print_usage(error=None):


def options_pop(value, default=no_default):
'''Pops value from options with error checking
"""Pops value from options with error checking
value: which option to pop and check.
default: optional, sets a default if not defined.
returns: a string corresponding to the option on the command line
'''
"""
global options
try:
# If no default value is defined
Expand All @@ -161,7 +159,7 @@ def options_pop(value, default=no_default):
except Exception as e:
raise e
if return_value == '':
print_usage('Option %s can\'t be blank.' % value)
print_usage("Option %s can't be blank." % value)
return return_value


Expand All @@ -184,7 +182,6 @@ def run():
rows = int(options_pop('rows'))
charmap = options_pop('charmap', 'A00')
if lcdmode == 'i2c':

from RPLCD import i2c

if len(sys.argv) < 5:
Expand All @@ -210,7 +207,6 @@ def run():
'or device not connected properly'
)
elif lcdmode == 'gpio':

import RPi.GPIO as GPIO
from RPLCD import gpio

Expand Down Expand Up @@ -251,7 +247,6 @@ def run():
charmap=charmap,
)
elif lcdmode == 'pigpio':

from pigpio import pi
from RPLCD import pigpio

Expand Down Expand Up @@ -308,4 +303,4 @@ def run():
else:
print_usage('%sx%s displays are not supported in this test.' % (cols, rows))
else:
print_usage('Test \'%s\' is not supported.' % test)
print_usage("Test '%s' is not supported." % test)
1 change: 0 additions & 1 deletion RPLCD_Tests/show_charmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@


def run(lcd, rows, cols):

print('This tool shows the character map of your LCD on the display.')
print('Press ctrl+c at any time to abort.\n')

Expand Down
1 change: 0 additions & 1 deletion RPLCD_Tests/testsuite_16x2.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@


def run(lcd):

lcd.backlight = True
input('Display should be blank. ')

Expand Down
1 change: 0 additions & 1 deletion RPLCD_Tests/testsuite_20x4.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@


def run(lcd):

lcd.backlight = True
input('Display should be blank. ')

Expand Down
14 changes: 6 additions & 8 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
[tool.black]
[tool.ruff]
line-length = 99
target-version = ["py38", "py39", "py310", "py311", "py312"]
extend-exclude = '''
(^/RPLCD/codecs/.*\.py$
|^/docs/conf.py$
)
'''
skip-string-normalization = true
target-version = "py38"

[tool.ruff.format]
exclude = ["RPLCD/codecs/*.py", "docs/conf.py"]
quote-style = "single"
52 changes: 26 additions & 26 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,37 @@

from setuptools import setup

readme = open("README.rst").read()
readme = open('README.rst').read()

setup(
name="RPLCD",
version="1.3.1",
description="A Raspberry Pi LCD library for the widely used Hitachi HD44780 controller.",
name='RPLCD',
version='1.3.1',
description='A Raspberry Pi LCD library for the widely used Hitachi HD44780 controller.',
long_description=readme,
author="Danilo Bargen",
author_email="mail@dbrgn.ch",
url="https://github.com/dbrgn/RPLCD",
license="MIT",
keywords="raspberry, raspberry pi, lcd, liquid crystal, hitachi, hd44780",
packages=["RPLCD", "RPLCD.codecs", "RPLCD_Tests"],
author='Danilo Bargen',
author_email='mail@dbrgn.ch',
url='https://github.com/dbrgn/RPLCD',
license='MIT',
keywords='raspberry, raspberry pi, lcd, liquid crystal, hitachi, hd44780',
packages=['RPLCD', 'RPLCD.codecs', 'RPLCD_Tests'],
entry_points={
"console_scripts": ["rplcd-tests=RPLCD_Tests.entrypoint:run"],
'console_scripts': ['rplcd-tests=RPLCD_Tests.entrypoint:run'],
},
platforms=["any"],
python_requires=">=3.8",
platforms=['any'],
python_requires='>=3.8',
classifiers=[
"Development Status :: 5 - Production/Stable",
"Environment :: Other Environment",
"Intended Audience :: Developers",
"License :: OSI Approved :: MIT License",
"Operating System :: POSIX",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Topic :: System :: Hardware :: Hardware Drivers",
"Topic :: Software Development :: Libraries :: Python Modules",
'Development Status :: 5 - Production/Stable',
'Environment :: Other Environment',
'Intended Audience :: Developers',
'License :: OSI Approved :: MIT License',
'Operating System :: POSIX',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11',
'Programming Language :: Python :: 3.12',
'Topic :: System :: Hardware :: Hardware Drivers',
'Topic :: Software Development :: Libraries :: Python Modules',
],
)