Skip to content

Commit b9a2cd2

Browse files
authored
Merge pull request #40 from adafruit/pylint-update
Ran black, updated to pylint 2.x
2 parents c4e9e5a + 098fa93 commit b9a2cd2

File tree

7 files changed

+348
-311
lines changed

7 files changed

+348
-311
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_rfm9x.py

Lines changed: 216 additions & 193 deletions
Large diffs are not rendered by default.

docs/conf.py

Lines changed: 68 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,19 @@
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',
14+
"sphinx.ext.autodoc",
15+
"sphinx.ext.intersphinx",
1516
#'sphinx.ext.napoleon'
16-
'sphinx.ext.todo',
17+
"sphinx.ext.todo",
1718
]
1819

1920
# Uncomment the below if you use native CircuitPython modules such as
@@ -22,29 +23,36 @@
2223
# autodoc_mock_imports = ["digitalio", "busio", "micropython", "adafruit_bus_device.spi_device", "adafruit_bus_device"]
2324

2425

25-
intersphinx_mapping = {'python': ('https://docs.python.org/3.4', None),'BusDevice': ('https://circuitpython.readthedocs.io/projects/busdevice/en/latest/', None),'CircuitPython': ('https://circuitpython.readthedocs.io/en/latest/', None)}
26+
intersphinx_mapping = {
27+
"python": ("https://docs.python.org/3.4", None),
28+
"BusDevice": (
29+
"https://circuitpython.readthedocs.io/projects/busdevice/en/latest/",
30+
None,
31+
),
32+
"CircuitPython": ("https://circuitpython.readthedocs.io/en/latest/", None),
33+
}
2634

2735
# Add any paths that contain templates here, relative to this directory.
28-
templates_path = ['_templates']
36+
templates_path = ["_templates"]
2937

30-
source_suffix = '.rst'
38+
source_suffix = ".rst"
3139

3240
# The master toctree document.
33-
master_doc = 'index'
41+
master_doc = "index"
3442

3543
# General information about the project.
36-
project = u'Adafruit rfm9x Library'
37-
copyright = u'2018 Tony DiCola'
38-
author = u'Tony DiCola'
44+
project = u"Adafruit rfm9x Library"
45+
copyright = u"2018 Tony DiCola"
46+
author = u"Tony DiCola"
3947

4048
# The version info for the project you're documenting, acts as replacement for
4149
# |version| and |release|, also used in various other places throughout the
4250
# built documents.
4351
#
4452
# The short X.Y version.
45-
version = u'1.0'
53+
version = u"1.0"
4654
# The full version, including alpha/beta/rc tags.
47-
release = u'1.0'
55+
release = u"1.0"
4856

4957
# The language for content autogenerated by Sphinx. Refer to documentation
5058
# for a list of supported languages.
@@ -56,7 +64,7 @@
5664
# List of patterns, relative to source directory, that match files and
5765
# directories to ignore when looking for source files.
5866
# This patterns also effect to html_static_path and html_extra_path
59-
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store', '.env', 'CODE_OF_CONDUCT.md']
67+
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store", ".env", "CODE_OF_CONDUCT.md"]
6068

6169
# The reST default role (used for this markup: `text`) to use for all
6270
# documents.
@@ -68,7 +76,7 @@
6876
add_function_parentheses = True
6977

7078
# The name of the Pygments (syntax highlighting) style to use.
71-
pygments_style = 'sphinx'
79+
pygments_style = "sphinx"
7280

7381
# If true, `todo` and `todoList` produce output, else they produce nothing.
7482
todo_include_todos = False
@@ -83,68 +91,76 @@
8391
# The theme to use for HTML and HTML Help pages. See the documentation for
8492
# a list of builtin themes.
8593
#
86-
on_rtd = os.environ.get('READTHEDOCS', None) == 'True'
94+
on_rtd = os.environ.get("READTHEDOCS", None) == "True"
8795

