Skip to content

Commit

Permalink
Removed deprecated param from local_filesystem (apache#41533)
Browse files Browse the repository at this point in the history
* removed deprecated parameters from local_filesystem

* add newsfragments file
  • Loading branch information
gopidesupavan authored Aug 16, 2024
1 parent 796699b commit 166de82
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 24 deletions.
24 changes: 0 additions & 24 deletions airflow/secrets/local_filesystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import json
import logging
import os
import warnings
from collections import defaultdict
from inspect import signature
from json import JSONDecodeError
Expand All @@ -33,7 +32,6 @@
AirflowFileParseException,
ConnectionNotUnique,
FileSyntaxError,
RemovedInAirflow3Warning,
)
from airflow.secrets.base_secrets import BaseSecretsBackend
from airflow.utils import yaml
Expand Down Expand Up @@ -243,16 +241,6 @@ def load_variables(file_path: str) -> dict[str, str]:
return variables


def load_connections(file_path) -> dict[str, list[Any]]:
"""Use `airflow.secrets.local_filesystem.load_connections_dict`, this is deprecated."""
warnings.warn(
"This function is deprecated. Please use `airflow.secrets.local_filesystem.load_connections_dict`.",
RemovedInAirflow3Warning,
stacklevel=2,
)
return {k: [v] for k, v in load_connections_dict(file_path).values()}


def load_connections_dict(file_path: str) -> dict[str, Any]:
"""
Load connection from text file.
Expand Down Expand Up @@ -318,17 +306,5 @@ def get_connection(self, conn_id: str) -> Connection | None:
return self._local_connections[conn_id]
return None

def get_connections(self, conn_id: str) -> list[Any]:
warnings.warn(
"This method is deprecated. Please use "
"`airflow.secrets.local_filesystem.LocalFilesystemBackend.get_connection`.",
RemovedInAirflow3Warning,
stacklevel=2,
)
conn = self.get_connection(conn_id=conn_id)
if conn:
return [conn]
return []

def get_variable(self, key: str) -> str | None:
return self._local_variables.get(key)
26 changes: 26 additions & 0 deletions newsfragments/41533.significant.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
**Breaking Change**

The ``load_connections`` parameter has been removed from the ``local_file_system``.
This parameter was previously deprecated in favor of ``load_connections_dict``.

If your code still uses ``load_connections``, you should update it to use ``load_connections_dict``
instead to ensure compatibility with future Airflow versions.

Example update:

.. code-block:: python
connection_by_conn_id = local_filesystem.load_connections_dict(file_path="a.json")
The ``get_connections`` parameter has been removed from the ``LocalFilesystemBackend`` class.
This parameter was previously deprecated in favor of ``get_connection``.

If your code still uses ``get_connections``, you should update it to use ``get_connection``
instead to ensure compatibility with future Airflow versions.


Example update:

.. code-block:: python
connection_by_conn_id = LocalFilesystemBackend().get_connection(conn_id="conn_id")

0 comments on commit 166de82

Please sign in to comment.