I have a directory of JSON Schema files that's distributed with a python package. Some code in the package uses the schema files to validate data.
The way I'm currently loading the schema files is like so:
from importlib import resources
from myapp.schema import v1 as schema_v1
...
def _schema_file(self, uri: str):
return resources.files(schema_v1) / uri
But one thing I don't like: this requires sprinkling __init__.py files throughout the schema/ directory for the import statement to work. I'd rather the schema/ directory has just the schema files and nothing else.
Is there a better strategy I should be using? I'm definitely open to switching away from importlib if that's advisable, I know there are lots of options but haven't figured out which is the most favored these days.