This is an automated email from the ASF dual-hosted git repository.
vincbeck 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 1aff29fa26f Fix MyPy type errors in models/errors.py & connection.py
(#57373)
1aff29fa26f is described below
commit 1aff29fa26fe98ec4e05dcbb2973bb9212835977
Author: LI,JHE-CHEN <[email protected]>
AuthorDate: Mon Nov 3 09:39:00 2025 -0500
Fix MyPy type errors in models/errors.py & connection.py (#57373)
---
airflow-core/src/airflow/models/connection.py | 13 +++++++++++--
airflow-core/src/airflow/models/errors.py | 2 ++
2 files changed, 13 insertions(+), 2 deletions(-)
diff --git a/airflow-core/src/airflow/models/connection.py
b/airflow-core/src/airflow/models/connection.py
index 06c2ee54c80..f64c38b5efe 100644
--- a/airflow-core/src/airflow/models/connection.py
+++ b/airflow-core/src/airflow/models/connection.py
@@ -158,7 +158,6 @@ class Connection(Base, LoggingMixin):
team_id: str | None = None,
):
super().__init__()
- self.conn_id = sanitize_conn_id(conn_id)
self.description = description
if extra and not isinstance(extra, str):
extra = json.dumps(extra)
@@ -171,13 +170,20 @@ class Connection(Base, LoggingMixin):
if uri:
self._parse_from_uri(uri)
else:
- self.conn_type = conn_type
+ if conn_type is not None:
+ self.conn_type = conn_type
+
self.host = host
self.login = login
self.password = password
self.schema = schema
self.port = port
self.extra = extra
+
+ if conn_id is not None:
+ sanitized_id = sanitize_conn_id(conn_id)
+ if sanitized_id is not None:
+ self.conn_id = sanitized_id
if self.extra:
self._validate_extra(self.extra, self.conn_id)
@@ -274,6 +280,9 @@ class Connection(Base, LoggingMixin):
else:
uri = "//"
+ host_to_use: str | None
+ protocol_to_add: str | None
+
if self.host and "://" in self.host:
protocol, host = self.host.split("://", 1)
# If the protocol in host matches the connection type, don't add
it again
diff --git a/airflow-core/src/airflow/models/errors.py
b/airflow-core/src/airflow/models/errors.py
index e20096aa05d..44e72129ccd 100644
--- a/airflow-core/src/airflow/models/errors.py
+++ b/airflow-core/src/airflow/models/errors.py
@@ -39,5 +39,7 @@ class ParseImportError(Base):
def full_file_path(self) -> str:
"""Return the full file path of the dag."""
+ if self.bundle_name is None or self.filename is None:
+ raise ValueError("bundle_name and filename must not be None")
bundle = DagBundlesManager().get_bundle(self.bundle_name)
return "/".join([str(bundle.path), self.filename])