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

potiuk pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git


The following commit(s) were added to refs/heads/main by this push:
     new 1e81ed1999 Use literal dict instead of calling dict() in Airflow core 
(#33762)
1e81ed1999 is described below

commit 1e81ed19997114cc7dc136e9fd64676a7710715a
Author: Hussein Awala <[email protected]>
AuthorDate: Sat Aug 26 09:26:46 2023 +0200

    Use literal dict instead of calling dict() in Airflow core (#33762)
---
 .../api_connexion/endpoints/dag_source_endpoint.py   |  2 +-
 airflow/api_connexion/schemas/dag_schema.py          |  2 +-
 airflow/cli/cli_config.py                            |  2 +-
 airflow/cli/commands/connection_command.py           | 20 ++++++++++----------
 airflow/dag_processing/processor.py                  |  2 +-
 airflow/operators/python.py                          | 16 ++++++++--------
 airflow/serialization/serialized_objects.py          | 14 +++++++-------
 airflow/utils/db_cleanup.py                          | 14 +++++++-------
 airflow/utils/log/secrets_masker.py                  |  2 +-
 airflow/www/extensions/init_manifest_files.py        |  2 +-
 10 files changed, 38 insertions(+), 38 deletions(-)

diff --git a/airflow/api_connexion/endpoints/dag_source_endpoint.py 
b/airflow/api_connexion/endpoints/dag_source_endpoint.py
index 42ccd4e5d8..b191630815 100644
--- a/airflow/api_connexion/endpoints/dag_source_endpoint.py
+++ b/airflow/api_connexion/endpoints/dag_source_endpoint.py
@@ -43,6 +43,6 @@ def get_dag_source(*, file_token: str) -> Response:
     if return_type == "text/plain":
         return Response(dag_source, headers={"Content-Type": return_type})
     if return_type == "application/json":
-        content = dag_source_schema.dumps(dict(content=dag_source))
+        content = dag_source_schema.dumps({"content": dag_source})
         return Response(content, headers={"Content-Type": return_type})
     return Response("Not Allowed Accept Header", 
status=HTTPStatus.NOT_ACCEPTABLE)
diff --git a/airflow/api_connexion/schemas/dag_schema.py 
b/airflow/api_connexion/schemas/dag_schema.py
index 08f649b3d6..9c063cb937 100644
--- a/airflow/api_connexion/schemas/dag_schema.py
+++ b/airflow/api_connexion/schemas/dag_schema.py
@@ -120,7 +120,7 @@ class DAGDetailSchema(DAGSchema):
         """Dump tags as objects."""
         tags = obj.tags
         if tags:
-            return [DagTagSchema().dump(dict(name=tag)) for tag in tags]
+            return [DagTagSchema().dump({"name": tag}) for tag in tags]
         return []
 
     @staticmethod
diff --git a/airflow/cli/cli_config.py b/airflow/cli/cli_config.py
index c52dd9aa90..fadf988a4a 100644
--- a/airflow/cli/cli_config.py
+++ b/airflow/cli/cli_config.py
@@ -2029,7 +2029,7 @@ core_commands: list[CLICommand] = [
         name="standalone",
         help="Run an all-in-one copy of Airflow",
         
func=lazy_load_command("airflow.cli.commands.standalone_command.standalone"),
-        args=tuple(),
+        args=(),
     ),
 ]
 
diff --git a/airflow/cli/commands/connection_command.py 
b/airflow/cli/commands/connection_command.py
index fe9e71733c..6990417dc0 100644
--- a/airflow/cli/commands/connection_command.py
+++ b/airflow/cli/commands/connection_command.py
@@ -96,16 +96,16 @@ def connections_list(args):
 
 
 def _connection_to_dict(conn: Connection) -> dict:
-    return dict(
-        conn_type=conn.conn_type,
-        description=conn.description,
-        login=conn.login,
-        password=conn.password,
-        host=conn.host,
-        port=conn.port,
-        schema=conn.schema,
-        extra=conn.extra,
-    )
+    return {
+        "conn_type": conn.conn_type,
+        "description": conn.description,
+        "login": conn.login,
+        "password": conn.password,
+        "host": conn.host,
+        "port": conn.port,
+        "schema": conn.schema,
+        "extra": conn.extra,
+    }
 
 
 def create_default_connections(args):
diff --git a/airflow/dag_processing/processor.py 
b/airflow/dag_processing/processor.py
index e38bae653c..ab17bad4da 100644
--- a/airflow/dag_processing/processor.py
+++ b/airflow/dag_processing/processor.py
@@ -619,7 +619,7 @@ class DagFileProcessor(LoggingMixin):
         for filename, stacktrace in import_errors.items():
             if filename in existing_import_error_files:
                 
session.query(errors.ImportError).filter(errors.ImportError.filename == 
filename).update(
-                    dict(filename=filename, timestamp=timezone.utcnow(), 
stacktrace=stacktrace),
+                    {"filename": filename, "timestamp": timezone.utcnow(), 
"stacktrace": stacktrace},
                     synchronize_session="fetch",
                 )
             else:
diff --git a/airflow/operators/python.py b/airflow/operators/python.py
index 85238b4bb3..ad2deb8ad7 100644
--- a/airflow/operators/python.py
+++ b/airflow/operators/python.py
@@ -430,14 +430,14 @@ class _BasePythonVirtualenvOperator(PythonOperator, 
metaclass=ABCMeta):
         self._write_args(input_path)
         self._write_string_args(string_args_path)
         write_python_script(
-            jinja_context=dict(
-                op_args=self.op_args,
-                op_kwargs=op_kwargs,
-                expect_airflow=self.expect_airflow,
-                pickling_library=self.pickling_library.__name__,
-                python_callable=self.python_callable.__name__,
-                python_callable_source=self.get_python_source(),
-            ),
+            jinja_context={
+                "op_args": self.op_args,
+                "op_kwargs": op_kwargs,
+                "expect_airflow": self.expect_airflow,
+                "pickling_library": self.pickling_library.__name__,
+                "python_callable": self.python_callable.__name__,
+                "python_callable_source": self.get_python_source(),
+            },
             filename=os.fspath(script_path),
             
render_template_as_native_obj=self.dag.render_template_as_native_obj,
         )
diff --git a/airflow/serialization/serialized_objects.py 
b/airflow/serialization/serialized_objects.py
index 67d08b7a94..b3a252783a 100644
--- a/airflow/serialization/serialized_objects.py
+++ b/airflow/serialization/serialized_objects.py
@@ -476,7 +476,7 @@ class BaseSerialization:
         elif isinstance(var, XComArg):
             return cls._encode(serialize_xcom_arg(var), type_=DAT.XCOM_REF)
         elif isinstance(var, Dataset):
-            return cls._encode(dict(uri=var.uri, extra=var.extra), 
type_=DAT.DATASET)
+            return cls._encode({"uri": var.uri, "extra": var.extra}, 
type_=DAT.DATASET)
         elif isinstance(var, SimpleTaskInstance):
             return cls._encode(
                 cls.serialize(var.__dict__, strict=strict, 
use_pydantic_models=use_pydantic_models),
@@ -616,12 +616,12 @@ class BaseSerialization:
 
     @classmethod
     def _serialize_param(cls, param: Param):
-        return dict(
-            __class=f"{param.__module__}.{param.__class__.__name__}",
-            default=cls.serialize(param.value),
-            description=cls.serialize(param.description),
-            schema=cls.serialize(param.schema),
-        )
+        return {
+            "__class": f"{param.__module__}.{param.__class__.__name__}",
+            "default": cls.serialize(param.value),
+            "description": cls.serialize(param.description),
+            "schema": cls.serialize(param.schema),
+        }
 
     @classmethod
     def _deserialize_param(cls, param_dict: dict):
diff --git a/airflow/utils/db_cleanup.py b/airflow/utils/db_cleanup.py
index 4c82f90ab3..f4e0293430 100644
--- a/airflow/utils/db_cleanup.py
+++ b/airflow/utils/db_cleanup.py
@@ -83,13 +83,13 @@ class _TableConfig:
 
     @property
     def readable_config(self):
-        return dict(
-            table=self.orm_model.name,
-            recency_column=str(self.recency_column),
-            keep_last=self.keep_last,
-            keep_last_filters=[str(x) for x in self.keep_last_filters] if 
self.keep_last_filters else None,
-            keep_last_group_by=str(self.keep_last_group_by),
-        )
+        return {
+            "table": self.orm_model.name,
+            "recency_column": str(self.recency_column),
+            "keep_last": self.keep_last,
+            "keep_last_filters": [str(x) for x in self.keep_last_filters] if 
self.keep_last_filters else None,
+            "keep_last_group_by": str(self.keep_last_group_by),
+        }
 
 
 config_list: list[_TableConfig] = [
diff --git a/airflow/utils/log/secrets_masker.py 
b/airflow/utils/log/secrets_masker.py
index a0f0da847c..bb39dbf95b 100644
--- a/airflow/utils/log/secrets_masker.py
+++ b/airflow/utils/log/secrets_masker.py
@@ -176,7 +176,7 @@ class SecretsMasker(logging.Filter):
             __file__,
             1,
             "",
-            tuple(),
+            (),
             exc_info=None,
             func="funcname",
         )
diff --git a/airflow/www/extensions/init_manifest_files.py 
b/airflow/www/extensions/init_manifest_files.py
index 2ce60194a6..4d491786a8 100644
--- a/airflow/www/extensions/init_manifest_files.py
+++ b/airflow/www/extensions/init_manifest_files.py
@@ -56,4 +56,4 @@ def configure_manifest_files(app):
         static/dist folder. This template tag reads the asset name in
         ``manifest.json`` and returns the appropriate file.
         """
-        return dict(url_for_asset=get_asset_url)
+        return {"url_for_asset": get_asset_url}

Reply via email to