From 2de14cf2b9a163ff2d4e5de2078d1a81c5edf1a4 Mon Sep 17 00:00:00 2001 From: Leon Haffmans <49658102+lord-haffi@users.noreply.github.com> Date: Fri, 2 Feb 2024 16:58:47 +0100 Subject: [PATCH] Sort `__all__` elements in `__init__.py` (#50) --- src/bo4e_generator/parser.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/bo4e_generator/parser.py b/src/bo4e_generator/parser.py index b363f4f..2cc2104 100644 --- a/src/bo4e_generator/parser.py +++ b/src/bo4e_generator/parser.py @@ -2,6 +2,7 @@ Contains code to generate pydantic v2 models from json schemas. Since the used tool doesn't support all features we need, we monkey patch some functions. """ +import itertools import re from pathlib import Path from typing import Sequence, Tuple, Type @@ -149,9 +150,8 @@ def bo4e_init_file_content(namespace: dict[str, SchemaMetadata], version: str) - init_file_content = INIT_FILE_COMMENT.strip().format(version=version) init_file_content += "\n\n__all__ = [\n" - for class_name in namespace: + for class_name in sorted(itertools.chain(namespace, ["__version__"])): init_file_content += f' "{class_name}",\n' - init_file_content += ' "__version__",\n' init_file_content += "]\n\n" for schema_metadata in namespace.values():