Skip to content

Commit 0d73d37

Browse files
authored
Merge pull request #4 from adafruit/pylint-update
Pylint update
2 parents 4ddca6b + 4dcc7c2 commit 0d73d37

File tree

7 files changed

+148
-111
lines changed

7 files changed

+148
-111
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ jobs:
4040
source actions-ci/install.sh
4141
- name: Pip install pylint, black, & Sphinx
4242
run: |
43-
pip install --force-reinstall pylint==1.9.2 black==19.10b0 Sphinx sphinx-rtd-theme
43+
pip install --force-reinstall pylint black==19.10b0 Sphinx sphinx-rtd-theme
4444
- name: Library version
4545
run: git describe --dirty --always --tags
4646
- name: PyLint

adafruit_display_notification/__init__.py

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -41,29 +41,35 @@
4141

4242
# pylint: disable=too-few-public-methods
4343

44+
4445
class NotificationFree(displayio.Group):
4546
"""Widget to show when no notifications are active."""
47+
4648
def __init__(self, width, height, *, dark_mode=True):
4749
# pylint: disable=unused-argument
4850
super().__init__()
4951

5052
if dark_mode:
51-
text_color = 0xffffff
53+
text_color = 0xFFFFFF
5254
else:
5355
text_color = 0x000000
5456