8896
if not on_rtd: # only import and set the theme if we're building docs locally
8997
try:
9098
import sphinx_rtd_theme
91-
html_theme = 'sphinx_rtd_theme'
92-
html_theme_path = [sphinx_rtd_theme.get_html_theme_path(), '.']
99+
100+
html_theme = "sphinx_rtd_theme"
101+
html_theme_path = [sphinx_rtd_theme.get_html_theme_path(), "."]
93102
except:
94-
html_theme = 'default'
95-
html_theme_path = ['.']
103+
html_theme = "default"
104+
html_theme_path = ["."]
96105
else:
97-
html_theme_path = ['.']
106+
html_theme_path = ["."]
98107

99108
# Add any paths that contain custom static files (such as style sheets) here,
100109
# relative to this directory. They are copied after the builtin static files,
101110
# so a file named "default.css" will overwrite the builtin "default.css".
102-
html_static_path = ['_static']
111+
html_static_path = ["_static"]
103112

104113
# The name of an image file (relative to this directory) to use as a favicon of
105114
# the docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
106115
# pixels large.
107116
#
108-
html_favicon = '_static/favicon.ico'
117+
html_favicon = "_static/favicon.ico"
109118

110119
# Output file base name for HTML help builder.
111-
htmlhelp_basename = 'AdafruitRfm9xLibrarydoc'
120+
htmlhelp_basename = "AdafruitRfm9xLibrarydoc"
112121

113122
# -- Options for LaTeX output ---------------------------------------------
114123

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

133139
# Grouping the document tree into LaTeX files. List of tuples
134140
# (source start file, target name, title,
135141
# author, documentclass [howto, manual, or own class]).
136142
latex_documents = [
137-
(master_doc, 'Adafruitrfm9xLibrary.tex', u'Adafruitrfm9x Library Documentation',
138-
author, 'manual'),
143+
(
144+
master_doc,
145+
"Adafruitrfm9xLibrary.tex",
146+
u"Adafruitrfm9x Library Documentation",
147+
author,
148+
"manual",
149+
),
139150
]
140151

141152
# -- Options for manual page output ---------------------------------------
142153

143154
# One entry per manual page. List of tuples
144155
# (source start file, name, description, authors, manual section).
145156
man_pages = [
146-
(master_doc, 'Adafruitrfm9xlibrary', u'Adafruit rfm9x Library Documentation',
147-
[author], 1)
157+
(
158+
master_doc,
159+
"Adafruitrfm9xlibrary",
160+
u"Adafruit rfm9x Library Documentation",
161+
[author],
162+
1,
163+
)
148164
]
149165

150166
# -- Options for Texinfo output -------------------------------------------
@@ -153,7 +169,13 @@
153169
# (source start file, target name, title, author,
154170
# dir menu entry, description, category)
155171
texinfo_documents = [
156-
(master_doc, 'Adafruitrfm9xLibrary', u'Adafruit rfm9x Library Documentation',
157-
author, 'Adafruitrfm9xLibrary', 'One line description of project.',
158-
'Miscellaneous'),
172+
(
173+
master_doc,
174+
"Adafruitrfm9xLibrary",
175+
u"Adafruit rfm9x Library Documentation",
176+
author,
177+
"Adafruitrfm9xLibrary",
178+
"One line description of project.",
179+
"Miscellaneous",
180+
),
159181
]

examples/rfm9x_rpi_interrupt.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,23 +13,23 @@
1313

1414
# setup interrupt callback function
1515
def rfm9x_callback(rfm9x_irq):
16-
global packet_received #pylint: disable=global-statement
17-
print("IRQ detected ",rfm9x_irq, rfm9x.rx_done)
16+
global packet_received # pylint: disable=global-statement
17+
print("IRQ detected ", rfm9x_irq, rfm9x.rx_done)
1818
# check to see if this was a rx interrupt - ignore tx
1919
if rfm9x.rx_done:
20-
packet = rfm9x.receive(timeout = None)
20+
packet = rfm9x.receive(timeout=None)
2121
if packet is not None:
2222
packet_received = True
2323
# Received a packet!
2424
# Print out the raw bytes of the packet:
25-
print('Received (raw bytes): {0}'.format(packet))
25+
print("Received (raw bytes): {0}".format(packet))
2626
print([hex(x) for x in packet])
27-
print('RSSI: {0}'.format(rfm9x.rssi))
27+
print("RSSI: {0}".format(rfm9x.rssi))
2828

