You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by pi...@apache.org on 2023/01/11 23:24:18 UTC

[airflow] branch v2-5-test updated: Update pre-commit hooks (#28567)

This is an automated email from the ASF dual-hosted git repository.

pierrejeambrun pushed a commit to branch v2-5-test
in repository https://gitbox.apache.org/repos/asf/airflow.git


The following commit(s) were added to refs/heads/v2-5-test by this push:
     new d65fd66e46 Update pre-commit hooks (#28567)
d65fd66e46 is described below

commit d65fd66e463ed8ce98d4060b7c8ae79626618277
Author: KarshVashi <41...@users.noreply.github.com>
AuthorDate: Sat Dec 24 01:03:59 2022 +0000

    Update pre-commit hooks (#28567)
    
    (cherry picked from commit 837e0fe2ea8859ae879d8382142c29a6416f02b9)
---
 .pre-commit-config.yaml                                  |  8 ++++----
 airflow/www/fab_security/manager.py                      |  2 +-
 .../src/airflow_breeze/commands/testing_commands.py      |  2 +-
 dev/provider_packages/prepare_provider_packages.py       | 16 ++++++++--------
 docs/exts/docs_build/docs_builder.py                     |  4 ++--
 docs/exts/extra_files_with_substitutions.py              |  2 +-
 docs/exts/provider_init_hack.py                          |  2 +-
 kubernetes_tests/test_base.py                            |  2 +-
 tests/jobs/test_triggerer_job.py                         |  2 +-
 9 files changed, 20 insertions(+), 20 deletions(-)

diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index a6ed9b1f4d..577f0a1dda 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -148,7 +148,7 @@ repos:
           \.cfg$|\.conf$|\.ini$|\.ldif$|\.properties$|\.readthedocs$|\.service$|\.tf$|Dockerfile.*$
   # Keep version of black in sync wit blacken-docs and pre-commit-hook-names
   - repo: https://github.com/psf/black
-    rev: 22.3.0
+    rev: 22.12.0
     hooks:
       - id: black
         name: Run black (python formatter)
@@ -210,7 +210,7 @@ repos:
         pass_filenames: true
   # TODO: Bump to Python 3.8 when support for Python 3.7 is dropped in Airflow.
   - repo: https://github.com/asottile/pyupgrade
-    rev: v2.32.1
+    rev: v3.3.1
     hooks:
       - id: pyupgrade
         name: Upgrade Python code automatically
@@ -259,7 +259,7 @@ repos:
           ^airflow/_vendor/
         additional_dependencies: ['toml']
   - repo: https://github.com/asottile/yesqa
-    rev: v1.3.0
+    rev: v1.4.0
     hooks:
       - id: yesqa
         name: Remove unnecessary noqa statements
@@ -268,7 +268,7 @@ repos:
           ^airflow/_vendor/
         additional_dependencies: ['flake8>=4.0.1']
   - repo: https://github.com/ikamensh/flynt
-    rev: '0.76'
+    rev: '0.77'
     hooks:
       - id: flynt
         name: Run flynt string format converter for Python
diff --git a/airflow/www/fab_security/manager.py b/airflow/www/fab_security/manager.py
index 96649b046b..ea8918053c 100644
--- a/airflow/www/fab_security/manager.py
+++ b/airflow/www/fab_security/manager.py
@@ -1013,7 +1013,7 @@ class BaseSecurityManager:
 
     @staticmethod
     def ldap_extract(ldap_dict: dict[str, list[bytes]], field_name: str, fallback: str) -> str:
-        raw_value = ldap_dict.get(field_name, [bytes()])
+        raw_value = ldap_dict.get(field_name, [b""])
         # decode - if empty string, default to fallback, otherwise take first element
         return raw_value[0].decode("utf-8") or fallback
 
diff --git a/dev/breeze/src/airflow_breeze/commands/testing_commands.py b/dev/breeze/src/airflow_breeze/commands/testing_commands.py
index 33781e3373..58d0b509a9 100644
--- a/dev/breeze/src/airflow_breeze/commands/testing_commands.py
+++ b/dev/breeze/src/airflow_breeze/commands/testing_commands.py
@@ -181,7 +181,7 @@ def _run_test(
             for container_id in container_ids:
                 dump_path = FILES_DIR / f"container_logs_{container_id}_{date_str}.log"
                 get_console(output=output).print(f"[info]Dumping container {container_id} to {dump_path}")
-                with open(dump_path, "wt") as outfile:
+                with open(dump_path, "w") as outfile:
                     run_command(["docker", "logs", container_id], check=False, stdout=outfile)
     finally:
         run_command(
diff --git a/dev/provider_packages/prepare_provider_packages.py b/dev/provider_packages/prepare_provider_packages.py
index 2ef0859c89..ed1afb1e8f 100755
--- a/dev/provider_packages/prepare_provider_packages.py
+++ b/dev/provider_packages/prepare_provider_packages.py
@@ -1110,7 +1110,7 @@ def prepare_readme_file(context):
         template_name="PROVIDER_README", context=context, extension=".rst"
     )
     readme_file_path = os.path.join(TARGET_PROVIDER_PACKAGES_PATH, "README.rst")
-    with open(readme_file_path, "wt") as readme_file:
+    with open(readme_file_path, "w") as readme_file:
         readme_file.write(readme_content)
 
 
@@ -1182,7 +1182,7 @@ def mark_latest_changes_as_documentation_only(provider_package_id: str, latest_c
         "as doc-only changes!"
     )
     with open(
-        os.path.join(provider_details.source_provider_package_path, ".latest-doc-only-change.txt"), "tw"
+        os.path.join(provider_details.source_provider_package_path, ".latest-doc-only-change.txt"), "w"
     ) as f:
         f.write(latest_change.full_hash + "\n")
         # exit code 66 marks doc-only change marked
@@ -1311,7 +1311,7 @@ def replace_content(file_path, old_text, new_text, provider_package_id):
         try:
             if os.path.isfile(file_path):
                 copyfile(file_path, temp_file_path)
-            with open(file_path, "wt") as readme_file:
+            with open(file_path, "w") as readme_file:
                 readme_file.write(new_text)
             console.print()
             console.print(f"Generated {file_path} file for the {provider_package_id} provider")
@@ -1401,7 +1401,7 @@ def prepare_setup_py_file(context):
     setup_py_content = render_template(
         template_name=setup_py_template_name, context=context, extension=".py", autoescape=False
     )
-    with open(setup_py_file_path, "wt") as setup_py_file:
+    with open(setup_py_file_path, "w") as setup_py_file:
         setup_py_file.write(black_format(setup_py_content))
 
 
@@ -1415,7 +1415,7 @@ def prepare_setup_cfg_file(context):
         autoescape=False,
         keep_trailing_newline=True,
     )
-    with open(setup_cfg_file_path, "wt") as setup_cfg_file:
+    with open(setup_cfg_file_path, "w") as setup_cfg_file:
         setup_cfg_file.write(setup_cfg_content)
 
 
@@ -1434,7 +1434,7 @@ def prepare_get_provider_info_py_file(context, provider_package_id: str):
         autoescape=False,
         keep_trailing_newline=True,
     )
-    with open(get_provider_file_path, "wt") as get_provider_file:
+    with open(get_provider_file_path, "w") as get_provider_file:
         get_provider_file.write(black_format(get_provider_content))
 
 
@@ -1447,7 +1447,7 @@ def prepare_manifest_in_file(context):
         autoescape=False,
         keep_trailing_newline=True,
     )
-    with open(target, "wt") as fh:
+    with open(target, "w") as fh:
         fh.write(content)
 
 
@@ -1840,7 +1840,7 @@ def generate_new_changelog(package_id, provider_details, changelog_path, changes
         console.print(
             f"[green]Appending the provider {package_id} changelog for `{latest_version}` version.[/]"
         )
-    with open(changelog_path, "wt") as changelog:
+    with open(changelog_path, "w") as changelog:
         changelog.write("\n".join(new_changelog_lines))
         changelog.write("\n")
 
diff --git a/docs/exts/docs_build/docs_builder.py b/docs/exts/docs_build/docs_builder.py
index d6b01d7239..90baffe2ba 100644
--- a/docs/exts/docs_build/docs_builder.py
+++ b/docs/exts/docs_build/docs_builder.py
@@ -162,7 +162,7 @@ class AirflowDocsBuilder:
                 " ".join(shlex.quote(c) for c in build_cmd),
             )
             console.print(f"[info]{self.package_name:60}:[/] The output is hidden until an error occurs.")
-        with open(self.log_spelling_filename, "wt") as output:
+        with open(self.log_spelling_filename, "w") as output:
             completed_proc = run(
                 build_cmd,
                 cwd=self._src_dir,
@@ -241,7 +241,7 @@ class AirflowDocsBuilder:
                 f"[info]{self.package_name:60}:[/] Running sphinx. "
                 f"The output is hidden until an error occurs."
             )
-        with open(self.log_build_filename, "wt") as output:
+        with open(self.log_build_filename, "w") as output:
             completed_proc = run(
                 build_cmd,
                 cwd=self._src_dir,
diff --git a/docs/exts/extra_files_with_substitutions.py b/docs/exts/extra_files_with_substitutions.py
index 5cdaadd610..a2f0d8f9ce 100644
--- a/docs/exts/extra_files_with_substitutions.py
+++ b/docs/exts/extra_files_with_substitutions.py
@@ -38,7 +38,7 @@ def copy_docker_compose(app, exception):
         with open(os.path.join(app.outdir, os.path.dirname(path), os.path.basename(path))) as input_file:
             content = input_file.readlines()
         with open(
-            os.path.join(app.outdir, os.path.dirname(path), os.path.basename(path)), "wt"
+            os.path.join(app.outdir, os.path.dirname(path), os.path.basename(path)), "w"
         ) as output_file:
             for line in content:
                 output_file.write(line.replace("|version|", app.config.version))
diff --git a/docs/exts/provider_init_hack.py b/docs/exts/provider_init_hack.py
index e9ff142e82..be34d13b3a 100644
--- a/docs/exts/provider_init_hack.py
+++ b/docs/exts/provider_init_hack.py
@@ -37,7 +37,7 @@ def _create_init_py(app, config):
     del config
     # This file is deleted by /docs/build_docs.py. If you are not using the script, the file will be
     # deleted by pre-commit.
-    with open(PROVIDER_INIT_FILE, "wt"):
+    with open(PROVIDER_INIT_FILE, "w"):
         pass
 
 
diff --git a/kubernetes_tests/test_base.py b/kubernetes_tests/test_base.py
index a5a690881d..0601b2ff55 100644
--- a/kubernetes_tests/test_base.py
+++ b/kubernetes_tests/test_base.py
@@ -52,7 +52,7 @@ class TestBase(unittest.TestCase):
         ci = os.environ.get("CI")
         if ci and ci.lower() == "true":
             print("The resource dump will be uploaded as artifact of the CI job")
-        with open(output_file_path, "wt") as output_file:
+        with open(output_file_path, "w") as output_file:
             print("=" * 80, file=output_file)
             print(f"Describe resources for namespace {namespace}", file=output_file)
             print(f"Datetime: {datetime.utcnow()}", file=output_file)
diff --git a/tests/jobs/test_triggerer_job.py b/tests/jobs/test_triggerer_job.py
index b84392366a..5fa64c9c47 100644
--- a/tests/jobs/test_triggerer_job.py
+++ b/tests/jobs/test_triggerer_job.py
@@ -44,7 +44,7 @@ class TimeDeltaTrigger_(TimeDeltaTrigger):
         self.delta = delta
 
     async def run(self):
-        with open(self.filename, "at") as f:
+        with open(self.filename, "a") as f:
             f.write("hi\n")
         async for event in super().run():
             yield event