Skip to content

Commit

Permalink
Fix and improve type annotations (#47)
Browse files Browse the repository at this point in the history
Type annotations make the code easier to understand. It can also be
checked with pyright. (Suggestion: check with pyright in pre-commit
workflow.)
- Add type annotations to cimgen and all lang_pack.py
- Remove unused functions
- Fix and improve comments 
- Fix ruff warnings for modernpython
- Unify use of partials for cpp, rename lang_pack to langPack
- Rename functions, parameters and variables to fix sonar issues
- Add function get_base_class to all lang_pack.py (replacing dictionary
base and function location)
- Simplified template file handling for java, javascript and python
  • Loading branch information
m-mirz authored Dec 27, 2024
2 parents 7538ec2 + 68c6b84 commit 3b44357
Show file tree
Hide file tree
Showing 17 changed files with 504 additions and 503 deletions.
9 changes: 5 additions & 4 deletions cimgen/build.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import argparse
import importlib
import os
from types import ModuleType

from cimgen import cimgen


def build():
def build() -> None:
parser = argparse.ArgumentParser(description="Generate some CIM classes.")
parser.add_argument("--outdir", type=str, help="The output directory", required=True)
parser.add_argument("--schemadir", type=str, help="The schema directory", required=True)
parser.add_argument("--langdir", type=str, help="The langpack directory", required=True)
parser.add_argument("--langdir", type=str, help="The language pack directory", required=True)
parser.add_argument(
"--cgmes_version",
type=str,
Expand All @@ -19,9 +20,9 @@ def build():
)
args = parser.parse_args()

langPack = importlib.import_module(f"cimgen.languages.{args.langdir}.lang_pack")
lang_pack: ModuleType = importlib.import_module(f"cimgen.languages.{args.langdir}.lang_pack")
schema_path = os.path.join(os.getcwd(), args.schemadir)
cimgen.cim_generate(schema_path, args.outdir, args.cgmes_version, langPack)
cimgen.cim_generate(schema_path, args.outdir, args.cgmes_version, lang_pack)


if __name__ == "__main__":
Expand Down
Loading

0 comments on commit 3b44357

Please sign in to comment.