@autorest/python 6.1.7 → 6.1.8

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.
@@ -3,7 +3,7 @@
3
3
  # Licensed under the MIT License. See License.txt in the project root for
4
4
  # license information.
5
5
  # --------------------------------------------------------------------------
6
- from typing import Any, Dict
6
+ from typing import Any, Dict, Tuple
7
7
  import re
8
8
  import argparse
9
9
 
@@ -37,7 +37,9 @@ def to_snake_case(name: str) -> str:
37
37
  return re.sub("[A-Z]+", replace_upper_characters, name)
38
38
 
39
39
 
40
- def parse_args(need_cadl_file: bool = True):
40
+ def parse_args(
41
+ need_cadl_file: bool = True,
42
+ ) -> Tuple[argparse.Namespace, Dict[str, Any]]:
41
43
  parser = argparse.ArgumentParser(
42
44
  description="Run mypy against target folder. Add a local custom plugin to the path prior to execution. "
43
45
  )
@@ -60,7 +62,24 @@ def parse_args(need_cadl_file: bool = True):
60
62
  required=False,
61
63
  action="store_true",
62
64
  )
63
- return parser.parse_args()
65
+ args, unknown_args = parser.parse_known_args()
66
+
67
+ def _get_value(value: Any) -> Any:
68
+ if value == "true":
69
+ return True
70
+ if value == "false":
71
+ return False
72
+ try:
73
+ return int(value)
74
+ except ValueError:
75
+ pass
76
+ return value
77
+
78
+ unknown_args_ret = {
79
+ ua.strip("--").split("=")[0]: _get_value(ua.strip("--").split("=")[1])
80
+ for ua in unknown_args
81
+ }
82
+ return args, unknown_args_ret
64
83
 
65
84
 
66
85
  def get_body_type_for_description(body_parameter: Dict[str, Any]) -> str:
@@ -54,5 +54,5 @@ class BlackScriptPluginAutorest(BlackScriptPlugin, PluginAutorest):
54
54
 
55
55
  if __name__ == "__main__":
56
56
  # CADL pipeline will call this
57
- args = parse_args(need_cadl_file=False)
58
- BlackScriptPlugin(output_folder=args.output_folder).process()
57
+ args, unknown_args = parse_args(need_cadl_file=False)
58
+ BlackScriptPlugin(output_folder=args.output_folder, **unknown_args).process()
@@ -124,5 +124,7 @@ class CadlFlags(YamlUpdatePlugin): # pylint: disable=abstract-method
124
124
 
125
125
  if __name__ == "__main__":
126
126
  # CADL pipeline will call this
127
- args = parse_args()
128
- CadlFlags(output_folder=args.output_folder, cadl_file=args.cadl_file).process()
127
+ args, unknown_args = parse_args()
128
+ CadlFlags(
129
+ output_folder=args.output_folder, cadl_file=args.cadl_file, **unknown_args
130
+ ).process()
@@ -361,5 +361,7 @@ class CodeGeneratorAutorest(CodeGenerator, PluginAutorest):
361
361
 
362
362
  if __name__ == "__main__":
363
363
  # CADL pipeline will call this
364
- args = parse_args()
365
- CodeGenerator(output_folder=args.output_folder, cadl_file=args.cadl_file).process()
364
+ args, unknown_args = parse_args()
365
+ CodeGenerator(
366
+ output_folder=args.output_folder, cadl_file=args.cadl_file, **unknown_args
367
+ ).process()
@@ -68,5 +68,7 @@ class M2RAutorest(YamlUpdatePluginAutorest, M2R):
68
68
 
69
69
  if __name__ == "__main__":
70
70
  # CADL pipeline will call this
71
- args = parse_args()
72
- M2R(output_folder=args.output_folder, cadl_file=args.cadl_file).process()
71
+ args, unknown_args = parse_args()
72
+ M2R(
73
+ output_folder=args.output_folder, cadl_file=args.cadl_file, **unknown_args
74
+ ).process()
@@ -363,7 +363,7 @@ class PreProcessPluginAutorest(YamlUpdatePluginAutorest, PreProcessPlugin):
363
363
 
364
364
  if __name__ == "__main__":
365
365
  # CADL pipeline will call this
366
- args = parse_args()
366
+ args, unknown_args = parse_args()
367
367
  PreProcessPlugin(
368
- output_folder=args.output_folder, cadl_file=args.cadl_file
368
+ output_folder=args.output_folder, cadl_file=args.cadl_file, **unknown_args
369
369
  ).process()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@autorest/python",
3
- "version": "6.1.7",
3
+ "version": "6.1.8",
4
4
  "description": "The Python extension for generators in AutoRest.",
5
5
  "repository": {
6
6
  "type": "git",