Skip to content

Stop CLI printing argparse.FileType deprecation warnings on Python 3.14 - #77853

Open
atishay-kasliwal wants to merge 1 commit into
apache:mainfrom
atishay-kasliwal:fix/77804-filetype-deprecation
Open

atishay-kasliwal wants to merge 1 commit into
apache:mainfrom
atishay-kasliwal:fix/77804-filetype-deprecation

Conversation

@atishay-kasliwal

Copy link
Copy Markdown

Python 3.14 deprecates argparse.FileType and warns when one is created. ARG_VAR_EXPORT and ARG_CONN_EXPORT created two of them when cli_config was imported, so every airflow command printed the warning twice.

This replaces them with a small writable_text_file type that behaves the same way: - is stdout, any other path is opened as UTF-8 for writing, and a path that can't be opened gives the same can't open '...' argument error.

Checked on Python 3.14:

  • airflow version prints no warnings (main prints two).
  • These commands give identical output and files on main and on this branch: variables export - / <file>, connections export - / .yaml / .txt, a missing parent directory, and a directory path.
  • The 6 new tests in test_cli_parser.py fail on main and pass here.

There is another open PR for this issue, #77841. It changes the argument to type=str, which makes variables export - write to a file named - instead of stdout, and a missing directory ends in a FileNotFoundError traceback instead of the argument error. This PR keeps the current behaviour.

closes: #77804


Was generative AI tooling used to co-author this PR?
  • Yes: Claude Code (Claude Opus 5.5)

Generated-by: Claude Code (Claude Opus 5.5) following the guidelines

Python 3.14 deprecates argparse.FileType and warns when one is created.
The variables and connections export arguments created two at import
time, so every airflow command printed the warning twice. Replace them
with a small type function that keeps the same behaviour: "-" is
stdout, other paths open as UTF-8 for writing, and unopenable paths
give the same "can't open" argument error.

closes: apache#77804
@boring-cyborg

boring-cyborg Bot commented Dec 1, 2026

Copy link
Copy Markdown

Congratulations on your first Pull Request and welcome to the Apache Airflow community! If you have any issues or are unsure about any anything please check our Contributors' Guide
Here are some useful points:

  • Pay attention to the quality of your code (ruff, mypy and type annotations). Our prek-hooks will help you with that.
  • In case of a new feature add useful documentation (in docstrings or in docs/ directory). Adding a new operator? Check this short guide Consider adding an example Dag that shows how users should use it.
  • Consider using Breeze environment for testing locally, it's a heavy docker but it ships with a working Airflow and a lot of integrations.
  • Be patient and persistent. It might take some time to get a review or get the final approval from Committers.
  • Please follow ASF Code of Conduct for all communication including (but not limited to) comments on Pull Requests, Mailing list and Slack.
  • Be sure to read the Airflow Coding style.
  • Always keep your Pull Requests rebased, otherwise your build might fail due to changes not related to your commits.
    Apache Airflow is a community-driven project and together we are making it better 🚀.
    In case of doubts contact the developers at:
    Mailing List: [email protected]
    Slack: https://s.apache.org/airflow-slack

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Every CLI command prints two "FileType is deprecated" PendingDeprecationWarnings on Python 3.14

1 participant