You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2020/06/29 20:01:10 UTC

[GitHub] [airflow] mik-laj opened a new pull request #9577: Raise exception on invalid type in pre_commit_yaml_to_cfg.py

mik-laj opened a new pull request #9577:
URL: https://github.com/apache/airflow/pull/9577


   ---
   Make sure to mark the boxes below before creating PR: [x]
   
   - [X] Description above provides context of the change
   - [X] Unit tests coverage for changes (not needed for documentation changes)
   - [X] Target Github ISSUE in description if exists
   - [X] Commits follow "[How to write a good git commit message](http://chris.beams.io/posts/git-commit/)"
   - [X] Relevant documentation is updated including usage instructions.
   - [X] I will engage committers as explained in [Contribution Workflow Example](https://github.com/apache/airflow/blob/master/CONTRIBUTING.rst#contribution-workflow-example).
   
   ---
   In case of fundamental code change, Airflow Improvement Proposal ([AIP](https://cwiki.apache.org/confluence/display/AIRFLOW/Airflow+Improvements+Proposals)) is needed.
   In case of a new dependency, check compliance with the [ASF 3rd Party License Policy](https://www.apache.org/legal/resolved.html#category-x).
   In case of backwards incompatible changes please leave a note in [UPDATING.md](https://github.com/apache/airflow/blob/master/UPDATING.md).
   Read the [Pull Request Guidelines](https://github.com/apache/airflow/blob/master/CONTRIBUTING.rst#pull-request-guidelines) for more information.
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [airflow] mik-laj merged pull request #9577: Raise exception on invalid type in pre_commit_yaml_to_cfg.py

Posted by GitBox <gi...@apache.org>.
mik-laj merged pull request #9577:
URL: https://github.com/apache/airflow/pull/9577


   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [airflow] mik-laj commented on a change in pull request #9577: Raise exception on invalid type in pre_commit_yaml_to_cfg.py

Posted by GitBox <gi...@apache.org>.
mik-laj commented on a change in pull request #9577:
URL: https://github.com/apache/airflow/pull/9577#discussion_r447220006



##########
File path: scripts/ci/pre_commit_yaml_to_cfg.py
##########
@@ -82,46 +82,61 @@ def write_config(yaml_config_file_path: str, default_cfg_file_path: str):
         config_yaml = read_default_config_yaml(yaml_config_file_path)
 
         for section in config_yaml:  # pylint: disable=too-many-nested-blocks
-            section_name = section["name"]
-            configfile.write(f"\n[{section_name}]\n")
-
-            section_description = None
-            if section["description"] is not None:
-                section_description = list(
-                    filter(lambda x: (x is not None) or x != "", section["description"].splitlines()))
-            if section_description:
-                configfile.write("\n")
-                for single_line_desc in section_description:
-                    if single_line_desc == "":
-                        configfile.write("#\n")
-                    else:
-                        configfile.write(f"# {single_line_desc}\n")
-
-            for idx, option in enumerate(section["options"]):
-                option_description = None
-                if option["description"] is not None:
-                    option_description = list(
-                        filter(lambda x: x is not None, option["description"].splitlines()))
-
-                if option_description:
-                    if idx != 0:
-                        configfile.write("\n")
-                    for single_line_desc in option_description:
-                        if single_line_desc == "":
-                            configfile.write("#\n")
-                        else:
-                            configfile.write(f"# {single_line_desc}\n")
-
-                if option["example"]:
-                    if not str(option["name"]).endswith("_template"):
-                        option["example"] = option["example"].replace("{", "{{").replace("}", "}}")
-                    configfile.write("# Example: {} = {}\n".format(option["name"], option["example"]))
-
-                configfile.write("{}{} ={}\n".format(
-                    "# " if option["default"] is None else "",
-                    option["name"],
-                    " " + option["default"] if option["default"] else "")
-                )
+            _write_section(configfile, section)
+
+
+def _write_section(configfile, section):
+    section_name = section["name"]
+    configfile.write(f"\n[{section_name}]\n")
+    section_description = None
+    if section["description"] is not None:
+        section_description = list(
+            filter(lambda x: (x is not None) or x != "", section["description"].splitlines()))
+    if section_description:
+        configfile.write("\n")
+        for single_line_desc in section_description:
+            if single_line_desc == "":
+                configfile.write("#\n")
+            else:
+                configfile.write(f"# {single_line_desc}\n")
+    for idx, option in enumerate(section["options"]):
+        _write_option(configfile, idx, option)
+
+
+def _write_option(configfile, idx, option):
+    option_description = None
+    if option["description"] is not None:
+        option_description = list(
+            filter(lambda x: x is not None, option["description"].splitlines()))
+
+    if option_description:
+        if idx != 0:
+            configfile.write("\n")
+        for single_line_desc in option_description:
+            if single_line_desc == "":
+                configfile.write("#\n")
+            else:
+                configfile.write(f"# {single_line_desc}\n")
+
+    if option["example"]:
+        if not str(option["name"]).endswith("_template"):
+            option["example"] = option["example"].replace("{", "{{").replace("}", "}}")
+        configfile.write("# Example: {} = {}\n".format(option["name"], option["example"]))
+
+    if option["default"] is not None:
+        if not isinstance(option["default"], str):

Review comment:
       This is the key line




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org