2929

3030
# Define radio parameters.
3131
RADIO_FREQ_MHZ = 915.0 # Frequency of the radio in Mhz. Must match your
32-
# module! Can be a value like 915.0, 433.0, etc.
32+
# module! Can be a value like 915.0, 433.0, etc.
3333

3434
# Define pins connected to the chip, use these if wiring up the breakout according to the guide:
3535
CS = digitalio.DigitalInOut(board.CE1)
@@ -51,25 +51,25 @@ def rfm9x_callback(rfm9x_irq):
5151
# configure the interrupt pin and event handling.
5252
RFM9X_G0 = 22
5353
io.setmode(io.BCM)
54-
io.setup(RFM9X_G0, io.IN,pull_up_down=io.PUD_DOWN) # activate input
55-
io.add_event_detect(RFM9X_G0,io.RISING)
56-
io.add_event_callback(RFM9X_G0,rfm9x_callback)
54+
io.setup(RFM9X_G0, io.IN, pull_up_down=io.PUD_DOWN) # activate input
55+
io.add_event_detect(RFM9X_G0, io.RISING)
56+
io.add_event_callback(RFM9X_G0, rfm9x_callback)
5757

5858
packet_received = False
5959
# Send a packet. Note you can only send a packet up to 252 bytes in length.
6060
# This is a limitation of the radio packet size, so if you need to send larger
6161
# amounts of data you will need to break it into smaller send calls. Each send
6262
# call will wait for the previous one to finish before continuing.
63-
rfm9x.send(bytes("Hello world!\r\n","utf-8"), keep_listening = True)
64-
print('Sent Hello World message!')
63+
rfm9x.send(bytes("Hello world!\r\n", "utf-8"), keep_listening=True)
64+
print("Sent Hello World message!")
6565

6666
# Wait to receive packets. Note that this library can't receive data at a fast
6767
# rate, in fact it can only receive and process one 252 byte packet at a time.
6868
# This means you should only use this for low bandwidth scenarios, like sending
6969
# and receiving a single message at a time.
70-
print('Waiting for packets...')
70+
print("Waiting for packets...")
7171
while True:
72-
time.sleep(.1)
72+
time.sleep(0.1)
7373
if packet_received:
74-
print('received message!')
74+
print("received message!")
7575
packet_received = False

examples/rfm9x_simpletest.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
# Define radio parameters.
1111
RADIO_FREQ_MHZ = 915.0 # Frequency of the radio in Mhz. Must match your
12-
# module! Can be a value like 915.0, 433.0, etc.
12+
# module! Can be a value like 915.0, 433.0, etc.
1313

1414
# Define pins connected to the chip, use these if wiring up the breakout according to the guide:
1515
CS = digitalio.DigitalInOut(board.D5)
@@ -40,36 +40,36 @@
4040
# This is a limitation of the radio packet size, so if you need to send larger
4141
# amounts of data you will need to break it into smaller send calls. Each send
4242
# call will wait for the previous one to finish before continuing.
43-
rfm9x.send(bytes("Hello world!\r\n","utf-8"))
44-
print('Sent Hello World message!')
43+
rfm9x.send(bytes("Hello world!\r\n", "utf-8"))
44+
print("Sent Hello World message!")
4545

4646
# Wait to receive packets. Note that this library can't receive data at a fast
4747
# rate, in fact it can only receive and process one 252 byte packet at a time.
4848
# This means you should only use this for low bandwidth scenarios, like sending
4949
# and receiving a single message at a time.
50-
print('Waiting for packets...')
50+
print("Waiting for packets...")
5151