5557
# Create the text label
56-
self.title = label.Label(TEXT_FONT, text="None!", y=height//2, color=text_color)
58+
self.title = label.Label(
59+
TEXT_FONT, text="None!", y=height // 2, color=text_color
60+
)
5761
self.append(self.title)
5862

63+
5964
class PlainNotification(displayio.Group):
6065
"""Plain text widget with a title and message."""
66+
6167
def __init__(self, title, message, width, height, *, dark_mode=True):
6268
super().__init__()
6369

6470
# Set text, font, and color
6571
if dark_mode:
66-
text_color = 0xffffff
72+
text_color = 0xFFFFFF
6773
else:
6874
text_color = 0x000000
6975

@@ -76,11 +82,9 @@ def __init__(self, title, message, width, height, *, dark_mode=True):
7682
max_lines = height // 20
7783
message = "\n".join(lines[:max_lines])
7884

79-
self.message = label.Label(terminalio.FONT,
80-
text=message,
81-
color=text_color,
82-
x=2,
83-
y=height // 2 + 8)
85+
self.message = label.Label(
86+
terminalio.FONT, text=message, color=text_color, x=2, y=height // 2 + 8
87+
)
8488
self.append(self.message)
8589

8690
# cribbed from pyportal
@@ -90,17 +94,17 @@ def _wrap_nicely(string, max_chars):
9094
:param str string: The text to be wrapped.
9195
:param int max_chars: The maximum number of characters on a line before wrapping.
9296
"""
93-
string = string.replace('\n', '').replace('\r', '') # strip confusing newlines
94-
words = string.split(' ')
97+
string = string.replace("\n", "").replace("\r", "") # strip confusing newlines
98+
words = string.split(" ")
9599
the_lines = []
96100
the_line = ""
97101
for w in words:
98-
if len(the_line+' '+w) <= max_chars:
99-
the_line += ' '+w
102+
if len(the_line + " " + w) <= max_chars:
103+
the_line += " " + w
100104
else:
101105
the_lines.append(the_line)
102-
the_line = ''+w
103-
if the_line: # last line remaining
106+
the_line = "" + w
107+
if the_line: # last line remaining
104108
the_lines.append(the_line)
105109
# remove first space from first line:
106110
the_lines[0] = the_lines[0][1:]

adafruit_display_notification/apple.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,12 @@
3434
__version__ = "0.0.0-auto.0"
3535
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_Display_Notification.git"
3636

37-
def create_notification_widget(notification, max_width, max_height, *, color_count=2**16):
37+
38+
def create_notification_widget(
39+
notification, max_width, max_height, *, color_count=2 ** 16
40+
):
3841
"""Creates a notification widget for the given Apple notification."""
3942
# pylint: disable=unused-argument
40-
return PlainNotification(notification.title, notification.message, max_width, max_height)
43+
return PlainNotification(
44+
notification.title, notification.message, max_width, max_height
45+
)

docs/conf.py

Lines changed: 71 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -2,50 +2,59 @@
22

33
import os
44
import sys
5-
sys.path.insert(0, os.path.abspath('..'))
5+
6+
sys.path.insert(0, os.path.abspath(".."))
67

78
# -- General configuration ------------------------------------------------
89

910
# Add any Sphinx extension module names here, as strings. They can be
1011
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
1112
# ones.
1213
extensions = [
13-
'sphinx.ext.autodoc',
14-
'sphinx.ext.intersphinx',
15-
'sphinx.ext.napoleon',
16-
'sphinx.ext.todo',
14+
"sphinx.ext.autodoc",
15+
"sphinx.ext.intersphinx",
16+
"sphinx.ext.napoleon",
17+
"sphinx.ext.todo",
1718
]
1819

1920
# TODO: Please Read!
2021
# Uncomment the below if you use native CircuitPython modules such as
2122
# digitalio, micropython and busio. List the modules you use. Without it, the
2223
# autodoc module docs will fail to generate with a warning.
23-
autodoc_mock_imports = ["displayio", "adafruit_bitmap_font", "adafruit_display_text", "terminalio"]
24+
autodoc_mock_imports = [
25+
"displayio",
26+
"adafruit_bitmap_font",
27+
"adafruit_display_text",
28+
"terminalio",
29+
]
2430

2531

26-
intersphinx_mapping = {'python': ('https://docs.python.org/3.4', None),'CircuitPython': ('https://circuitpython.readthedocs.io/en/latest/', None)}
32+
intersphinx_mapping = {
33+
"python": ("https://docs.python.org/3.4", None),
34+
"CircuitPython": ("https://circuitpython.readthedocs.io/en/latest/", None),
35+
}
2736

2837
# Add any paths that contain templates here, relative to this directory.
29-
templates_path = ['_templates']
38+
templates_path = ["_templates"]
3039

31-
source_suffix = '.rst'
40+
source_suffix = ".rst"
3241

3342
# The master toctree document.
34-
master_doc = 'index'
43+
master_doc = "index"
3544

3645
# General information about the project.
37-
project = u'Adafruit Display_Notification Library'
38-
copyright = u'2019 Scott Shawcroft'
39-
author = u'Scott Shawcroft'
46+
project = "Adafruit Display_Notification Library"
47+
copyright = "2019 Scott Shawcroft"
48+
author = "Scott Shawcroft"
4049

4150
# The version info for the project you're documenting, acts as replacement for
4251
# |version| and |release|, also used in various other places throughout the
4352
# built documents.
4453
#
4554
# The short X.Y version.
46-
version = u'1.0'
55+
version = "1.0"
4756
# The full version, including alpha/beta/rc tags.
48-
release = u'1.0'
57+
release = "1.0"
4958

5059
# The language for content autogenerated by Sphinx. Refer to documentation
5160
# for a list of supported languages.
@@ -57,7 +66,7 @@
5766
# List of patterns, relative to source directory, that match files and
5867
# directories to ignore when looking for source files.
5968
# This patterns also effect to html_static_path and html_extra_path
60-
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store', '.env', 'CODE_OF_CONDUCT.md']
69+
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store", ".env", "CODE_OF_CONDUCT.md"]
6170

6271
# The reST default role (used for this markup: `text`) to use for all
6372
# documents.
@@ -69,7 +78,7 @@
6978
add_function_parentheses = True
7079

7180
# The name of the Pygments (syntax highlighting) style to use.
72-
pygments_style = 'sphinx'
81+
pygments_style = "sphinx"
7382

7483
# If true, `todo` and `todoList` produce output, else they produce nothing.
7584
todo_include_todos = False
@@ -84,68 +93,76 @@
8493
# The theme to use for HTML and HTML Help pages. See the documentation for
8594
# a list of builtin themes.
8695
#
87-
on_rtd = os.environ.get('READTHEDOCS', None) == 'True'
96+
on_rtd = os.environ.get("READTHEDOCS", None) == "True"
8897

8998
if not on_rtd: # only import and set the theme if we're building docs locally
9099
try:
91100
import sphinx_rtd_theme
92-
html_theme = 'sphinx_rtd_theme'
93-
html_theme_path = [sphinx_rtd_theme.get_html_theme_path(), '.']
101+
102+
html_theme = "sphinx_rtd_theme"
103+
html_theme_path = [sphinx_rtd_theme.get_html_theme_path(), "."]
94104
except:
95-
html_theme = 'default'
96-
html_theme_path = ['.']
105+
html_theme = "default"
106+
html_theme_path = ["."]
97107
else:
98-
html_theme_path = ['.']
108+
html_theme_path = ["."]
99109

100110
# Add any paths that contain custom static files (such as style sheets) here,
101111
# relative to this directory. They are copied after the builtin static files,
102112
# so a file named "default.css" will overwrite the builtin "default.css".
103-
html_static_path = ['_static']
113+
html_static_path = ["_static"]
104114

105115
# The name of an image file (relative to this directory) to use as a favicon of
106116
# the docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
107117
# pixels large.
108118
#
109-
html_favicon = '_static/favicon.ico'
119+
html_favicon = "_static/favicon.ico"
110120

111121
# Output file base name for HTML help builder.
112-
htmlhelp_basename = 'AdafruitDisplay_notificationLibrarydoc'
122+
htmlhelp_basename = "AdafruitDisplay_notificationLibrarydoc"
113123

114124
# -- Options for LaTeX output ---------------------------------------------
115125

116126
latex_elements = {
117-
# The paper size ('letterpaper' or 'a4paper').
118-
#
119-
# 'papersize': 'letterpaper',
120-
121-
# The font size ('10pt', '11pt' or '12pt').
122-
#
123-
# 'pointsize': '10pt',
124-
125-
# Additional stuff for the LaTeX preamble.
126-
#
127-
# 'preamble': '',
128-
129-
# Latex figure (float) alignment
130-
#
131-
# 'figure_align': 'htbp',
127+
# The paper size ('letterpaper' or 'a4paper').
128+
#
129+
# 'papersize': 'letterpaper',
130+
# The font size ('10pt', '11pt' or '12pt').
131+
#
132+
# 'pointsize': '10pt',
133+
# Additional stuff for the LaTeX preamble.
134+
#
135+
# 'preamble': '',
136+
# Latex figure (float) alignment
137+
#
138+
# 'figure_align': 'htbp',
132139
}
133140

134141
# Grouping the document tree into LaTeX files. List of tuples
135142
# (source start file, target name, title,
136143
# author, documentclass [howto, manual, or own class]).
137144
latex_documents = [
138-
(master_doc, 'AdafruitDisplay_NotificationLibrary.tex', u'AdafruitDisplay_Notification Library Documentation',
139-
author, 'manual'),
145+
(
146+
master_doc,
147+
"AdafruitDisplay_NotificationLibrary.tex",
148+
"AdafruitDisplay_Notification Library Documentation",
149+
author,
150+
"manual",
151+
),
140152
]
141153

142154
# -- Options for manual page output ---------------------------------------
143155

144156
# One entry per manual page. List of tuples
145157
# (source start file, name, description, authors, manual section).
146158
man_pages = [
147-
(master_doc, 'AdafruitDisplay_Notificationlibrary', u'Adafruit Display_Notification Library Documentation',
148-
[author], 1)
159+
(
160+
master_doc,
161+
"AdafruitDisplay_Notificationlibrary",
162+
"Adafruit Display_Notification Library Documentation",
163+
[author],
164+
1,
165+
)
149166
]
150167

151168
# -- Options for Texinfo output -------------------------------------------
@@ -154,7 +171,13 @@
154171
# (source start file, target name, title, author,
155172
# dir menu entry, description, category)
156173
texinfo_documents = [
157-
(master_doc, 'AdafruitDisplay_NotificationLibrary', u'Adafruit Display_Notification Library Documentation',
158-
author, 'AdafruitDisplay_NotificationLibrary', 'One line description of project.',
159-
'Miscellaneous'),
174+
(
175+
master_doc,
176+
"AdafruitDisplay_NotificationLibrary",
177+
"Adafruit Display_Notification Library Documentation",
178+
author,
179+
"AdafruitDisplay_NotificationLibrary",
180+
"One line description of project.",
181+
"Miscellaneous",
182+
),
160183
]

examples/display_notification_eink_gizmo.py

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
# This is a whitelist of apps to show notifications from.
1212
APPS = ["com.tinyspeck.chatlyio", "com.atebits.Tweetie2"]
1313

14+
1415
def find_connection():
1516
for connection in radio.connections:
1617
if AppleNotificationCenterService not in connection:
@@ -20,6 +21,7 @@ def find_connection():
2021
return connection, connection[AppleNotificationCenterService]
2122
return None, None
2223

24+
2325
# Start advertising before messing with the display so that we can connect immediately.
2426
radio = adafruit_ble.BLERadio()
2527
a = SolicitServicesAdvertisement()
@@ -51,14 +53,19 @@ def find_connection():
5153
if not screen_updated:
5254
remaining_time = display.time_to_refresh
5355
new_notification = None
54-
for notification in notification_service.wait_for_new_notifications(remaining_time):
56+
for notification in notification_service.wait_for_new_notifications(
57+
remaining_time
58+
):
5559
# Filter notifications we don't care about.
5660
if APPS and notification.app_id not in APPS:
5761
continue
5862
# For now, use _raw_date even though we should use a parsed version of the date.
5963
# pylint: disable=protected-access
6064
# Ignore notifications older than the currently shown one.
61-
if latest_notification and notification._raw_date < latest_notification._raw_date:
65+
if (
66+
latest_notification
67+
and notification._raw_date < latest_notification._raw_date
68+
):
6269
continue
6370
new_notification = notification
6471
break
@@ -67,9 +74,11 @@ def find_connection():
6774
print(new_notification)
6875
latest_notification = new_notification
6976
screen_updated = False
70-
display.show(apple.create_notification_widget(latest_notification,
71-
display.width,
72-
display.height))
77+
display.show(
78+
apple.create_notification_widget(
79+
latest_notification, display.width, display.height
80+
)
81+
)
7382
elif latest_notification and latest_notification.removed:
7483
# Stop showing the latest and show that there are no new notifications.
7584
latest_notification = None

0 commit comments

Comments
 (0)