← index #17453Issue #16609
Off-topic · high · value 2.434
QUERY · ISSUE

micropython.const inconsistent behaviour in class

openby konomikittenopened 2025-06-07updated 2025-06-08
bug

Port, board and/or hardware

Waveshare ESP32-C3-Zero Development Board

MicroPython version

MicroPython v1.25.0 on 2025-04-15; ESP32C3 module with ESP32C3

Reproduction

with_const.py

from micropython import const

class HelloWorld:
    TEST = const("Hello World!")

    def __init__(self):
        print(TEST)
>>> import with_const
>>> hello_world = with_const.HelloWorld()
Hello World!
>>>

without_const.py

class HelloWorld:
    TEST = "Hello World!"

    def __init__(self):
        print(TEST)
>>> import without_const
>>> hello_world = without_const.HelloWorld()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "without_const.py", line 5, in __init__
NameError: name 'TEST' isn't defined
>>>

I wouldn't have noticed that I wasn't properly referencing my class constant variable if it wasn't for PyLint telling me I was making mistakes. This seems like a bug?

Expected behaviour

I expected the example using micropython.const() to error.

Observed behaviour

There is no error.

Additional Information

No, I've provided everything above.

Code of Conduct

Yes, I agree

CANDIDATE · ISSUE

TypeError: unexpected keyword argument 'sideset_count'

closedby sidd-kishanopened 2025-01-19updated 2025-01-19
bug

Port, board and/or hardware

rp2

MicroPython version

MicroPython v1.24.1 on 2024-11-29; Pi Pico Board

Reproduction

`import rp2

Define the PIO program

@rp2.asm_pio(sideset_init=rp2.PIO.OUT_HIGH, autopush=True, push_thresh=32, sideset_count=3)
def pio_program():
wait(0,gpio,5).side(7)

print("Hello World")
`

Expected behaviour

Expected to print "Hello World"

Observed behaviour

This unexpected error occurs: -

TypeError: unexpected keyword argument 'sideset_count'

Additional Information

No, I've provided everything above.

Code of Conduct

Yes, I agree

Keyboard

j / / n
next pair
k / / p
previous pair
1 / / h
show query pane
2 / / l
show candidate pane
c
copy suggested comment
r
toggle reasoning
g i
go to index
?
show this help
esc
close overlays

press ? or esc to close

copied