← index #15776Issue #17075
Off-topic · high · value 2.977
QUERY · ISSUE

RP2 build, doc strings, help()

openby thestumbleropened 2024-09-03updated 2024-11-22
bug

Port, board and/or hardware

rp2 pico

MicroPython version

MicroPython v1.24.0-preview.278.g5e692d046.dirty on 2024-09-03; RP2040

I have set MICROPY_ENABLE_DOC_STRING (1) in mpconfigboard.h

When building this way, I can clearly see, and print, __doc__ for each class. But the help() function doesn't return the docstring like it does in Python on the desktop.Also, there is only a __doc__ on a class -- on functions a doc string is not created regardless of the setting in mpconfigboard.h. Is this the expected behavior? Is this maybe unique to the RP2 port? I seem to remember this working on a STM32F4 board.

Reproduction

class Ocean:
  '''This is the Ocean Class.'''
  def __init__(self):
    pass
  def wave(self):
    '''Prints a wave.'''
    print('a wave')


Expected behaviour

Expected help(Ocean) or help(o) to show the doc string. Instead it shows what looks like dir(Ocean)

Expected help(o.wave) to show the doc string for the wave() function. Instead there is no doc string.

Observed behaviour

You can see the doc object on the class, but not on the function.
help() doesn't show the usual help output

Additional Information

No, I've provided everything above.

Code of Conduct

Yes, I agree

CANDIDATE · ISSUE

Syntax Error when using multiline f-strings on RP2040 with MicroPython v1.23.0

openby kpg141260opened 2025-04-04updated 2025-10-03
bugproposed-close

Port, board and/or hardware

RP2040 Raspberry Pi Pico

MicroPython version

MicroPython Version: v1.23.0 (2024-06-02)
RP2040 Platform: Raspberry Pi Pico
Python Version: MicroPython (RP2040)
Firmware: v1.23.0
Hardware: Raspberry Pi Pico (RP2040)

Reproduction

msg = (
    f'One ' 
    f'Two ' 
    f'Three'
)

print(msg)

Expected behaviour

The above code should print the concatenated string One Two Three without any syntax errors, similar to how it works in standard Python environments.

Observed behaviour

SyntaxError: invalid syntax

Additional Information

This issue persists even when re-typing the code, leading me to suspect it might be an issue with the way multiline f-strings are handled on this particular platform.

The issue can be resolved by concatenating the f-strings manually using +:

msg = (
    f'One ' +
    f'Two ' +
    f'Three'
)

print(msg)

Workaround:

Using string concatenation (as shown above) works, but this is not as elegant and adds unnecessary complexity compared to expected behaviour.

What else I have tried:

Testing with other Python environments (such as standard Python 3.x) shows that the multiline f-string works as expected.

This issue does not occur with simpler, single-line f-strings.
Ensuring no invisible characters or incorrect syntax in the code.

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