Relative Content

Tag Archive for python-3.xdictionarypydanticpylint

Check for key in dictionary without magic value comparison

I’m using pydantic in a project to check file formatting for an object, as well as pylint for linting. Whenever I read a file with an invalid format, I want to raise an exception with a descriptive message. The code I’m using looks something like this: