half-orm-dev 1.0.0a9__tar.gz → 1.0.0a11__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (79) hide show
  1. {half_orm_dev-1.0.0a9/half_orm_dev.egg-info → half_orm_dev-1.0.0a11}/PKG-INFO +1 -1
  2. {half_orm_dev-1.0.0a9 → half_orm_dev-1.0.0a11}/half_orm_dev/modules.py +57 -8
  3. half_orm_dev-1.0.0a11/half_orm_dev/version.txt +1 -0
  4. {half_orm_dev-1.0.0a9 → half_orm_dev-1.0.0a11/half_orm_dev.egg-info}/PKG-INFO +1 -1
  5. half_orm_dev-1.0.0a9/half_orm_dev/version.txt +0 -1
  6. {half_orm_dev-1.0.0a9 → half_orm_dev-1.0.0a11}/AUTHORS +0 -0
  7. {half_orm_dev-1.0.0a9 → half_orm_dev-1.0.0a11}/LICENSE +0 -0
  8. {half_orm_dev-1.0.0a9 → half_orm_dev-1.0.0a11}/README.md +0 -0
  9. {half_orm_dev-1.0.0a9 → half_orm_dev-1.0.0a11}/half_orm_dev/__init__.py +0 -0
  10. {half_orm_dev-1.0.0a9 → half_orm_dev-1.0.0a11}/half_orm_dev/bootstrap_manager.py +0 -0
  11. {half_orm_dev-1.0.0a9 → half_orm_dev-1.0.0a11}/half_orm_dev/cli/__init__.py +0 -0
  12. {half_orm_dev-1.0.0a9 → half_orm_dev-1.0.0a11}/half_orm_dev/cli/commands/__init__.py +0 -0
  13. {half_orm_dev-1.0.0a9 → half_orm_dev-1.0.0a11}/half_orm_dev/cli/commands/apply.py +0 -0
  14. {half_orm_dev-1.0.0a9 → half_orm_dev-1.0.0a11}/half_orm_dev/cli/commands/bootstrap.py +0 -0
  15. {half_orm_dev-1.0.0a9 → half_orm_dev-1.0.0a11}/half_orm_dev/cli/commands/check.py +0 -0
  16. {half_orm_dev-1.0.0a9 → half_orm_dev-1.0.0a11}/half_orm_dev/cli/commands/clone.py +0 -0
  17. {half_orm_dev-1.0.0a9 → half_orm_dev-1.0.0a11}/half_orm_dev/cli/commands/init.py +0 -0
  18. {half_orm_dev-1.0.0a9 → half_orm_dev-1.0.0a11}/half_orm_dev/cli/commands/migrate.py +0 -0
  19. {half_orm_dev-1.0.0a9 → half_orm_dev-1.0.0a11}/half_orm_dev/cli/commands/patch.py +0 -0
  20. {half_orm_dev-1.0.0a9 → half_orm_dev-1.0.0a11}/half_orm_dev/cli/commands/release.py +0 -0
  21. {half_orm_dev-1.0.0a9 → half_orm_dev-1.0.0a11}/half_orm_dev/cli/commands/restore.py +0 -0
  22. {half_orm_dev-1.0.0a9 → half_orm_dev-1.0.0a11}/half_orm_dev/cli/commands/revert_migration.py +0 -0
  23. {half_orm_dev-1.0.0a9 → half_orm_dev-1.0.0a11}/half_orm_dev/cli/commands/set_git_origin.py +0 -0
  24. {half_orm_dev-1.0.0a9 → half_orm_dev-1.0.0a11}/half_orm_dev/cli/commands/sync.py +0 -0
  25. {half_orm_dev-1.0.0a9 → half_orm_dev-1.0.0a11}/half_orm_dev/cli/commands/todo.py +0 -0
  26. {half_orm_dev-1.0.0a9 → half_orm_dev-1.0.0a11}/half_orm_dev/cli/commands/undo.py +0 -0
  27. {half_orm_dev-1.0.0a9 → half_orm_dev-1.0.0a11}/half_orm_dev/cli/commands/update.py +0 -0
  28. {half_orm_dev-1.0.0a9 → half_orm_dev-1.0.0a11}/half_orm_dev/cli/commands/upgrade.py +0 -0
  29. {half_orm_dev-1.0.0a9 → half_orm_dev-1.0.0a11}/half_orm_dev/cli/main.py +0 -0
  30. {half_orm_dev-1.0.0a9 → half_orm_dev-1.0.0a11}/half_orm_dev/cli_extension.py +0 -0
  31. {half_orm_dev-1.0.0a9 → half_orm_dev-1.0.0a11}/half_orm_dev/database.py +0 -0
  32. {half_orm_dev-1.0.0a9 → half_orm_dev-1.0.0a11}/half_orm_dev/decorators.py +0 -0
  33. {half_orm_dev-1.0.0a9 → half_orm_dev-1.0.0a11}/half_orm_dev/file_executor.py +0 -0
  34. {half_orm_dev-1.0.0a9 → half_orm_dev-1.0.0a11}/half_orm_dev/hgit.py +0 -0
  35. {half_orm_dev-1.0.0a9 → half_orm_dev-1.0.0a11}/half_orm_dev/migration_manager.py +0 -0
  36. {half_orm_dev-1.0.0a9 → half_orm_dev-1.0.0a11}/half_orm_dev/migrations/0/17/1/00_move_to_hop.py +0 -0
  37. {half_orm_dev-1.0.0a9 → half_orm_dev-1.0.0a11}/half_orm_dev/migrations/0/17/1/01_txt_to_toml.py +0 -0
  38. {half_orm_dev-1.0.0a9 → half_orm_dev-1.0.0a11}/half_orm_dev/migrations/0/17/4/00_toml_dict_format.py +0 -0
  39. {half_orm_dev-1.0.0a9 → half_orm_dev-1.0.0a11}/half_orm_dev/migrations/0/17/4/01_add_bootstrap_table.py +0 -0
  40. {half_orm_dev-1.0.0a9 → half_orm_dev-1.0.0a11}/half_orm_dev/migrations/0/17/4/02_move_patches_to_subdirs.py +0 -0
  41. {half_orm_dev-1.0.0a9 → half_orm_dev-1.0.0a11}/half_orm_dev/migrations/0/17/5/01_update_pyproject_dependency.py +0 -0
  42. {half_orm_dev-1.0.0a9 → half_orm_dev-1.0.0a11}/half_orm_dev/migrations/0/18/0/00_add_async_support.py +0 -0
  43. {half_orm_dev-1.0.0a9 → half_orm_dev-1.0.0a11}/half_orm_dev/migrations/0/18/0/01_update_default_tests.py +0 -0
  44. {half_orm_dev-1.0.0a9 → half_orm_dev-1.0.0a11}/half_orm_dev/migrations/hop/BREAKING_CHANGES-1.0.0.md +0 -0
  45. {half_orm_dev-1.0.0a9 → half_orm_dev-1.0.0a11}/half_orm_dev/patch_manager.py +0 -0
  46. {half_orm_dev-1.0.0a9 → half_orm_dev-1.0.0a11}/half_orm_dev/patch_validator.py +0 -0
  47. {half_orm_dev-1.0.0a9 → half_orm_dev-1.0.0a11}/half_orm_dev/patches/0/1/0/00_half_orm_meta.database.sql +0 -0
  48. {half_orm_dev-1.0.0a9 → half_orm_dev-1.0.0a11}/half_orm_dev/patches/0/1/0/01_alter_half_orm_meta.hop_release.sql +0 -0
  49. {half_orm_dev-1.0.0a9 → half_orm_dev-1.0.0a11}/half_orm_dev/patches/0/1/0/02_half_orm_meta.view.hop_penultimate_release.sql +0 -0
  50. {half_orm_dev-1.0.0a9 → half_orm_dev-1.0.0a11}/half_orm_dev/patches/log +0 -0
  51. {half_orm_dev-1.0.0a9 → half_orm_dev-1.0.0a11}/half_orm_dev/patches/sql/half_orm_meta.sql +0 -0
  52. {half_orm_dev-1.0.0a9 → half_orm_dev-1.0.0a11}/half_orm_dev/release_file.py +0 -0
  53. {half_orm_dev-1.0.0a9 → half_orm_dev-1.0.0a11}/half_orm_dev/release_manager.py +0 -0
  54. {half_orm_dev-1.0.0a9 → half_orm_dev-1.0.0a11}/half_orm_dev/repo.py +0 -0
  55. {half_orm_dev-1.0.0a9 → half_orm_dev-1.0.0a11}/half_orm_dev/scripts/repair-metadata.py +0 -0
  56. {half_orm_dev-1.0.0a9 → half_orm_dev-1.0.0a11}/half_orm_dev/templates/.gitignore +0 -0
  57. {half_orm_dev-1.0.0a9 → half_orm_dev-1.0.0a11}/half_orm_dev/templates/MANIFEST.in +0 -0
  58. {half_orm_dev-1.0.0a9 → half_orm_dev-1.0.0a11}/half_orm_dev/templates/README +0 -0
  59. {half_orm_dev-1.0.0a9 → half_orm_dev-1.0.0a11}/half_orm_dev/templates/conftest_template +0 -0
  60. {half_orm_dev-1.0.0a9 → half_orm_dev-1.0.0a11}/half_orm_dev/templates/git-hooks/pre-commit +0 -0
  61. {half_orm_dev-1.0.0a9 → half_orm_dev-1.0.0a11}/half_orm_dev/templates/git-hooks/prepare-commit-msg +0 -0
  62. {half_orm_dev-1.0.0a9 → half_orm_dev-1.0.0a11}/half_orm_dev/templates/init_module_template +0 -0
  63. {half_orm_dev-1.0.0a9 → half_orm_dev-1.0.0a11}/half_orm_dev/templates/module_stub_template +0 -0
  64. {half_orm_dev-1.0.0a9 → half_orm_dev-1.0.0a11}/half_orm_dev/templates/module_template_1 +0 -0
  65. {half_orm_dev-1.0.0a9 → half_orm_dev-1.0.0a11}/half_orm_dev/templates/module_template_2 +0 -0
  66. {half_orm_dev-1.0.0a9 → half_orm_dev-1.0.0a11}/half_orm_dev/templates/module_template_3 +0 -0
  67. {half_orm_dev-1.0.0a9 → half_orm_dev-1.0.0a11}/half_orm_dev/templates/pyproject.toml +0 -0
  68. {half_orm_dev-1.0.0a9 → half_orm_dev-1.0.0a11}/half_orm_dev/templates/relation_test +0 -0
  69. {half_orm_dev-1.0.0a9 → half_orm_dev-1.0.0a11}/half_orm_dev/templates/sql_adapter +0 -0
  70. {half_orm_dev-1.0.0a9 → half_orm_dev-1.0.0a11}/half_orm_dev/templates/warning +0 -0
  71. {half_orm_dev-1.0.0a9 → half_orm_dev-1.0.0a11}/half_orm_dev/utils.py +0 -0
  72. {half_orm_dev-1.0.0a9 → half_orm_dev-1.0.0a11}/half_orm_dev.egg-info/SOURCES.txt +0 -0
  73. {half_orm_dev-1.0.0a9 → half_orm_dev-1.0.0a11}/half_orm_dev.egg-info/dependency_links.txt +0 -0
  74. {half_orm_dev-1.0.0a9 → half_orm_dev-1.0.0a11}/half_orm_dev.egg-info/entry_points.txt +0 -0
  75. {half_orm_dev-1.0.0a9 → half_orm_dev-1.0.0a11}/half_orm_dev.egg-info/requires.txt +0 -0
  76. {half_orm_dev-1.0.0a9 → half_orm_dev-1.0.0a11}/half_orm_dev.egg-info/top_level.txt +0 -0
  77. {half_orm_dev-1.0.0a9 → half_orm_dev-1.0.0a11}/pyproject.toml +0 -0
  78. {half_orm_dev-1.0.0a9 → half_orm_dev-1.0.0a11}/setup.cfg +0 -0
  79. {half_orm_dev-1.0.0a9 → half_orm_dev-1.0.0a11}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: half_orm_dev
3
- Version: 1.0.0a9
3
+ Version: 1.0.0a11
4
4
  Summary: half_orm development Framework.
5
5
  Author-email: Joël Maïzi <joel.maizi@collorg.org>
6
6
  License-Expression: GPL-3.0-or-later
@@ -423,18 +423,66 @@ def __get_inheritance_info(rel, package_name):
423
423
 
424
424
 
425
425
  def __get_fkeys(repo, class_name, module_path):
426
+ """Read the Fkeys dict from the module file using AST, without importing.
427
+
428
+ Importing via importlib requires the project package to be on sys.path,
429
+ which is not guaranteed during `hop migrate`. Parsing with ast reads
430
+ directly from the file on disk regardless of installation state.
431
+ """
432
+ if not os.path.exists(module_path):
433
+ return {}
426
434
  try:
427
- mod_path = module_path.replace(str(repo.base_dir), '').replace(os.path.sep, '.')[1:-3]
428
- mod = importlib.import_module(mod_path)
429
- importlib.reload(mod)
430
- cls = mod.__dict__[class_name]
431
- fkeys = cls.__dict__.get('Fkeys', {})
432
- return fkeys
433
- except ModuleNotFoundError:
435
+ import ast
436
+ source = utils.read(module_path)
437
+ tree = ast.parse(source)
438
+ for node in ast.walk(tree):
439
+ if isinstance(node, ast.ClassDef) and node.name == class_name:
440
+ for stmt in node.body:
441
+ if (isinstance(stmt, ast.Assign)
442
+ and len(stmt.targets) == 1
443
+ and isinstance(stmt.targets[0], ast.Name)
444
+ and stmt.targets[0].id == 'Fkeys'):
445
+ return ast.literal_eval(stmt.value)
446
+ except Exception:
434
447
  pass
435
448
  return {}
436
449
 
437
450
 
451
+ def __apply_fkey_aliases_to_doc(documentation: str, rel, existing_fkeys: dict) -> str:
452
+ """Replace the Fkeys block in the docstring using the developer's aliases.
453
+
454
+ For each constraint already aliased in existing_fkeys the alias is preserved.
455
+ New constraints (not yet aliased) fall back to the default rfk_/fk_ name.
456
+ This prevents spurious diffs when generate() runs automatically on branches
457
+ where the developer has already defined aliases.
458
+ """
459
+ import re
460
+ if not rel._ho_fkeys:
461
+ return documentation
462
+
463
+ # Invert existing_fkeys: constraint_name → alias (skip empty aliases)
464
+ aliases = {constraint: alias for alias, constraint in existing_fkeys.items() if alias}
465
+
466
+ lines = [" Fkeys = {"]
467
+ for constraint_name in rel._ho_fkeys:
468
+ if constraint_name in aliases:
469
+ key = aliases[constraint_name]
470
+ elif constraint_name.startswith('_reverse_fkey_'):
471
+ key = 'rfk_' + constraint_name[len('_reverse_fkey_'):]
472
+ else:
473
+ key = 'fk_' + constraint_name
474
+ lines.append(f" '{key}': '{constraint_name}',")
475
+ lines.append(" }")
476
+ new_block = '\n'.join(lines)
477
+
478
+ return re.sub(
479
+ r' Fkeys = \{[^}]*\}',
480
+ new_block,
481
+ documentation,
482
+ flags=re.DOTALL,
483
+ )
484
+
485
+
438
486
  def __assemble_module_template(module_path):
439
487
  """Construct the module after slicing it if it already exists."""
440
488
  ALT_BEGIN_CODE = "#>>> PLACE YOUR CODE BELLOW THIS LINE. DO NOT REMOVE THIS LINE!\n"
@@ -506,7 +554,7 @@ def __update_this_module(
506
554
  if not os.path.exists(path_1):
507
555
  os.makedirs(path_1)
508
556
 
509
- # Read user-defined Fkeys aliases (for dataclass generation only).
557
+ # Read user-defined Fkeys aliases (for docstring and dataclass generation).
510
558
  existing_fkeys = __get_fkeys(repo, class_name, module_path)
511
559
 
512
560
  module_template = __assemble_module_template(module_path)
@@ -519,6 +567,7 @@ def __update_this_module(
519
567
  # Generate Python module
520
568
  with open(module_path, 'w', encoding='utf-8') as file_:
521
569
  documentation = "\n".join([line and f" {line}" or "" for line in str(rel).split("\n")[1:]])
570
+ documentation = __apply_fkey_aliases_to_doc(documentation, rel, existing_fkeys)
522
571
  file_.write(
523
572
  module_template.format(
524
573
  hop_release = hop_version(),
@@ -0,0 +1 @@
1
+ 1.0.0-a11
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: half_orm_dev
3
- Version: 1.0.0a9
3
+ Version: 1.0.0a11
4
4
  Summary: half_orm development Framework.
5
5
  Author-email: Joël Maïzi <joel.maizi@collorg.org>
6
6
  License-Expression: GPL-3.0-or-later
@@ -1 +0,0 @@
1
- 1.0.0-a9
File without changes
File without changes
File without changes