cadwyn 3.6.6__py3-none-any.whl → 3.7.0__py3-none-any.whl

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.

Potentially problematic release.


This version of cadwyn might be problematic. Click here for more details.

cadwyn/__main__.py CHANGED
@@ -1,10 +1,12 @@
1
1
  import importlib
2
2
  import sys
3
+ import warnings
3
4
  from pathlib import Path
4
5
  from typing import Any
5
6
 
6
7
  import typer
7
8
 
9
+ from cadwyn.exceptions import CadwynError
8
10
  from cadwyn.structure.versions import VersionBundle
9
11
 
10
12
  app = typer.Typer(
@@ -22,8 +24,8 @@ def version_callback(value: bool):
22
24
  raise typer.Exit
23
25
 
24
26
 
25
- @app.command(name="generate-code-for-versioned-packages")
26
- def generate_versioned_packages(
27
+ @app.command(name="generate-code-for-versioned-packages", hidden=True)
28
+ def deprecated_generate_versioned_packages(
27
29
  path_to_template_package: str = typer.Argument(
28
30
  ...,
29
31
  help=(
@@ -43,6 +45,12 @@ def generate_versioned_packages(
43
45
  ),
44
46
  ) -> None:
45
47
  """For each version in the version bundle, generate a versioned package based on the template package"""
48
+ warnings.warn(
49
+ "`cadwyn generate-code-for-versioned-packages` is deprecated. Please, use `cadwyn codegen` instead",
50
+ DeprecationWarning,
51
+ stacklevel=1,
52
+ )
53
+
46
54
  from .codegen._main import generate_code_for_versioned_packages
47
55
 
48
56
  sys.path.append(str(Path.cwd()))
@@ -59,6 +67,39 @@ def generate_versioned_packages(
59
67
  )
60
68
 
61
69
 
70
+ @app.command(
71
+ name="codegen",
72
+ help=(
73
+ "For each version in the version bundle, generate a versioned package based on the "
74
+ "`latest_schema_package` package"
75
+ ),
76
+ short_help="Generate code for all versions of schemas",
77
+ )
78
+ def generate_versioned_packages(
79
+ full_path_to_version_bundle: str = typer.Argument(
80
+ ...,
81
+ help="The python path to the version bundle. Format: 'path.to.version_bundle:my_version_bundle_var'",
82
+ show_default=False,
83
+ ),
84
+ ) -> None:
85
+ from .codegen._main import generate_code_for_versioned_packages
86
+
87
+ sys.path.append(str(Path.cwd()))
88
+ path_to_version_bundle, version_bundle_variable_name = full_path_to_version_bundle.split(":")
89
+ version_bundle_module = importlib.import_module(path_to_version_bundle)
90
+ possibly_version_bundle = getattr(version_bundle_module, version_bundle_variable_name)
91
+ version_bundle = _get_version_bundle(possibly_version_bundle)
92
+
93
+ if version_bundle.latest_schemas_package is None: # pragma: no cover
94
+ raise CadwynError("VersionBundle requires a 'latest_schemas_package' argument to generate schemas.")
95
+
96
+ return generate_code_for_versioned_packages(
97
+ version_bundle.latest_schemas_package,
98
+ version_bundle,
99
+ ignore_coverage_for_latest_aliases=True,
100
+ )
101
+
102
+
62
103
  def _get_version_bundle(possibly_version_bundle: Any) -> VersionBundle:
63
104
  if not isinstance(possibly_version_bundle, VersionBundle):
64
105
  err = TypeError(
cadwyn/codegen/_main.py CHANGED
@@ -96,6 +96,7 @@ def _generate_versioned_directories(
96
96
  migration_plugins: Collection[MigrationPlugin],
97
97
  ):
98
98
  for version in versions:
99
+ print(f"Generating code for version={version.value!s}") # noqa: T201
99
100
  global_context = GlobalCodegenContext(
100
101
  current_version=version,
101
102
  versions=versions,
@@ -104,6 +105,7 @@ def _generate_versioned_directories(
104
105
  modules=modules,
105
106
  extra=extra_context,
106
107
  )
108
+
107
109
  _generate_directory_for_version(template_package, codegen_plugins, version, global_context)
108
110
  for plugin in migration_plugins:
109
111
  plugin(global_context)
@@ -117,6 +119,7 @@ def _generate_directory_for_version(
117
119
  ):
118
120
  template_dir = get_package_path_from_module(template_package)
119
121
  version_dir = get_version_dir_path(template_package, version.value)
122
+
120
123
  for (
121
124
  _relative_path_to_file,
122
125
  template_module,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: cadwyn
3
- Version: 3.6.6
3
+ Version: 3.7.0
4
4
  Summary: Production-ready community-driven modern Stripe-like API versioning in FastAPI
5
5
  Home-page: https://github.com/zmievsa/cadwyn
6
6
  License: MIT
@@ -1,5 +1,5 @@
1
1
  cadwyn/__init__.py,sha256=L5OVmOYlh5z3OYvwj6HidGBy8gvstCPMX5l4f4E-wr0,486
2
- cadwyn/__main__.py,sha256=JUNmAhwn7tG1EeXI82QmFZE-fpjfAOv2kxFNDfxWbhQ,2851
2
+ cadwyn/__main__.py,sha256=ERSXJs2S9OCZR05W4n-hz9M_n91pI35tvntSXHfv7N8,4423
3
3
  cadwyn/_asts.py,sha256=jFdnbkDDu_10YhJemDUVMut_XoqwIvGMtCQpDeitCiM,10206
4
4
  cadwyn/_compat.py,sha256=6QwtzbXn53mIhEFfEizmFjd-f894oLsM6ITxqq2rCpc,5408
5
5
  cadwyn/_package_utils.py,sha256=trxTYLmppv-10SKhScfyDQJh21rsQGFoLaOtHycKKR0,1443
@@ -8,7 +8,7 @@ cadwyn/applications.py,sha256=dx2QH_IzCRRLoSZ8xH4IT5yl792Yjjo-llIlrX6euc8,5128
8
8
  cadwyn/codegen/README.md,sha256=V2Kz2IOz1cTxrC-RnQ7YbWEVCIGYr3tR4IPCvepeq0M,1047
9
9
  cadwyn/codegen/__init__.py,sha256=JgddDjxMTjSfVrMXHwNu1ODgdn2QfPWpccrRKquBV6k,355
10
10
  cadwyn/codegen/_common.py,sha256=OJqmooQlShIJz68TUDNpJl1qN4KGv2u8ZntYXeu1mew,5916
11
- cadwyn/codegen/_main.py,sha256=KtwUvaqVSkNsHTGeOncjpDt6SBUzZTEQJf2-Il_zu3U,9232
11
+ cadwyn/codegen/_main.py,sha256=99NuZIPK6VwbZC6FIdVnuDmPFJeLud2jkWSaP31y5tM,9312
12
12
  cadwyn/codegen/_plugins/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
13
13
  cadwyn/codegen/_plugins/class_migrations.py,sha256=UnibLF98JrrVhXOOArsJWTij02HDlA_p4tZgsNDn2Dk,20111
14
14
  cadwyn/codegen/_plugins/class_rebuilding.py,sha256=15SI1AAQgLgIkz176Gf86whaw0NWAYX8_2ogYHUeT1g,3695
@@ -28,8 +28,8 @@ cadwyn/structure/enums.py,sha256=iMokxA2QYJ61SzyB-Pmuq3y7KL7-e6TsnjLVUaVZQnw,954
28
28
  cadwyn/structure/modules.py,sha256=1FK-lLm-zOTXEvn-QtyBH38aDRht5PDQiZrOPCsBlM4,1268
29
29
  cadwyn/structure/schemas.py,sha256=5hExJEdvEFPK4Cv8G_Gh6E6ltiNMyId_UjGIJz3jz0o,8802
30
30
  cadwyn/structure/versions.py,sha256=6M_saZPlzEQ0LNRQywhtrw-YPdjT0P18EEPTRg1dR8Y,32785
31
- cadwyn-3.6.6.dist-info/LICENSE,sha256=KeCWewiDQYpmSnzF-p_0YpoWiyDcUPaCuG8OWQs4ig4,1072
32
- cadwyn-3.6.6.dist-info/METADATA,sha256=ZThrLRK2fDcW3BpUVOWfic_tzAU2cOtMTU0yBCHfNWM,4104
33
- cadwyn-3.6.6.dist-info/WHEEL,sha256=FMvqSimYX_P7y0a7UY-_Mc83r5zkBZsCYPm7Lr0Bsq4,88
34
- cadwyn-3.6.6.dist-info/entry_points.txt,sha256=eO05hLn9GoRzzpwT9GONPmXKsonjuMNssM2D2WHWKGk,46
35
- cadwyn-3.6.6.dist-info/RECORD,,
31
+ cadwyn-3.7.0.dist-info/LICENSE,sha256=KeCWewiDQYpmSnzF-p_0YpoWiyDcUPaCuG8OWQs4ig4,1072
32
+ cadwyn-3.7.0.dist-info/METADATA,sha256=Vosr3uxnmqMPwDj4q2rBo18maTBIT7rCOvTG8sVA6Zs,4104
33
+ cadwyn-3.7.0.dist-info/WHEEL,sha256=FMvqSimYX_P7y0a7UY-_Mc83r5zkBZsCYPm7Lr0Bsq4,88
34
+ cadwyn-3.7.0.dist-info/entry_points.txt,sha256=eO05hLn9GoRzzpwT9GONPmXKsonjuMNssM2D2WHWKGk,46
35
+ cadwyn-3.7.0.dist-info/RECORD,,
File without changes