Skip to content

Commit 861fbf6

Browse files
projectgusdpgeorge
authored andcommitted
examples: Mark asm, pio, etc. as noqa: F821 (undefined-name).
These files all use decorators (@asm_thumb, @asm_pio) that add names to the function scope, that the linter cannot see. It's useful to clear them in the file not in pyproject.toml as example code will be copied and adapted elsewhere, and those developers may also use Ruff (we hope!) Signed-off-by: Angus Gratton <[email protected]>
1 parent 00855ee commit 861fbf6

File tree

13 files changed

+31
-0
lines changed

13 files changed

+31
-0
lines changed

Diff for: examples/asmled.py

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# flash LED #1 using inline assembler
22
# this version is overly verbose and uses word stores
3+
#
4+
# ruff: noqa: F821 - @asm_thumb decorator adds names to function scope
5+
6+
37
@micropython.asm_thumb
48
def flash_led(r0):
59
movw(r1, (stm.GPIOA + stm.GPIO_BSRRL) & 0xFFFF)

Diff for: examples/asmsum.py

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# ruff: noqa: F821 - @asm_thumb decorator adds names to function scope
2+
3+
14
@micropython.asm_thumb
25
def asm_sum_words(r0, r1):
36
# r0 = len

Diff for: examples/natmod/btree/btree_py.py

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
# Implemented in Python to support keyword arguments
2+
3+
# ruff: noqa: F821 - this file is evaluated with C-defined names in scope
4+
5+
26
def open(stream, *, flags=0, cachesize=0, pagesize=0, minkeypage=0):
37
return _open(stream, flags, cachesize, pagesize, minkeypage)

Diff for: examples/natmod/features2/test.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# This Python code will be merged with the C code in main.c
22

3+
# ruff: noqa: F821 - this file is evaluated with C-defined names in scope
4+
35
import array
46

57

Diff for: examples/rp2/pio_1hz.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# Example using PIO to blink an LED and raise an IRQ at 1Hz.
22
# Note: this does not work on Pico W because it uses Pin(25) for LED output.
33

4+
# ruff: noqa: F821 - @asm_pio decorator adds names to function scope
5+
46
import time
57
from machine import Pin
68
import rp2

Diff for: examples/rp2/pio_exec.py

+2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
# - using set_init and set_base
66
# - using StateMachine.exec
77

8+
# ruff: noqa: F821 - @asm_pio decorator adds names to function scope
9+
810
import time
911
from machine import Pin
1012
import rp2

Diff for: examples/rp2/pio_pinchange.py

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
# - setting an irq handler for a StateMachine
99
# - instantiating 2x StateMachine's with the same program and different pins
1010

11+
# ruff: noqa: F821 - @asm_pio decorator adds names to function scope
12+
1113
import time
1214
from machine import Pin
1315
import rp2

Diff for: examples/rp2/pio_pwm.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Example of using PIO for PWM, and fading the brightness of an LED
22

3+
# ruff: noqa: F821 - @asm_pio decorator adds names to function scope
4+
35
from machine import Pin
46
from rp2 import PIO, StateMachine, asm_pio
57
from time import sleep

Diff for: examples/rp2/pio_uart_rx.py

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
# - PIO irq handler
99
# - using the second core via _thread
1010

11+
# ruff: noqa: F821 - @asm_pio decorator adds names to function scope
12+
1113
import _thread
1214
from machine import Pin, UART
1315
from rp2 import PIO, StateMachine, asm_pio

Diff for: examples/rp2/pio_uart_tx.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Example using PIO to create a UART TX interface
22

3+
# ruff: noqa: F821 - @asm_pio decorator adds names to function scope
4+
35
from machine import Pin
46
from rp2 import PIO, StateMachine, asm_pio
57

Diff for: examples/rp2/pio_ws2812.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Example using PIO to drive a set of WS2812 LEDs.
22

3+
# ruff: noqa: F821 - @asm_pio decorator adds names to function scope
4+
35
import array, time
46
from machine import Pin
57
import rp2

Diff for: examples/rp2/pwm_fade.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# Example using PWM to fade an LED.
22
# Note: this does not work on Pico W because it uses Pin(25) for LED output.
33

4+
# ruff: noqa: F821 - @asm_pio decorator adds names to function scope
5+
46
import time
57
from machine import Pin, PWM
68

Diff for: ports/qemu-arm/test-frzmpy/frozen_asm.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Test freezing inline-asm code.
22

3+
# ruff: noqa: F821 - @asm_thumb decorator adds names to function scope
4+
35
import micropython
46

57

0 commit comments

Comments
 (0)