Message named pkg/Duration with field builtin_interfaces/Duration is invalid
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 55/100
Direzione di ricerca
Riproducete il problema con un pacchetto di messaggi contenente pkg/Duration e un campo builtin_interfaces/Duration, quindi esaminate l'output build/stamped_msgs/rosidl_generator_py/stamped_msgs/msg/_duration.py. Tracciate il codice del generatore che produce gli import in conflitto, aggiornate il comportamento di generazione in modo che il nome del messaggio non venga oscurato ed eseguite i controlli mypy e flake8 segnalati per confermare che il codice generato sia valido.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Generated by Generative AI
No response
Operating System:
Linux
ROS version or commit hash:
rolling
RMW implementation (if applicable):
No response
RMW Configuration (if applicable):
No response
Client library (if applicable):
No response
'ros2 doctor --report' output
No response
Steps to reproduce issue
- Create a message package
pkgcontaining a message type namedDurationwith a field of typebuiltin_interfaces/Duration. - Compile the workspace and inspect the generated Python code.
- Run mypy tests and flake8
Expected behavior
Message type pkg/Duration should be valid.
Actual behavior
The generated message Python code is invalid:
27: /root/target_ws/build/stamped_msgs/rosidl_generator_py/stamped_msgs/msg/_duration.py:87:1: F811 redefinition of unused 'Duration' from line 20
27: class Duration(rosidl_pycommon.interface_base_classes.BaseMessage, metaclass=Metaclass_Duration):
27: ^
27:
27: 1 F811 redefinition of unused 'Duration' from line 20
30: /root/target_ws/build/stamped_msgs/rosidl_generator_py/stamped_msgs/msg/_duration.py:87:1: error: Name "Duration" already defined (possibly by an import) [no-redef]
30: /root/target_ws/build/stamped_msgs/rosidl_generator_py/stamped_msgs/msg/_duration.py: note: In member "__eq__" of class "Duration":
30: /root/target_ws/build/stamped_msgs/rosidl_generator_py/stamped_msgs/msg/_duration.py:151:27: error: "Duration" has no attribute "header" [attr-defined]
30: /root/target_ws/build/stamped_msgs/rosidl_generator_py/stamped_msgs/msg/_duration.py:153:25: error: "Duration" has no attribute "data" [attr-defined]
30: Found 3 errors in 1 file (checked 46 source files)
Additional information
Indeed, there are multiple places in the generated code that do:
from a.msg import b
But if the message is named pkg.Duration and the type of one of its fields is builtin_interfaces.Duration, then this import shadows the actual pkg.Duration and the code gets either confused, or even invalid.
I think all usages of from a.msg import b should be replaced by import a.msg; .... a.msg.b in the generated code. This way, the name collisions would not happen.
- Lingua principale
- EmberScript
- Stelle
- 26
- Fork
- 68
- Merge medio
- 2g 13h
- PR unite (30g)
- 1
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di ros2/rosidl_python
-
enhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
ros2/rosidl_python#255 · 1 reazione ·
-
bug
Difficoltà 3/5 1-2 giorni Idoneità per principianti 56/100
ros2/rosidl_python#264 · 2 commenti ·
-
enhancement
Difficoltà 3/5 1-2 giorni Idoneità per principianti 35/100
ros2/rosidl_python#242 ·
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 32/100
ros2/rosidl_python#219 · 2 commenti ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
ros2/rosidl_python#217 · 2 commenti ·
Tutte le issue di ros2/rosidl_python
Issue simili
-
[Bug]: classify_items.py cron script never includes its own required JSON schema in the prompt Apertacomp/cron P2 sweeper:risk-automation type/bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
NousResearch/hermes-agent#117792 · 1 commento ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
bancolombia/sentinel#20 ·
-
optimization optimization:agents-md-curator
Difficoltà 2/5 1-3 ore Idoneità per principianti 86/100
githubnext/gh-aw-cao#13143 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
-
chore
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
alunduil/woodland-generators#669 ·