ponyorm / pony

Pony Object Relational Mapper
Apache License 2.0
3.58k stars 242 forks source link

Right way to do it #690

Closed pomponchik closed 9 months ago

pomponchik commented 9 months ago

Hello!

I was looking at the pony source code and I was confused by the following fragment:

https://github.com/ponyorm/pony/blob/6f7620c9e66a4b8d4f7f7ba4a456b733aab9f374/pony/utils/utils.py#L68C22-L68C22

Probably the more correct way to specify filtering exceptions that are defined in the package is not to work with names as with strings, but to ensure the correct inheritance hierarchy. You can declare a general exception like PonyException and inherit all other exceptions from it. And in this fragment, replace the work with strings with a simple check via isinstance.