Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 6c86bbf

Browse files
committedApr 30, 2025·
new infrastructure files. use ruff.
1 parent 12819ff commit 6c86bbf

12 files changed

+188
-575
lines changed
 

‎.gitattributes

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# SPDX-FileCopyrightText: 2024 Justin Myers for Adafruit Industries
2+
#
3+
# SPDX-License-Identifier: Unlicense
4+
5+
.py text eol=lf
6+
.rst text eol=lf
7+
.txt text eol=lf
8+
.yaml text eol=lf
9+
.toml text eol=lf
10+
.license text eol=lf
11+
.md text eol=lf

‎.pre-commit-config.yaml

Lines changed: 11 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,21 @@
1-
# SPDX-FileCopyrightText: 2020 Diego Elio Pettenò
1+
# SPDX-FileCopyrightText: 2024 Justin Myers for Adafruit Industries
22
#
33
# SPDX-License-Identifier: Unlicense
44

55
repos:
6-
- repo: https://github.com/python/black
7-
rev: 23.3.0
8-
hooks:
9-
- id: black
10-
- repo: https://github.com/fsfe/reuse-tool
11-
rev: v1.1.2
12-
hooks:
13-
- id: reuse
146
- repo: https://github.com/pre-commit/pre-commit-hooks
15-
rev: v4.4.0
7+
rev: v4.5.0
168
hooks:
179
- id: check-yaml
1810
- id: end-of-file-fixer
1911
- id: trailing-whitespace
20-
- repo: https://github.com/pycqa/pylint
21-
rev: v2.17.4
12+
- repo: https://github.com/astral-sh/ruff-pre-commit
13+
rev: v0.3.4
2214
hooks:
23-
- id: pylint
24-
name: pylint (library code)
25-
types: [python]
26-
args:
27-
- --disable=consider-using-f-string
28-
exclude: "^(docs/|examples/|tests/|setup.py$)"
29-
- id: pylint
30-
name: pylint (example code)
31-
description: Run pylint rules on "examples/*.py" files
32-
types: [python]
33-
files: "^examples/"
34-
args:
35-
- --disable=missing-docstring,invalid-name,consider-using-f-string,duplicate-code
36-
- id: pylint
37-
name: pylint (test code)
38-
description: Run pylint rules on "tests/*.py" files
39-
types: [python]
40-
files: "^tests/"
41-
args:
42-
- --disable=missing-docstring,consider-using-f-string,duplicate-code
15+
- id: ruff-format
16+
- id: ruff
17+
args: ["--fix"]
18+
- repo: https://github.com/fsfe/reuse-tool
19+
rev: v3.0.1
20+
hooks:
21+
- id: reuse

‎.pylintrc

Lines changed: 0 additions & 436 deletions
This file was deleted.

‎.readthedocs.yml

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,22 @@
1-
# SPDX-FileCopyrightText: 2017 Scott Shawcroft, written for Adafruit Industries
1+
# SPDX-FileCopyrightText: 2021 Melissa LeBlanc-Williams for Adafruit Industries
22
#
33
# SPDX-License-Identifier: Unlicense
44

5+
# Read the Docs configuration file
6+
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
7+
8+
# Required
9+
version: 2
10+
11+
sphinx:
12+
configuration: docs/conf.py
13+
14+
build:
15+
os: ubuntu-lts-latest
16+
tools:
17+
python: "3"
18+
519
python:
6-
version: 3
7-
requirements_file: requirements.txt
20+
install:
21+
- requirements: docs/requirements.txt
22+
- requirements: requirements.txt

‎displayio_annotation.py

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,11 @@
2121
2222
"""
2323

24-
# pylint: disable=too-many-arguments, too-many-locals, unused-argument, too-few-public-methods
2524

26-
from terminalio import FONT
27-
from adafruit_display_text import bitmap_label
2825
from adafruit_display_shapes.line import Line
26+
from adafruit_display_text import bitmap_label
2927
from adafruit_displayio_layout.widgets.widget import Widget
28+
from terminalio import FONT
3029

3130

3231
class Annotation(Widget):
@@ -96,7 +95,7 @@ class Annotation(Widget):
9695
File location: *examples/displayio_annotation_simpletest.py*
9796
"""
9897

99-
def __init__(
98+
def __init__( # noqa: PLR0913, PLR0917, too many args, too many positional args
10099
self,
101100
x=None,
102101
y=None,
@@ -123,16 +122,8 @@ def __init__(
123122
widget_width = widget.bounding_box[2]
124123
widget_height = widget.bounding_box[3]
125124
if anchor_point is not None:
126-
line_x0 = (
127-
widget.x
128-
+ round(widget_width * anchor_point[0])
129-
+ position_offset[0]
130-
)
131-
line_y0 = (
132-
widget.y
133-
+ round(widget_height * anchor_point[1])
134-
+ position_offset[1]
135-
)
125+
line_x0 = widget.x + round(widget_width * anchor_point[0]) + position_offset[0]
126+
line_y0 = widget.y + round(widget_height * anchor_point[1]) + position_offset[1]
136127
elif anchored_position is not None:
137128
line_x0 = widget.x + anchored_position[0] + position_offset[0]
138129
line_y0 = widget.y + anchored_position[1] + position_offset[1]
@@ -156,9 +147,7 @@ def __init__(
156147
text_anchor_point = (1.0, 1.0)
157148
underline_x_multiplier = -1
158149

159-
if (
160-
text_under
161-
): # if text is under the line, set to text_anchor_point to upper edge
150+
if text_under: # if text is under the line, set to text_anchor_point to upper edge
162151
text_anchor_point = (text_anchor_point[0], 0.0)
163152

164153
if text_color is None:

‎docs/api.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
.. If your library file(s) are nested in a directory (e.g. /adafruit_foo/foo.py)
55
.. use this format as the module name: "adafruit_foo.foo"
66
7+
API Reference
8+
#############
9+
710
.. automodule:: displayio_annotation
811
:members:
912
:member-order: bysource

‎docs/conf.py

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
1-
# -*- coding: utf-8 -*-
2-
3-
# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
1+
# SPDX-FileCopyrightText: 2017 Scott Shawcroft, written for Adafruit Industries
42
#
53
# SPDX-License-Identifier: MIT
64

5+
import datetime
76
import os
87
import sys
9-
import datetime
108

119
sys.path.insert(0, os.path.abspath(".."))
1210

@@ -29,12 +27,16 @@
2927
# autodoc module docs will fail to generate with a warning.
3028
autodoc_mock_imports = ["terminalio", "vectorio", "bitmaptools"]
3129

30+
autodoc_preserve_defaults = True
3231

3332
intersphinx_mapping = {
3433
"python": ("https://docs.python.org/3", None),
3534
"CircuitPython": ("https://docs.circuitpython.org/en/latest/", None),
3635
}
3736

37+
# Show the docstring from both the class and its __init__() method.
38+
autoclass_content = "both"
39+
3840
# Add any paths that contain templates here, relative to this directory.
3941
templates_path = ["_templates"]
4042

@@ -44,8 +46,13 @@
4446
master_doc = "index"
4547

4648
# General information about the project.
47-
project = " CircuitPython DisplayIO_Annotation Library"
48-
copyright = "2021 Kevin Matocha"
49+
project = "CircuitPython DisplayIO_Annotation Library"
50+
creation_year = "2021"
51+
current_year = str(datetime.datetime.now().year)
52+
year_duration = (
53+
current_year if current_year == creation_year else creation_year + " - " + current_year
54+
)
55+
copyright = year_duration + " Kevin Matocha"
4956
author = "Kevin Matocha"
5057

5158
# The version info for the project you're documenting, acts as replacement for
@@ -67,7 +74,13 @@
6774
# List of patterns, relative to source directory, that match files and
6875
# directories to ignore when looking for source files.
6976
# This patterns also effect to html_static_path and html_extra_path
70-
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store", ".env", "CODE_OF_CONDUCT.md"]
77+
exclude_patterns = [
78+
"_build",
79+
"Thumbs.db",
80+
".DS_Store",
81+
".env",
82+
"CODE_OF_CONDUCT.md",
83+
]
7184

7285
# The reST default role (used for this markup: `text`) to use for all
7386
# documents.
@@ -97,7 +110,6 @@
97110
import sphinx_rtd_theme
98111

99112
html_theme = "sphinx_rtd_theme"
100-
html_theme_path = [sphinx_rtd_theme.get_html_theme_path(), "."]
101113

102114
# Add any paths that contain custom static files (such as style sheets) here,
103115
# relative to this directory. They are copied after the builtin static files,
@@ -111,22 +123,18 @@
111123
html_favicon = "_static/favicon.ico"
112124

113125
# Output file base name for HTML help builder.
114-
htmlhelp_basename = "CircuitPython_Displayio_annotationLibrarydoc"
126+
htmlhelp_basename = "CircuitPython_Displayio_annotation_Librarydoc"
115127

116128
# -- Options for LaTeX output ---------------------------------------------
117129

118130
latex_elements = {
119131
# The paper size ('letterpaper' or 'a4paper').
120-
#
121132
# 'papersize': 'letterpaper',
122133
# The font size ('10pt', '11pt' or '12pt').
123-
#
124134
# 'pointsize': '10pt',
125135
# Additional stuff for the LaTeX preamble.
126-
#
127136
# 'preamble': '',
128137
# Latex figure (float) alignment
129-
#
130138
# 'figure_align': 'htbp',
131139
}
132140

@@ -136,7 +144,7 @@
136144
latex_documents = [
137145
(
138146
master_doc,
139-
"CircuitPython_DisplayIO_AnnotationLibrary.tex",
147+
"CircuitPython_DisplayIO_Annotation_Library.tex",
140148
"CircuitPython DisplayIO_Annotation Library Documentation",
141149
author,
142150
"manual",
@@ -150,11 +158,11 @@
150158
man_pages = [
151159
(
152160
master_doc,
153-
"CircuitPython_DisplayIO_AnnotationLibrary",
161+
"CircuitPython_DisplayIO_Annotation_Library",
154162
"CircuitPython DisplayIO_Annotation Library Documentation",
155163
[author],
156164
1,
157-
)
165+
),
158166
]
159167

160168
# -- Options for Texinfo output -------------------------------------------
@@ -165,10 +173,10 @@
165173
texinfo_documents = [
166174
(
167175
master_doc,
168-
"CircuitPython_DisplayIO_AnnotationLibrary",
176+
"CircuitPython_DisplayIO_Annotation_Library",
169177
"CircuitPython DisplayIO_Annotation Library Documentation",
170178
author,
171-
"CircuitPython_DisplayIO_AnnotationLibrary",
179+
"CircuitPython_DisplayIO_Annotation_Library",
172180
"One line description of project.",
173181
"Miscellaneous",
174182
),

‎docs/requirements.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# SPDX-FileCopyrightText: 2021 Kattni Rembor for Adafruit Industries
2+
#
3+
# SPDX-License-Identifier: Unlicense
4+
5+
sphinx
6+
sphinxcontrib-jquery
7+
sphinx-rtd-theme

‎examples/displayio_annotation_simpletest.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,12 @@
77
"""
88

99
import time
10+
11+
import adafruit_touchscreen
1012
import board
1113
import displayio
12-
import adafruit_touchscreen
13-
from adafruit_displayio_layout.widgets.switch_round import SwitchRound as Switch
1414
from adafruit_displayio_layout.widgets.annotation import Annotation
15+
from adafruit_displayio_layout.widgets.switch_round import SwitchRound as Switch
1516

1617
display = board.DISPLAY
1718

‎pyproject.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,11 @@ keywords = [
2424
"blinka",
2525
"circuitpython",
2626
"micropython",
27-
"displayio",
2827
"displayio_annotation",
28+
"displayio",
29+
"annotation",
2930
"graphics",
30-
"widget"
31+
"widget",
3132
]
3233
license = {text = "MIT"}
3334
classifiers = [

‎ruff.toml

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
# SPDX-FileCopyrightText: 2024 Tim Cocks for Adafruit Industries
2+
#
3+
# SPDX-License-Identifier: MIT
4+
5+
target-version = "py38"
6+
line-length = 100
7+
8+
[lint]
9+
preview = true
10+
select = ["I", "PL", "UP"]
11+
12+
extend-select = [
13+
"D419", # empty-docstring
14+
"E501", # line-too-long
15+
"W291", # trailing-whitespace
16+
"PLC0414", # useless-import-alias
17+
"PLC2401", # non-ascii-name
18+
"PLC2801", # unnecessary-dunder-call
19+
"PLC3002", # unnecessary-direct-lambda-call
20+
"E999", # syntax-error
21+
"PLE0101", # return-in-init
22+
"F706", # return-outside-function
23+
"F704", # yield-outside-function
24+
"PLE0116", # continue-in-finally
25+
"PLE0117", # nonlocal-without-binding
26+
"PLE0241", # duplicate-bases
27+
"PLE0302", # unexpected-special-method-signature
28+
"PLE0604", # invalid-all-object
29+
"PLE0605", # invalid-all-format
30+
"PLE0643", # potential-index-error
31+
"PLE0704", # misplaced-bare-raise
32+
"PLE1141", # dict-iter-missing-items
33+
"PLE1142", # await-outside-async
34+
"PLE1205", # logging-too-many-args
35+
"PLE1206", # logging-too-few-args
36+
"PLE1307", # bad-string-format-type
37+
"PLE1310", # bad-str-strip-call
38+
"PLE1507", # invalid-envvar-value
39+
"PLE2502", # bidirectional-unicode
40+
"PLE2510", # invalid-character-backspace
41+
"PLE2512", # invalid-character-sub
42+
"PLE2513", # invalid-character-esc
43+
"PLE2514", # invalid-character-nul
44+
"PLE2515", # invalid-character-zero-width-space
45+
"PLR0124", # comparison-with-itself
46+
"PLR0202", # no-classmethod-decorator
47+
"PLR0203", # no-staticmethod-decorator
48+
"UP004", # useless-object-inheritance
49+
"PLR0206", # property-with-parameters
50+
"PLR0904", # too-many-public-methods
51+
"PLR0911", # too-many-return-statements
52+
"PLR0912", # too-many-branches
53+
"PLR0913", # too-many-arguments
54+
"PLR0914", # too-many-locals
55+
"PLR0915", # too-many-statements
56+
"PLR0916", # too-many-boolean-expressions
57+
"PLR1702", # too-many-nested-blocks
58+
"PLR1704", # redefined-argument-from-local
59+
"PLR1711", # useless-return
60+
"C416", # unnecessary-comprehension
61+
"PLR1733", # unnecessary-dict-index-lookup
62+
"PLR1736", # unnecessary-list-index-lookup
63+
64+
# ruff reports this rule is unstable
65+
#"PLR6301", # no-self-use
66+
67+
"PLW0108", # unnecessary-lambda
68+
"PLW0120", # useless-else-on-loop
69+
"PLW0127", # self-assigning-variable
70+
"PLW0129", # assert-on-string-literal
71+
"B033", # duplicate-value
72+
"PLW0131", # named-expr-without-context
73+
"PLW0245", # super-without-brackets
74+
"PLW0406", # import-self
75+
"PLW0602", # global-variable-not-assigned
76+
"PLW0603", # global-statement
77+
"PLW0604", # global-at-module-level
78+
79+
# fails on the try: import typing used by libraries
80+
#"F401", # unused-import
81+
82+
"F841", # unused-variable
83+
"E722", # bare-except
84+
"PLW0711", # binary-op-exception
85+
"PLW1501", # bad-open-mode
86+
"PLW1508", # invalid-envvar-default
87+
"PLW1509", # subprocess-popen-preexec-fn
88+
"PLW2101", # useless-with-lock
89+
"PLW3301", # nested-min-max
90+
]
91+
92+
ignore = [
93+
"PLR2004", # magic-value-comparison
94+
"UP030", # format literals
95+
"PLW1514", # unspecified-encoding
96+
97+
]
98+
99+
[format]
100+
line-ending = "lf"

‎setup.py

Lines changed: 0 additions & 65 deletions
This file was deleted.

0 commit comments

Comments
 (0)
Please sign in to comment.