5252
while True:
5353
packet = rfm9x.receive()
5454
# Optionally change the receive timeout from its default of 0.5 seconds:
55-
#packet = rfm9x.receive(timeout=5.0)
55+
# packet = rfm9x.receive(timeout=5.0)
5656
# If no packet was received during the timeout then None is returned.
5757
if packet is None:
5858
# Packet has not been received
5959
LED.value = False
60-
print('Received nothing! Listening again...')
60+
print("Received nothing! Listening again...")
6161
else:
6262
# Received a packet!
6363
LED.value = True
6464
# Print out the raw bytes of the packet:
65-
print('Received (raw bytes): {0}'.format(packet))
65+
print("Received (raw bytes): {0}".format(packet))
6666
# And decode to ASCII text and print it too. Note that you always
6767
# receive raw bytes and need to convert to a text format like ASCII
6868
# if you intend to do string processing on your data. Make sure the
6969
# sending side is sending ASCII data before you try to decode!
70-
packet_text = str(packet, 'ascii')
71-
print('Received (ASCII): {0}'.format(packet_text))
70+
packet_text = str(packet, "ascii")
71+
print("Received (ASCII): {0}".format(packet_text))
7272
# Also read the RSSI (signal strength) of the last received message and
7373
# print it.
7474
rssi = rfm9x.rssi
75-
print('Received signal strength: {0} dB'.format(rssi))
75+
print("Received signal strength: {0} dB".format(rssi))

examples/rfm9x_transmit.py

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@
88
import adafruit_rfm9x
99

1010
# set the time interval (seconds) for sending packets
11-
transmit_interval=10
11+
transmit_interval = 10
1212

1313
# Define radio parameters.
14-
RADIO_FREQ_MHZ = 915.0 # Frequency of the radio in Mhz. Must match your
15-
# module! Can be a value like 915.0, 433.0, etc.
14+
RADIO_FREQ_MHZ = 915.0 # Frequency of the radio in Mhz. Must match your
15+
# module! Can be a value like 915.0, 433.0, etc.
1616

1717
# Define pins connected to the chip.
18-
CS = digitalio.DigitalInOut(board.CE1)
18+
CS = digitalio.DigitalInOut(board.CE1)
1919
RESET = digitalio.DigitalInOut(board.D25)
2020

2121
# Initialize SPI bus.
@@ -34,27 +34,27 @@
3434

3535
# initialize counter
3636
counter = 0
37-
#send a broadcast mesage
38-
rfm9x.send(bytes("message number {}".format(counter),"UTF-8"))
37+
# send a broadcast mesage
38+
rfm9x.send(bytes("message number {}".format(counter), "UTF-8"))
3939

4040
# Wait to receive packets.
41-
print('Waiting for packets...')
42-
#initialize flag and timer
43-
send_reading=False
44-
time_now=time.monotonic()
41+
print("Waiting for packets...")
42+
# initialize flag and timer
43+
send_reading = False
44+
time_now = time.monotonic()
4545
while True:
4646
# Look for a new packet - wait up to 5 seconds:
4747
packet = rfm9x.receive(timeout=5.0)
4848
# If no packet was received during the timeout then None is returned.
4949
if packet is not None:
5050
# Received a packet!
5151
# Print out the raw bytes of the packet:
52-
print('Received (raw bytes): {0}'.format(packet))
52+
print("Received (raw bytes): {0}".format(packet))
5353
# send reading after any packet received
54-
if time.monotonic()-time_now>transmit_interval:
55-
#reset timeer
56-
time_now=time.monotonic()
57-
#clear flag to send data
58-
send_reading=False
54+
if time.monotonic() - time_now > transmit_interval:
55+
# reset timeer
56+
time_now = time.monotonic()
57+
# clear flag to send data
58+
send_reading = False
5959
counter = counter + 1
60-
rfm9x.send(bytes("message number {}".format(counter),"UTF-8"))
60+
rfm9x.send(bytes("message number {}".format(counter), "UTF-8"))

0 commit comments

Comments
 (0)