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

Reoccurring pattern of usage try-except #83

Open
ovaar opened this issue Apr 20, 2021 · 0 comments
Open

Reoccurring pattern of usage try-except #83

ovaar opened this issue Apr 20, 2021 · 0 comments
Labels
code-quality General code quality related issues and PRs

Comments

@ovaar
Copy link

ovaar commented Apr 20, 2021

Describe the issue

I just came across the extensive usage of the following pattern, see screenshot, try-except to check whether a key exists in a dictionary. I want to propose the usage of configuration validators or use strictly defined record types such as dataclasses-json.

This can be re-written to the following to be more explicit and readable to the user.

if not "algorithm" in cfg:
  raise ...

algorithm_name = cfg["algorithm"]
if not algorithm_name in algorithms:
  raise ...

There is also a typo: Unkown should be Unknown in C3:ERROR:Unkown sampling method

Screenshots

image

@lazyoracle lazyoracle added the code-quality General code quality related issues and PRs label Apr 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
code-quality General code quality related issues and PRs
Projects
None yet
Development

No branches or pull requests

2 participants