Skip to content

Module import fails with structlog > 25.4.0 #57346

@buhln

Description

@buhln

Apache Airflow version

3.1.0

If "Other Airflow 2/3 version" selected, which one?

No response

What happened?

If the structlog package version > 25.4.0 is installed the import of airflow.sdk does not work.

>>> import airflow.sdk
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/xxxxxxx/miniconda3/envs/airflow/lib/python3.12/site-packages/airflow/__init__.py", line 79, in <module>
    settings.initialize()
  File "/home/xxxxxxx/miniconda3/envs/airflow/lib/python3.12/site-packages/airflow/settings.py", line 698, in initialize
    LOGGING_CLASS_PATH = configure_logging()
                         ^^^^^^^^^^^^^^^^^^^
  File "/home/xxxxxxx/miniconda3/envs/airflow/lib/python3.12/site-packages/airflow/logging_config.py", line 88, in configure_logging
    from airflow._shared.logging import configure_logging, init_log_folder, translate_config_values
  File "/home/xxxxxxx/miniconda3/envs/airflow/lib/python3.12/site-packages/airflow/_shared/logging/__init__.py", line 27, in <module>
    from .structlog import configure_logging, init_log_file, init_log_folder
  File "/home/xxxxxxx/miniconda3/envs/airflow/lib/python3.12/site-packages/airflow/_shared/logging/structlog.py", line 38, in <module>
    from .percent_formatter import PercentFormatRender
  File "/home/xxxxxxx/miniconda3/envs/airflow/lib/python3.12/site-packages/airflow/_shared/logging/percent_formatter.py", line 29, in <module>
    from structlog.dev import ConsoleRenderer, Styles
ImportError: cannot import name 'Styles' from 'structlog.dev' (/home/xxxxxxx/miniconda3/envs/airflow/lib/python3.12/site-packages/structlog/dev.py)

What you think should happen instead?

Import should work for structlog 25.5.0 as it does for version 25.4.0.

How to reproduce

Install Airflow with pip install apache-airflow==3.1.0, open REPL and try import airflow.sdk.

Operating System

Ubuntu 22.04.5 LTS

Versions of Apache Airflow Providers

No response

Deployment

Virtualenv installation

Deployment details

Python 3.12.11

Anything else?

No response

Are you willing to submit PR?

  • Yes I am willing to submit a PR!

Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:corekind:bugThis is a clearly a bugneeds-triagelabel for new issues that we didn't triage yet

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions