10000 python: support defining enum member descriptions using docstrings in modules by helderco · Pull Request #10600 · dagger/dagger · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

python: support defining enum member descriptions using docstrings in modules #10600

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 23, 2025

Conversation

helderco
Copy link
Contributor
@helderco helderco commented Jun 17, 2025

Been meaning to do this for a while. Rather than requiring our custom class for descriptions, users can use docstrings now:

Before

import dagger

@dagger.enum_type
class Options(dagger.Enum):
    ONE = "ONE", "The first value"
    TWO = "TWO", "The second value"

After

import enum
import dagger

@dagger.enum_type
class Options(enum.Enum):
    ONE = "ONE"
    """The first value"""
    
    TWO = "TWO"
    """The second value"""

@helderco helderco requested review from a team as code owners June 17, 2025 17:25
@helderco helderco force-pushed the python-enum-docstrings branch from 819d933 to 38d675b Compare June 17, 2025 17:37
@helderco helderco requested a review from jedevc June 21, 2025 17:31
@helderco helderco force-pushed the python-enum-docstrings branch from 38d675b to 0cb0262 Compare June 21, 2025 18:55
helderco added 3 commits June 23, 2025 10:56
Signed-off-by: Helder Correia <174525+helderco@users.noreply.github.com>
Signed-off-by: Helder Correia <174525+helderco@users.noreply.github.com>
Signed-off-by: Helder Correia <174525+helderco@users.noreply.github.com>
@helderco helderco force-pushed the python-enum-docstrings branch from 53b0d5f to 18655de Compare June 23, 2025 10:57
.with_exposed_port(bind)
.as_service()
.as_service(args=["uv", "run", "python", "-m", "http.server", str(bind)])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BEGONE 🎉

Thought we got all of these ages ago, I'm so glad we deprecated this pattern 😁

@jedevc jedevc added this to the v0.18.11 milestone Jun 23, 2025
@helderco helderco merged commit 94e41c7 into dagger:main Jun 23, 2025
57 checks passed
@helderco helderco deleted the python-enum-docstrings branch June 23, 2025 11:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0