Skip to content

Commit 9ab1a6a

Browse files
Update old style typing (#26872)
1 parent b757bfa commit 9ab1a6a

File tree

228 files changed

+396
-1008
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

228 files changed

+396
-1008
lines changed

β€Žairflow/api/client/__init__.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
from __future__ import annotations
2020

2121
from importlib import import_module
22-
from typing import Any
2322

2423
from airflow import api
2524
from airflow.api.client.api_client import Client
@@ -28,7 +27,7 @@
2827

2928
def get_current_api_client() -> Client:
3029
"""Return current API Client based on current Airflow configuration"""
31-
api_module = import_module(conf.get_mandatory_value('cli', 'api_client')) # type: Any
30+
api_module = import_module(conf.get_mandatory_value('cli', 'api_client'))
3231
auth_backends = api.load_auth()
3332
session = None
3433
for backend in auth_backends:

β€Žairflow/configuration.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -829,7 +829,6 @@ def getsection(self, section: str) -> ConfigOptionsDictType | None:
829829
as required.
830830
831831
:param section: section from the config
832-
:rtype: dict
833832
"""
834833
if not self.has_section(section) and not self.airflow_defaults.has_section(section):
835834
return None
@@ -921,7 +920,6 @@ def as_dict(
921920
:param include_secret: Should the result of calling any *_secret config be
922921
set (True, default), or should the _secret options be left as the
923922
path to get the secret from (False)
924-
:rtype: Dict[str, Dict[str, str]]
925923
:return: Dictionary, where the key is the name of the section and the content is
926924
the dictionary with the name of the parameter and its value.
927925
"""
@@ -1087,7 +1085,6 @@ def _filter_by_source(
10871085
Source is either 'airflow.cfg', 'default', 'env var', or 'cmd'.
10881086
:param getter_func: A callback function that gets the user configured
10891087
override value for a particular sensitive_config_values config.
1090-
:rtype: None
10911088
:return: None, the given config_sources is filtered if necessary,
10921089
otherwise untouched.
10931090
"""

β€Žairflow/dag_processing/manager.py

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -845,89 +845,80 @@ def _log_file_processing_stats(self, known_file_paths):
845845

846846
self.log.info(log_str)
847847

848-
def get_pid(self, file_path):
848+
def get_pid(self, file_path) -> int | None:
849849
"""
850850
:param file_path: the path to the file that's being processed
851851
:return: the PID of the process processing the given file or None if
852852
the specified file is not being processed
853-
:rtype: int
854853
"""
855854
if file_path in self._processors:
856855
return self._processors[file_path].pid
857856
return None
858857

859-
def get_all_pids(self):
858+
def get_all_pids(self) -> list[int]:
860859
"""
860+
Get all pids.
861+
861862
:return: a list of the PIDs for the processors that are running
862-
:rtype: List[int]
863863
"""
864864
return [x.pid for x in self._processors.values()]
865865

866-
def get_last_runtime(self, file_path):
866+
def get_last_runtime(self, file_path) -> float | None:
867867
"""
868868
:param file_path: the path to the file that was processed
869869
:return: the runtime (in seconds) of the process of the last run, or
870870
None if the file was never processed.
871-
:rtype: float
872871
"""
873872
stat = self._file_stats.get(file_path)
874873
return stat.last_duration.total_seconds() if stat and stat.last_duration else None
875874

876-
def get_last_dag_count(self, file_path):
875+
def get_last_dag_count(self, file_path) -> int | None:
877876
"""
878877
:param file_path: the path to the file that was processed
879878
:return: the number of dags loaded from that file, or None if the file
880879
was never processed.
881-
:rtype: int
882880
"""
883881
stat = self._file_stats.get(file_path)
884882
return stat.num_dags if stat else None
885883

886-
def get_last_error_count(self, file_path):
884+
def get_last_error_count(self, file_path) -> int | None:
887885
"""
888886
:param file_path: the path to the file that was processed
889887
:return: the number of import errors from processing, or None if the file
890888
was never processed.
891-
:rtype: int
892889
"""
893890
stat = self._file_stats.get(file_path)
894891
return stat.import_errors if stat else None
895892

896-
def get_last_finish_time(self, file_path):
893+
def get_last_finish_time(self, file_path) -> datetime | None:
897894
"""
898895
:param file_path: the path to the file that was processed
899896
:return: the finish time of the process of the last run, or None if the
900897
file was never processed.
901-
:rtype: datetime
902898
"""
903899
stat = self._file_stats.get(file_path)
904900
return stat.last_finish_time if stat else None
905901

906-
def get_start_time(self, file_path):
902+
def get_start_time(self, file_path) -> datetime | None:
907903
"""
908904
:param file_path: the path to the file that's being processed
909905
:return: the start time of the process that's processing the
910906
specified file or None if the file is not currently being processed
911-
:rtype: datetime
912907
"""
913908
if file_path in self._processors:
914909
return self._processors[file_path].start_time
915910
return None
916911

917-
def get_run_count(self, file_path):
912+
def get_run_count(self, file_path) -> int:
918913
"""
919914
:param file_path: the path to the file that's being processed
920915
:return: the number of times the given file has been parsed
921-
:rtype: int
922916
"""
923917
stat = self._file_stats.get(file_path)
924918
return stat.run_count if stat else 0
925919

926920
def get_dag_directory(self) -> str:
927-
"""
928-
Returns the dag_director as a string.
929-
:rtype: str
930-
"""
921+
"""Returns the dag_director as a string."""
931922
if isinstance(self._dag_directory, Path):
932923
return str(self._dag_directory.resolve())
933924
else:

β€Žairflow/dag_processing/processor.py

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,6 @@ def _run_file_processor(
129129
:param thread_name: the name to use for the process that is launched
130130
:param callback_requests: failure callback to execute
131131
:return: the process that was launched
132-
:rtype: multiprocessing.Process
133132
"""
134133
# This helper runs in the newly created process
135134
log: logging.Logger = logging.getLogger("airflow.processor")
@@ -259,10 +258,7 @@ def _kill_process(self) -> None:
259258

260259
@property
261260
def pid(self) -> int:
262-
"""
263-
:return: the PID of the process launched to process the given file
264-
:rtype: int
265-
"""
261+
"""PID of the process launched to process the given file."""
266262
if self._process is None or self._process.pid is None:
267263
raise AirflowException("Tried to get PID before starting!")
268264
return self._process.pid
@@ -273,7 +269,6 @@ def exit_code(self) -> int | None:
273269
After the process is finished, this can be called to get the return code
274270
275271
:return: the exit code of the process
276-
:rtype: int
277272
"""
278273
if self._process is None:
279274
raise AirflowException("Tried to get exit code before starting!")
@@ -287,7 +282,6 @@ def done(self) -> bool:
287282
Check if the process launched to process this file is done.
288283
289284
:return: whether the process is finished running
290-
:rtype: bool
291285
"""
292286
if self._process is None or self._parent_channel is None:
293287
raise AirflowException("Tried to see if it's done before starting!")
@@ -326,20 +320,14 @@ def done(self) -> bool:
326320

327321
@property
328322
def result(self) -> tuple[int, int] | None:
329-
"""
330-
:return: result of running DagFileProcessor.process_file()
331-
:rtype: tuple[int, int] or None
332-
"""
323+
"""Result of running ``DagFileProcessor.process_file()``."""
333324
if not self.done:
334325
raise AirflowException("Tried to get the result before it's done!")
335326
return self._result
336327

337328
@property
338329
def start_time(self) -> datetime.datetime:
339-
"""
340-
:return: when this started to process the file
341-
:rtype: datetime
342-
"""
330+
"""Time when this started to process the file."""
343331
if self._start_time is None:
344332
raise AirflowException("Tried to get start time before it started!")
345333
return self._start_time
@@ -751,7 +739,6 @@ def process_file(
751739
save them to the db
752740
:param session: Sqlalchemy ORM Session
753741
:return: number of dags found, count of import errors
754-
:rtype: Tuple[int, int]
755742
"""
756743
self.log.info("Processing file %s for tasks to queue", file_path)
757744

0 commit comments

Comments
 (0)