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 <angus@redyak.com.au>
This commit is contained in:
parent
00855eeb36
commit
861fbf6ab5
|
@ -1,5 +1,9 @@
|
||||||
# flash LED #1 using inline assembler
|
# flash LED #1 using inline assembler
|
||||||
# this version is overly verbose and uses word stores
|
# this version is overly verbose and uses word stores
|
||||||
|
#
|
||||||
|
# ruff: noqa: F821 - @asm_thumb decorator adds names to function scope
|
||||||
|
|
||||||
|
|
||||||
@micropython.asm_thumb
|
@micropython.asm_thumb
|
||||||
def flash_led(r0):
|
def flash_led(r0):
|
||||||
movw(r1, (stm.GPIOA + stm.GPIO_BSRRL) & 0xFFFF)
|
movw(r1, (stm.GPIOA + stm.GPIO_BSRRL) & 0xFFFF)
|
||||||
|
|
|
@ -1,3 +1,6 @@
|
||||||
|
# ruff: noqa: F821 - @asm_thumb decorator adds names to function scope
|
||||||
|
|
||||||
|
|
||||||
@micropython.asm_thumb
|
@micropython.asm_thumb
|
||||||
def asm_sum_words(r0, r1):
|
def asm_sum_words(r0, r1):
|
||||||
# r0 = len
|
# r0 = len
|
||||||
|
|
|
@ -1,3 +1,7 @@
|
||||||
# Implemented in Python to support keyword arguments
|
# Implemented in Python to support keyword arguments
|
||||||
|
|
||||||
|
# ruff: noqa: F821 - this file is evaluated with C-defined names in scope
|
||||||
|
|
||||||
|
|
||||||
def open(stream, *, flags=0, cachesize=0, pagesize=0, minkeypage=0):
|
def open(stream, *, flags=0, cachesize=0, pagesize=0, minkeypage=0):
|
||||||
return _open(stream, flags, cachesize, pagesize, minkeypage)
|
return _open(stream, flags, cachesize, pagesize, minkeypage)
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
# This Python code will be merged with the C code in main.c
|
# This Python code will be merged with the C code in main.c
|
||||||
|
|
||||||
|
# ruff: noqa: F821 - this file is evaluated with C-defined names in scope
|
||||||
|
|
||||||
import array
|
import array
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
# Example using PIO to blink an LED and raise an IRQ at 1Hz.
|
# Example using PIO to blink an LED and raise an IRQ at 1Hz.
|
||||||
# Note: this does not work on Pico W because it uses Pin(25) for LED output.
|
# Note: this does not work on Pico W because it uses Pin(25) for LED output.
|
||||||
|
|
||||||
|
# ruff: noqa: F821 - @asm_pio decorator adds names to function scope
|
||||||
|
|
||||||
import time
|
import time
|
||||||
from machine import Pin
|
from machine import Pin
|
||||||
import rp2
|
import rp2
|
||||||
|
|
|
@ -5,6 +5,8 @@
|
||||||
# - using set_init and set_base
|
# - using set_init and set_base
|
||||||
# - using StateMachine.exec
|
# - using StateMachine.exec
|
||||||
|
|
||||||
|
# ruff: noqa: F821 - @asm_pio decorator adds names to function scope
|
||||||
|
|
||||||
import time
|
import time
|
||||||
from machine import Pin
|
from machine import Pin
|
||||||
import rp2
|
import rp2
|
||||||
|
|
|
@ -8,6 +8,8 @@
|
||||||
# - setting an irq handler for a StateMachine
|
# - setting an irq handler for a StateMachine
|
||||||
# - instantiating 2x StateMachine's with the same program and different pins
|
# - instantiating 2x StateMachine's with the same program and different pins
|
||||||
|
|
||||||
|
# ruff: noqa: F821 - @asm_pio decorator adds names to function scope
|
||||||
|
|
||||||
import time
|
import time
|
||||||
from machine import Pin
|
from machine import Pin
|
||||||
import rp2
|
import rp2
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
# Example of using PIO for PWM, and fading the brightness of an LED
|
# Example of using PIO for PWM, and fading the brightness of an LED
|
||||||
|
|
||||||
|
# ruff: noqa: F821 - @asm_pio decorator adds names to function scope
|
||||||
|
|
||||||
from machine import Pin
|
from machine import Pin
|
||||||
from rp2 import PIO, StateMachine, asm_pio
|
from rp2 import PIO, StateMachine, asm_pio
|
||||||
from time import sleep
|
from time import sleep
|
||||||
|
|
|
@ -8,6 +8,8 @@
|
||||||
# - PIO irq handler
|
# - PIO irq handler
|
||||||
# - using the second core via _thread
|
# - using the second core via _thread
|
||||||
|
|
||||||
|
# ruff: noqa: F821 - @asm_pio decorator adds names to function scope
|
||||||
|
|
||||||
import _thread
|
import _thread
|
||||||
from machine import Pin, UART
|
from machine import Pin, UART
|
||||||
from rp2 import PIO, StateMachine, asm_pio
|
from rp2 import PIO, StateMachine, asm_pio
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
# Example using PIO to create a UART TX interface
|
# Example using PIO to create a UART TX interface
|
||||||
|
|
||||||
|
# ruff: noqa: F821 - @asm_pio decorator adds names to function scope
|
||||||
|
|
||||||
from machine import Pin
|
from machine import Pin
|
||||||
from rp2 import PIO, StateMachine, asm_pio
|
from rp2 import PIO, StateMachine, asm_pio
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
# Example using PIO to drive a set of WS2812 LEDs.
|
# Example using PIO to drive a set of WS2812 LEDs.
|
||||||
|
|
||||||
|
# ruff: noqa: F821 - @asm_pio decorator adds names to function scope
|
||||||
|
|
||||||
import array, time
|
import array, time
|
||||||
from machine import Pin
|
from machine import Pin
|
||||||
import rp2
|
import rp2
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
# Example using PWM to fade an LED.
|
# Example using PWM to fade an LED.
|
||||||
# Note: this does not work on Pico W because it uses Pin(25) for LED output.
|
# Note: this does not work on Pico W because it uses Pin(25) for LED output.
|
||||||
|
|
||||||
|
# ruff: noqa: F821 - @asm_pio decorator adds names to function scope
|
||||||
|
|
||||||
import time
|
import time
|
||||||
from machine import Pin, PWM
|
from machine import Pin, PWM
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
# Test freezing inline-asm code.
|
# Test freezing inline-asm code.
|
||||||
|
|
||||||
|
# ruff: noqa: F821 - @asm_thumb decorator adds names to function scope
|
||||||
|
|
||||||
import micropython
|
import micropython
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue