microsoft / microsoft/pxt-microbit
enum within namespace doesn't work in Python
Open
Nobody has claimed this yet.
P2
python
tsToPy
- Dominant language
- TypeScript
- Stars
- 804
- Forks
- 721
- Avg merge
- 2d 9h
- Merged PRs (30d)
- 2
Description
This typescript:
namespace foo {
export enum bar {
Zero,
One,
Two
}
}
input.onButtonPressed(Button.A, function () {
basic.showNumber(foo.bar.Two)
})
converts to this Python:
@namespace
class foo:
class bar(Enum):
Zero = 0
One = 1
Two = 2
def on_button_pressed_a():
basic.show_number(foo.bar.Two)
input.on_button_pressed(Button.A, on_button_pressed_a)
with these errors:

Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the TypeScript namespace and enum example in the issue, then reproduce the generated Python and its errors. Trace the TypeScript-to-Python conversion entry point and compare it with other namespace or enum cases; done means the example generates valid Python and foo.bar.Two works without errors.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, typescript
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100