Skip to content
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

Add enum parser #185

Merged
merged 7 commits into from
Nov 7, 2020
Merged

Add enum parser #185

merged 7 commits into from
Nov 7, 2020

Conversation

tomgrin10
Copy link
Contributor

The enum parser receives the enum type and parses the enum by its name.

Copy link
Owner

@sloria sloria left a comment

Choose a reason for hiding this comment

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

Thanks! This looks good. Just some nitpicking to address.

environs/__init__.py Outdated Show resolved Hide resolved
environs/__init__.py Outdated Show resolved Hide resolved
@tomgrin10
Copy link
Contributor Author

Applied the KeyError suggestion and added a bonus ignore_case argument :)

Copy link
Owner

@sloria sloria left a comment

Choose a reason for hiding this comment

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

Just a few more tiny changes

.gitignore Outdated Show resolved Hide resolved
environs/__init__.py Outdated Show resolved Hide resolved
tests/test_environs.py Show resolved Hide resolved
@tomgrin10
Copy link
Contributor Author

Updated the readme, and left a comment on the from error nitpick

Copy link
Owner

@sloria sloria left a comment

Choose a reason for hiding this comment

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

Looks good! I'll merge and release this soon when I'm off the clock

environs/__init__.py Outdated Show resolved Hide resolved
@env.parser_for("enum")
def enum_parser(value, choices):
@env.parser_for("choice")
def choice_parser(value, choices):
Copy link
Owner

Choose a reason for hiding this comment

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

thought (non-blocking): We might want to come up with a different example here since users would use env.enum for this use case rather than a custom parser.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think the example isn't that bad for now, this deserves a separate issue anyway.

@tomgrin10 tomgrin10 closed this Nov 4, 2020
@tomgrin10 tomgrin10 reopened this Nov 4, 2020
@sloria sloria merged commit 237ebdf into sloria:master Nov 7, 2020
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