pydantic / pydantic-extra-types

Extra Pydantic types.
MIT License
176 stars 47 forks source link

Replace try-except block by if-else statement #192

Closed maxsos closed 2 months ago

maxsos commented 2 months ago

Description:

The current code uses a try-except block to handle a potential KeyError when looking up a color value in the COLORS_BY_VALUE and COLORS_BY_NAME dictionary:

Proposed Change: Refactor the code to use an if-else conditional check instead of a try-except block. This change improves code readability and leverages a more predictable conditional flow:

Benefits:

Impact: This change is expected to maintain the existing functionality while improving code clarity.

Please let me know if there are any specific tests or cases you would like me to address in this refactoring.

Thank you!

codecov[bot] commented 2 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

:loudspeaker: Thoughts on this report? Let us know!